Use assertions in simsoc testbench
authorJean THOMAS <git0@pub.jeanthomas.me>
Thu, 16 Jul 2020 13:36:00 +0000 (15:36 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Thu, 16 Jul 2020 13:36:00 +0000 (15:36 +0200)
gram/simulation/simsoctb.v

index 2c9d15dc12ffa9ad44763a7961a5466f318ee506..cd3b4338343679798bcd065a31144c8de07a5557 100644 (file)
@@ -183,7 +183,7 @@ module simsoctb;
       #2000;
 
       wishbone_read(32'h10000000 >> 2, tmp);
-      #2000;
+      #2000 assert_equal_32(tmp, 32'hFACECA8C);
 
       // Write
       wishbone_write(32'h10000000 >> 2, 32'h12345678);
@@ -265,4 +265,17 @@ module simsoctb;
       #50;
     end
   endtask
+
+  task assert_equal_32;
+    input [31:0] inA;
+    input [31:0] inB;
+
+    begin
+      if (inA != inB)
+        begin
+          $display("%m at %t: Assertion failed (32-bit) equality: %08x != %08x", $time, inA, inB);
+          $finish;
+        end
+    end
+  endtask
 endmodule