From 2cbdc8a905d6b4fac757ae6a33f75548b16f10e7 Mon Sep 17 00:00:00 2001 From: dianshi Date: Tue, 25 Jan 2022 21:37:30 +0000 Subject: Add alu_control version v0.1 --- alu_control/v0.1/alu_control.v | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 alu_control/v0.1/alu_control.v (limited to 'alu_control/v0.1/alu_control.v') diff --git a/alu_control/v0.1/alu_control.v b/alu_control/v0.1/alu_control.v new file mode 100644 index 0000000..fb6a743 --- /dev/null +++ b/alu_control/v0.1/alu_control.v @@ -0,0 +1,26 @@ +module alu_control( + input [1:0] alu_op, + input [3:0] opcode, + output reg [2:0] alu_cnt + +); + +wire [5:0]alu_control_in; +assign alu_control_in = {alu_op, opcode}; + +always @(alu_control_in) +casex (alu_control_in) + 6'b10xxxx: alu_cnt=3'b000; + 6'b01xxxx: alu_cnt=3'b001; + 6'b000010: alu_cnt=3'b000; + 6'b000011: alu_cnt=3'b001; + 6'b000100: alu_cnt=3'b010; + 6'b000101: alu_cnt=3'b011; + 6'b000110: alu_cnt=3'b100; + 6'b000111: alu_cnt=3'b101; + 6'b001000: alu_cnt=3'b110; + 6'b001001: alu_cnt=3'b111; + default: alu_cnt=3'b000; +endcase + +endmodule \ No newline at end of file -- cgit v1.2.3