Add log of events to view.

This commit is contained in:
Danila Fedorin 2019-05-28 22:51:02 -07:00
parent 2f180bbf98
commit 8d00731248

View File

@ -133,13 +133,41 @@ viewAccessView m av =
currentCache = Maybe.withDefault [] m.hierarchy
in
div [ class "access-view" ]
[ viewCacheHierarchy <| effectiveCacheHierarchy currentCache av
[ h2 [] [ text "Access Simulation" ]
, buttonWrapper
[ button "Forward" AccessViewForward
, button "Back" AccessViewBack
]
, viewAccessLog av
, viewCacheHierarchy <| effectiveCacheHierarchy currentCache av
]
viewAccessLog : AccessView -> Html Msg
viewAccessLog (aes, ap) =
let
resultSpan r =
case r of
Hit -> span [ class "success" ] [ text "HIT" ]
Miss -> span [ class "failure" ] [ text "MISS" ]
downEvent n ae = div [ class "event" ]
[ text <| "L" ++ String.fromInt (n + 1)
, resultSpan ae.result
]
upEvent n ae = div [ class "event" ]
[ text <| "Updated L" ++ String.fromInt (n + 1)
]
events =
case ap of
Done -> []
Down n -> List.indexedMap downEvent <| List.take (n + 1) aes
Up n -> List.indexedMap downEvent aes ++
(List.indexedMap upEvent <| List.drop n aes)
in
div [ class "access-log" ]
[ h3 [] [ text "Simulation events" ]
, div [ class "access-log-events" ] events
]
viewAccessInput : Model -> Html Msg
viewAccessInput m =
let