-
Notifications
You must be signed in to change notification settings - Fork 0
/
alu.v
27 lines (24 loc) · 813 Bytes
/
alu.v
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
module alu(input clk, input rst, input [6:0] opcode, input [proc.ARCH_BITS-1:0] data1,
input [proc.ARCH_BITS-1:0] data2, output reg [proc.ARCH_BITS-1:0] res);
wire [proc.ARCH_BITS-1:0] resAdd;
wire [proc.ARCH_BITS-1:0] resSub;
assign resAdd = data1 + data2;
assign resSub = data1 - data2;
always @(*)
begin
case(opcode)
proc.OPCODE_ADD: res = resAdd;
proc.OPCODE_SUB: res = resSub;
proc.OPCODE_LDB: res = resAdd;
proc.OPCODE_LDW: res = resAdd;
proc.OPCODE_STB: res = resAdd;
proc.OPCODE_STW: res = resAdd;
proc.OPCODE_BEQ: res = resAdd;
proc.OPCODE_JUMP: res = resAdd;
proc.OPCODE_BZ: res = resAdd;
proc.OPCODE_MOV: res = data1;
proc.OPCODE_MOVI: res = data1;
default: res = 32'hffffffff;
endcase
end
endmodule