Add basic hierarchy code.

This commit is contained in:
Danila Fedorin 2019-05-28 19:01:14 -07:00
parent 8de1d82d88
commit 5023b6c341

View File

@ -0,0 +1,23 @@
module CacheSim.Hierarchy exposing (..)
import CacheSim.Cache exposing (..)
type alias CacheModelHierarchy = List CacheModel
type alias CacheHierarchy = List Cache
accessCacheHierarchy : WordAddr -> CacheHierarchy -> Result String (List (AccessEffect Cache))
accessCacheHierarchy wa ch =
case ch of
[] -> Ok []
c::cs ->
case accessCache wa c of
Ok { result, output } ->
case result of
Hit ->
Ok [ { result = Hit, output = output } ]
Miss ->
Result.map ((::) { result = Miss, output = output })
<| accessCacheHierarchy wa cs
Err e -> Err e
freshCacheHierarchy : CacheModelHierarchy -> CacheHierarchy
freshCacheHierarchy cmh = List.map freshCache cmh