将约克熔岩功能转换为堪萨斯熔岩



我这里有一个York Lava函数,我想在Kansas Lava中重写。但它行不通,我不知道我是否应该这么做。有人能帮我一下吗?

{-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]

现在我试着在堪萨斯熔岩中写这个,他们是一个延迟函数,但我得到了奇怪的结果。下面的代码使用与第一个示例相同的参数生成me:

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'   

您的代码完全按照预期工作。

在GHCi的模拟器中尝试你的函数,结果是:

*Main> sipo 3 (high :: Signal CLK Bool)
[high,? | high .,? | ? | high .]

阅读方法:

 sipo 3 high !! 0 = high
 sipo 3 high !! 1 = ?    | high
 sipo 3 high !! 2 = ?    | ?    | high

熔岩模拟器的输出意味着第一个输出是第一个循环中的high,并且没有模拟器输入来告诉进一步的值。同样,第二个输出在第一个周期中未定义,第二个周期中未定义high;第三个输出两个周期未定义,第三个周期为high

这很有意义,因为第二个输出在第一个周期中没有被设置为任何值:延迟的输入信号还没有时间到达那里。

结果与York Lava不同的原因是York Lava的delay原语似乎在第一个时钟周期之前使用了一个额外的值。我不确定这是可合成的

最新更新