blob: e0254aa5cbb8cbcba37a2a7cdd1ffb3fcf5b0b9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// nandgame arithmetic unit
`timescale 1us/1us
`include "nandgame_types.v"
`ifndef NANDGAME_ARU
`define NANDGAME_ARU
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
`endif
|