diff options
| author | Prashanth Mundkur | 2018-06-07 11:03:58 -0700 |
|---|---|---|
| committer | Prashanth Mundkur | 2018-06-07 13:08:53 -0700 |
| commit | 10a6c9a83405084092c26ce432051bbeae8f2f1a (patch) | |
| tree | 3ee92bec8ee7191d432cb0ce42acadde56d3f525 /riscv/riscv_platform.sail | |
| parent | 6eaf3159474aa62b9afee843b0983dcfb23a4157 (diff) | |
Add terminal output to riscv platform, with incomplete handling of input.
Diffstat (limited to 'riscv/riscv_platform.sail')
| -rw-r--r-- | riscv/riscv_platform.sail | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/riscv/riscv_platform.sail b/riscv/riscv_platform.sail index f3911ba9..a002341a 100644 --- a/riscv/riscv_platform.sail +++ b/riscv/riscv_platform.sail @@ -70,7 +70,12 @@ function clint_store(addr, width, data) = { } else MemException(E_SAMO_Access_Fault) } -/* Spike's HTIF device interface. */ +/* Basic terminal character I/O. */ + +val plat_term_write = {ocaml: "Platform.term_write", lem: "plat_term_write"} : bits(8) -> unit +val plat_term_read = {ocaml: "Platform.term_read", lem: "plat_term_read"} : unit -> bits(8) + +/* Spike's HTIF device interface, which multiplexes the above MMIO devices. */ bitfield htif_cmd : bits(64) = { device : 63 .. 56, @@ -81,7 +86,6 @@ bitfield htif_cmd : bits(64) = { register htif_done : bool register htif_exit_code : xlenbits -// no support yet for terminal input val htif_load : forall 'n, 0 < 'n <= 64. (xlenbits, int('n)) -> MemoryOpResult(bits(8 * 'n)) function htif_load(addr, width) = MemValue(EXTZ(0b0)) @@ -103,8 +107,8 @@ function htif_store(addr, width, data) = { }, 0x01 => { /* terminal */ match cmd.cmd() { - 0x00 => /* input */ (), - 0x01 => /* TODO: output data */ (), + 0x00 => /* TODO: terminal input handling */ (), + 0x01 => plat_term_write(cmd.payload()[7..0]), c => print("Unknown term cmd: " ^ BitStr(c)) } }, |
