Question: module maindec ( Z _ flag, opcode, PCSrc , / / funct 3 , / / / bne ResultSrc, MemWrite, / / ALUSrc , ALUSrcA,

module maindec( Z_flag, opcode, PCSrc,//funct3,///bne ResultSrc, MemWrite, //ALUSrc, ALUSrcA, ALUSrcB, ImmSrc, RegWrite, Jump, ALUop, Branch, Btaken ); // input input Z_flag; //input [2:0]funct3; //bne input [6:0] opcode; input Btaken; // output output [1:0]PCSrc; output reg MemWrite, RegWrite, Jump; output reg [1:0]ALUSrcA; output reg ALUSrcB; output reg [1:0] ResultSrc; output reg [2:0] ImmSrc; output reg [1:0] ALUop; output reg Branch; assign PCSrc =(Btaken ==1'b1| Jump ==1'b1)?2'b01 : 2'b00; //assign PCSrc =(Jump ==1'b1)?2'b10 : //(Btaken ==1'b1)?2'b01 : 2'b00; always@(*) begin // main decoder case(opcode)//{1,3,2,1,1,2,1,2,1}7'b000_0011 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b10_0000_0000_0000; // lw, lbu 7'b010_0011 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b00_0100_1100_0000; // sw, sb 7'b011_0011 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b1x_xx00_0000_0100; // R-type, sar 7'b110_0011 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b010_00xx_1010; // beq, bne //7'b110_0011 : {RegWrite, ImmSrc, ALUSrc, MemWrite, ResultSrc, Branch, ALUop, Jump}=11'b010_00xx_0010; // bnes 7'b001_0011 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b100_1000_0100; // I-type ALU, slli srli 7'b110_1111 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b111_x010_0xx1; // jal 7'b011_0111 : {RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b11_0010_1000_0010//lui 7'b001_0111 :{RegWrite, ImmSrc, ALUSrcA, ALUSrcB, MemWrite, ResultSrc, Branch, ALUop, Jump}=14'b //auipc default : {RegWrite, ImmSrc, ALUSrc, MemWrite, ResultSrc, Branch, ALUop, Jump}=11'hx; endcase end endmodule .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!