From 43d23e3d9b24d0627fa3338f66ddc8d425058286 Mon Sep 17 00:00:00 2001
From: Noah Boorstin <nboorstin@hmc.edu>
Date: Mon, 22 Mar 2021 18:24:31 -0400
Subject: [PATCH] busybear: add better warning on illegal instruction

...also it seems that mret is being picked up as an illegal instruction??
---
 wally-pipelined/testbench/testbench-busybear.sv | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/wally-pipelined/testbench/testbench-busybear.sv b/wally-pipelined/testbench/testbench-busybear.sv
index 4015e8c89..6f957efa3 100644
--- a/wally-pipelined/testbench/testbench-busybear.sv
+++ b/wally-pipelined/testbench/testbench-busybear.sv
@@ -262,8 +262,14 @@ module testbench_busybear();
   end
 
   always @(dut.hart.priv.csr.genblk1.csrm.MCAUSE_REGW) begin
+    if (dut.hart.priv.csr.genblk1.csrm.MCAUSE_REGW == 2 && instrs != 0) begin
+      $display("!!!!!! illegal instruction !!!!!!!!!!");
+      $display("(as a reminder, MCAUSE and MEPC are set by this)");
+      $display("at %0t ps, instr %0d, HADDR %x", $time, instrs, HADDR);
+      `ERROR
+    end
     if (dut.hart.priv.csr.genblk1.csrm.MCAUSE_REGW == 5 && instrs != 0) begin
-      $display("!!!!!!illegal (physical) memory access !!!!!!!!!!");
+      $display("!!!!!! illegal (physical) memory access !!!!!!!!!!");
       $display("(as a reminder, MCAUSE and MEPC are set by this)");
       $display("at %0t ps, instr %0d, HADDR %x", $time, instrs, HADDR);
       `ERROR