Prev Problem
Next Problem

51. Opcode Decoder

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

Switch case is used for  each of the 4 cases. 

 

 

Code

module alu_decoder (
    input  [1:0] opcode,
    output reg [3:0] alu_op
);
    always @* begin
        case (opcode)
            // Write solution here
            2'b00: assign alu_op = 4'b0001;
            2'b01: assign alu_op = 4'b0010;
            2'b10: assign alu_op = 4'b0100;
            2'b11: assign alu_op = 4'b1000;
            default: assign alu_op = 4'b0000;
        endcase
    end
endmodule

 

Was this helpful?
Upvote
Downvote