4
我在这里有一个约克熔岩函数,我想在堪萨斯熔岩重写。但它不想工作,我不知道我应该这样做。 有人可以帮助我吗?将约克熔岩函数转换为堪萨斯熔岩
{-Serial In - Parallel Out shiftregister. The serial bit is inserted at
the least significant bit position. The data is shifted LSB -> MSB
each and every clock cycle-}
sipo :: Int --^The number of bits in the output word.
-> Bit --^The input bit.
-> [Bit] --^The output word.
sipo 1 inp = [inp]
sipo n inp = inp : rest
where
inp' = delay low inp
rest = sipo (n-1) inp'
这上面的函数给了我一些例子,这些正确的结果:
n = 3
inp = high
out = [high, low, low]
n= 5
inp = high
out = [high, low, low, low, low]
现在,我已经试过在堪萨斯熔岩写这个,他们是延迟功能,但我得到奇怪的结果。 下面这段代码生成我,用相同的参数,第一个例子:
n = 3
inp = high
out = [high?, high., high!] (don't know what that means)
sipo :: (Clock clk)
=> Int --^The number of bits in the output word.
-> Signal clk Bool --^The input bit.
-> [Signal clk Bool] --^The output word.
sipo 1 inp = [inp]
sipo n inp = inp : rest
where
inp' = delay inp
rest = sipo (n-1) inp'
你能更具体一点关于正确的输出应该是什么? –
n代表列表有多大 inp是输入低或高 输出比inp ++ n倍低值 out = [inp,low,low,low,...,n ] 示例:n = 2的 INP =高 OUT = [高,低] 第二个例子:N = 5 INP =低 OUT = [低,低,低,低,低] –
(1)你确定最后的代码段与你粘贴的错误相符吗? (2)GHC(i)的类型是什么类型?我不知道'I'到'CLK'的专业化会导致'无法匹配预期类型'[Signal i0 Bool]',实际类型'Signal clk0 a0' )如果你暂时删除签名,推断“sipo”? – duplode