diff options
| author | uvok | 2026-01-01 15:44:40 +0100 |
|---|---|---|
| committer | uvok | 2026-01-01 15:44:40 +0100 |
| commit | 20fd019f0cf4c9110f44e46ff7820dd37598e164 (patch) | |
| tree | 3ee8c14d0f1c1eebd2be2631463d11074eed754a /nandgame/arith_unit_tb.sv | |
| parent | 981f86a5b3ea6a05925c807bac26986e0c876dcf (diff) | |
Add arithmetic unit, disable gtkwave
Diffstat (limited to 'nandgame/arith_unit_tb.sv')
| -rw-r--r-- | nandgame/arith_unit_tb.sv | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/nandgame/arith_unit_tb.sv b/nandgame/arith_unit_tb.sv new file mode 100644 index 0000000..054e484 --- /dev/null +++ b/nandgame/arith_unit_tb.sv @@ -0,0 +1,71 @@ +`timescale 1us/1us + +// `include "nandgame_types.v" + +module arith_unit_tb ( +); + +logic [15:0] in1; +logic [15:0] in2; +ArithCode opcode; +logic [15:0] result; + + arith_unit uut ( + .X(in1), + .Y(in2), + .operation(opcode), + .RES(result) +); + +string filename; +initial begin +`ifdef DUMP_FILE_NAME + filename=`DUMP_FILE_NAME; +`else + filename=" arith_unit.lxt2"; +`endif + $dumpfile(filename); $dumpvars(); + +end + +initial begin + in1 = 13; + in2 = 17; + opcode = ARITH_PLUS; + #1 + assert(result == 30); + #1 + in1 = 12; + in2 = 4; + opcode = ARITH_MINUS; + #1 + assert(result == 8); + #1 + in1 = 12; + in2 = 13; + opcode = ARITH_MINUS; + #1 + assert(result == 16'hffff); + #1 + in1 = 13; + in2 = 17; + opcode = ARITH_INC; + #1 + assert(result == 14); + #1 + in1 = 13; + in2 = 17; + opcode = ARITH_DEC; + #1 + assert(result == 12); + #1 + in1 = 0; + in2 = 17; + opcode = ARITH_DEC; + #1 + assert(result == 16'hffff); + #1 + $finish(); +end + +endmodule |
