-
-
-{-
-first attempt at BlockRAM
-
-State:
-mem: content of the RAM
-
-Input:
-data_in: input value to be written to 'mem' at location 'wraddr'
-rdaddr: read address
-wraddr: write address
-wrenable: write enable flag
-
-Output:
-data_out: value of 'mem' at location 'rdaddr'
--}
-blockRAM :: (MemState a) ->
- ( a
- , Discr
- , Discr
- , Discr
- , Bit
- ) ->
- (MemState a, (a, a) )
-blockRAM (State mem) (data_in, rdaddr1, rdaddr2, wraddr, wrenable) =
- ((State mem'), (data_out1,data_out2))
- where
- data_out1 = mem!rdaddr1
- data_out2 = mem!rdaddr2
- -- Only write data_in to memory if write is enabled
- mem' | wrenable == Low = mem
- | otherwise = replace mem wraddr data_in