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.sv | |
| parent | 981f86a5b3ea6a05925c807bac26986e0c876dcf (diff) | |
Add arithmetic unit, disable gtkwave
Diffstat (limited to 'nandgame/arith_unit.sv')
| -rw-r--r-- | nandgame/arith_unit.sv | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nandgame/arith_unit.sv b/nandgame/arith_unit.sv new file mode 100644 index 0000000..ebbaaf8 --- /dev/null +++ b/nandgame/arith_unit.sv @@ -0,0 +1,27 @@ +// nandgame logic unit + +`timescale 1us/1us + +`include "nandgame_types.v" + +module arith_unit #( + parameter DATA_WIDTH = 16 +) ( + input [(DATA_WIDTH-1):0] X, + input [(DATA_WIDTH-1):0] Y, + input ArithCode operation, + + output logic [(DATA_WIDTH-1):0] RES +); + +always_comb begin + case (operation) + ARITH_PLUS: RES = X + Y; + ARITH_MINUS: RES = X - Y; + ARITH_INC: RES = X + 1; + ARITH_DEC: RES = X - 1; + default: RES = 0; + endcase +end + +endmodule |
