diff options
author | Alasdair <alasdair.armstrong@cl.cam.ac.uk> | 2024-05-09 20:07:30 +0100 |
---|---|---|
committer | Bill McSpadden <bill@riscv.org> | 2024-05-12 14:36:33 -0500 |
commit | e1242d851d6b27b357bfb31d46c8f08e18fb768b (patch) | |
tree | d85a9cf6756e5e42d2ceb38cadd2c65c02b560bc /model/riscv_types.sail | |
parent | 82acf052d4392f0662fa62cccea2353d57b4145a (diff) | |
download | sail-riscv-e1242d851d6b27b357bfb31d46c8f08e18fb768b.zip sail-riscv-e1242d851d6b27b357bfb31d46c8f08e18fb768b.tar.gz sail-riscv-e1242d851d6b27b357bfb31d46c8f08e18fb768b.tar.bz2 |
Refactor MUL instruction
This instruction had a bit of a case of 'boolean blindness' code smell,
where the mul operation was represented as a triple of booleans. This
commit refactors the implemention to use a struct with named fields for
high, signed_rs1, and signed_rs2.
The C_MUL instruction in Zcb also needs to be changed appropriately
The mul_op struct was added in riscv_types
While there do some housekeeping w.r.t the comment about a workaround for
Sail < 0.15.1, as this is no longer needed.
Diffstat (limited to 'model/riscv_types.sail')
-rw-r--r-- | model/riscv_types.sail | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/model/riscv_types.sail b/model/riscv_types.sail index e9a5a19..2b1c132 100644 --- a/model/riscv_types.sail +++ b/model/riscv_types.sail @@ -389,6 +389,12 @@ mapping size_bytes : word_width <-> {1, 2, 4, 8} = { DOUBLE <-> 8, } +struct mul_op = { + high : bool, + signed_rs1 : bool, + signed_rs2 : bool +} + /*! * Raise an internal error reporting that width w is invalid for access kind, k, * and current xlen. The file name and line number should be passed in as the @@ -399,17 +405,6 @@ mapping size_bytes : word_width <-> {1, 2, 4, 8} = { */ val report_invalid_width : forall ('a : Type). (string, int, word_width, string) -> 'a function report_invalid_width(f , l, w, k) -> 'a = { - /* - * Ideally we would call internal_error here but this triggers a Sail bug, - * https://github.com/rems-project/sail/issues/203 in versions < 0.15.1, so - * we work around this by manually inlining. - * TODO when we are happy to require Sail >= 0.15.1 uncomment the following - * and remove the rest of the function. - */ - // internal_error(f, l, "Invalid width, " ^ size_mnemonic(w) ^ ", for " ^ k ^ - // " with xlen=" ^ dec_str(sizeof(xlen))); - assert (false, f ^ ":" ^ dec_str(l) ^ ": " ^ "Invalid width, " - ^ size_mnemonic(w) ^ ", for " ^ k ^ " with xlen=" - ^ dec_str(sizeof(xlen))); - throw Error_internal_error() + internal_error(f, l, "Invalid width, " ^ size_mnemonic(w) ^ ", for " ^ k ^ + " with xlen=" ^ dec_str(sizeof(xlen))) } |