Ensure that MimaMemory is always sparse

This commit is contained in:
Joscha 2019-11-06 16:43:57 +00:00
parent 5fdbf2fbd2
commit a1f532172a

View file

@ -33,7 +33,10 @@ addressRange (MimaMemory m) =
in [minBound..maxAddr]
wordsToMemory :: [MimaWord] -> MimaMemory
wordsToMemory = MimaMemory . Map.fromAscList . zip [minBound..]
wordsToMemory = MimaMemory
. Map.filter (/= zeroBits)
. Map.fromAscList
. zip [minBound..]
memoryToWords :: MimaMemory -> [MimaWord]
memoryToWords mem = map (\addr -> readAt addr mem) $ addressRange mem