blob: 53ea17e90a08dd909d2ef0ef27d4b2fd0730ee25 (
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
33
34
35
36
|
// nandgame arithmetic unit
`timescale 1us/1us
`include "nandgame_types.v"
`ifndef NANDGAME_ARU
`define NANDGAME_ARU
module arith_unit #(
parameter DATA_WIDTH = 16
) (
// first operand
input [(DATA_WIDTH-1):0] X_in,
// second operand
input [(DATA_WIDTH-1):0] Y_in,
// opcode, see ArithCode
input ArithCode arith_operation_in,
// result of operation
output logic [(DATA_WIDTH-1):0] result_out
);
always_comb begin
case (arith_operation_in)
ARITH_PLUS: result_out = X_in + Y_in;
ARITH_MINUS: result_out = X_in - Y_in;
ARITH_INC: result_out = X_in + 1;
ARITH_DEC: result_out = X_in - 1;
default: result_out = 0;
endcase
end
endmodule
`endif
|