2019-05-27 14:08:48 -07:00
|
|
|
import CacheSim.Model exposing (..)
|
2019-05-28 19:26:02 -07:00
|
|
|
import CacheSim.Cache exposing (..)
|
|
|
|
import CacheSim.IntMap exposing (..)
|
|
|
|
import CacheSim.Hierarchy exposing (..)
|
|
|
|
import CacheSim.Raw exposing (..)
|
|
|
|
import CacheSim.View exposing (..)
|
2019-05-27 14:08:48 -07:00
|
|
|
import Browser exposing (Document, document)
|
|
|
|
import Html exposing (text)
|
|
|
|
|
2019-05-28 19:26:02 -07:00
|
|
|
testCacheModelHierarchy =
|
|
|
|
[ { blockSize = "128", setCount = "8", setSize = "1" }
|
|
|
|
]
|
|
|
|
|
2019-05-27 14:08:48 -07:00
|
|
|
init : Flags -> (Model, Cmd Msg)
|
2019-05-28 19:26:02 -07:00
|
|
|
init f =
|
|
|
|
let
|
|
|
|
initialModel =
|
|
|
|
{ rawCacheModelHierarchy = testCacheModelHierarchy
|
|
|
|
}
|
|
|
|
in
|
|
|
|
(initialModel, Cmd.none)
|
2019-05-27 14:08:48 -07:00
|
|
|
|
|
|
|
view : Model -> Document Msg
|
|
|
|
view m =
|
|
|
|
{ title = "Cache Simulator"
|
2019-05-28 19:26:02 -07:00
|
|
|
, body = [ viewRawCacheModelHierarchy m.rawCacheModelHierarchy ]
|
2019-05-27 14:08:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
update : Msg -> Model -> (Model, Cmd Msg)
|
2019-05-28 19:26:02 -07:00
|
|
|
update msg m =
|
|
|
|
case msg of
|
|
|
|
UpdateRawModel l f ->
|
|
|
|
({ m | rawCacheModelHierarchy = intMapUpdate l f m.rawCacheModelHierarchy}, Cmd.none)
|
2019-05-27 14:08:48 -07:00
|
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
2019-05-28 19:26:02 -07:00
|
|
|
subscriptions m = Sub.none
|
2019-05-27 14:08:48 -07:00
|
|
|
|
|
|
|
main = document
|
|
|
|
{ init = init
|
|
|
|
, view = view
|
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
}
|