Convert York Lava Function to Kansas Lava

I have a York Lava function that I want to rewrite in Kansas Lava. But he does not want to work, and I do not know that I should really do this. Can someone help me with this please?

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

This function above gives me these correct results for some examples:

n = 3
inp = high
out = [high, low, low]

n= 5
inp = high
out = [high, low, low, low, low]

Now I tried to write this in Kansas Lava, their delay function, but I get strange results. This code below generates me with the same parameters as in the first example:

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'   
+4
source share
1 answer

Your code works exactly as expected.

Trying to execute its function in a simulator from GHCi, the result:

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

Reading method:

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

Lava , high , . , undefined high ; undefined high .

, : .

, York Lava, , York Lava delay, , , . , .

+2

Source: https://habr.com/ru/post/1539952/


All Articles