blob: 8394ba80e610bade21fce41553e441cf3c5c01d9 [file] [log] [blame]
Yuki Azuma10b8f642021-10-05 15:52:38 +09001module alu_controller(opcode, alu_ctrl);
2 input [3:0] opcode;
3 output [3:0] alu_ctrl;
4
5 assign alu_ctrl = alu_control(opcode);
6
7 function [3:0] alu_control(input [3:0] opcode);
8 begin
9 case(opcode)
10 4'b0001: alu_control = 4'b0000;
Cra2yPierr0t39c95b02021-10-13 21:56:29 +090011 4'b0010: alu_control = 4'b1000;
Yuki Azuma10b8f642021-10-05 15:52:38 +090012 4'b0011: alu_control = 4'b0001;
13 4'b0100: alu_control = 4'b0010;
14 4'b0101: alu_control = 4'b0011;
15 4'b0110: alu_control = 4'b0100;
16 4'b0111: alu_control = 4'b0101;
17 4'b1000: alu_control = 4'b0110;
18 4'b1001: alu_control = 4'b0111;
19 endcase
20 end
21 endfunction
22endmodule