Add basic hierarchy code.
This commit is contained in:
parent
8de1d82d88
commit
5023b6c341
23
src/CacheSim/Hierarchy.elm
Normal file
23
src/CacheSim/Hierarchy.elm
Normal 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
|
Loading…
Reference in New Issue
Block a user