aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Richardson <alexrichardson@google.com>2023-03-14 12:20:26 +0000
committerGitHub <noreply@github.com>2023-03-14 07:20:26 -0500
commit6df1e784cf80e909cf7d8ec77f139805c2730e08 (patch)
tree260d290149c1edb1ad74a6b16c0d46c3d85b793c
parentad13bf2deaab2a36b2caea1e92dcbaa63ad2a534 (diff)
downloadsail-riscv-6df1e784cf80e909cf7d8ec77f139805c2730e08.zip
sail-riscv-6df1e784cf80e909cf7d8ec77f139805c2730e08.tar.gz
sail-riscv-6df1e784cf80e909cf7d8ec77f139805c2730e08.tar.bz2
Move ILLEGAL/C_ILLEGAL ast declaration to riscv_insts_begin.sail (#223)
This is useful for the sail-cheri-riscv model, where we would like to reuse C_ILLEGAL, but can't right now since it is current defined too late. It is needed for https://github.com/CTSRD-CHERI/sail-cheri-riscv/pull/69
-rw-r--r--model/riscv_insts_begin.sail9
-rw-r--r--model/riscv_insts_end.sail4
2 files changed, 9 insertions, 4 deletions
diff --git a/model/riscv_insts_begin.sail b/model/riscv_insts_begin.sail
index 52748b2..f5cc2e4 100644
--- a/model/riscv_insts_begin.sail
+++ b/model/riscv_insts_begin.sail
@@ -85,3 +85,12 @@ scattered mapping encdec
val encdec_compressed : ast <-> bits(16) effect {rreg}
scattered mapping encdec_compressed
+
+/*
+ * We declare the ILLEGAL/C_ILLEGAL ast clauses here instead of in
+ * riscv_insts_end, so that model extensions can make use of them.
+ * However, the encdec mapping must come last to ensure that all
+ * unmatched encodings decode to an illegal instruction.
+ */
+union clause ast = ILLEGAL : word
+union clause ast = C_ILLEGAL : half
diff --git a/model/riscv_insts_end.sail b/model/riscv_insts_end.sail
index 267d080..a94b88a 100644
--- a/model/riscv_insts_end.sail
+++ b/model/riscv_insts_end.sail
@@ -70,8 +70,6 @@
/* ****************************************************************** */
-union clause ast = ILLEGAL : word
-
mapping clause encdec = ILLEGAL(s) <-> s
function clause execute (ILLEGAL(s)) = { handle_illegal(); RETIRE_FAIL }
@@ -80,8 +78,6 @@ mapping clause assembly = ILLEGAL(s) <-> "illegal" ^ spc() ^ hex_bits_32(s)
/* ****************************************************************** */
-union clause ast = C_ILLEGAL : half
-
mapping clause encdec_compressed = C_ILLEGAL(s) <-> s
function clause execute C_ILLEGAL(s) = { handle_illegal(); RETIRE_FAIL }