Sun Aug 5 11:13:03 EDT 2018

Building a CPU

The outer part of a CPU is the update of the instruction pointer in
terms of the current instruction word.

closeIW :: Seq m r => SType -> SType -> (r S -> m ((r S, r S), o)) -> m o
closeIW tw ta f = do
  closeMem [tw] $ \[iw] -> do
    (ip', out) <- closeReg [ta] $ \[ip] -> do
      ((jmp, dst), out) <- f iw
      ip1 <- inc ip
      ip' <- if' jmp dst ip1
      return ([ip'], (ip',out)) -- comb out
    return ([(0, 0, 0, ip')], out) -- imem is read-only

This raises the questions: what is the output of a CPU?

The central idea is to perform composition of multiple of these
"close" operations.

The input/output of a cpu:
- instruction memory writes
- GPIn, GPOut