diff --git a/src/CacheSim/View.elm b/src/CacheSim/View.elm index c14f20b..9a41775 100644 --- a/src/CacheSim/View.elm +++ b/src/CacheSim/View.elm @@ -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