Verilog: on left-hand side of assignment must have a variable data type

天涯浪子 提交于 2019-12-11 12:48:59

问题


I am having trouble with combination assignment. I do not understand why I cannot use a always combination structure the set my output variables. When I use assign, I do not get the assignment error.

I thought assign and always@(*) both means blocking (combinational assignment)

module control_unit(input wire [31:0] instruction
                   ,output wire RegDst
                   ,output wire ALUSrc
                   ,output wire RegWrite
                   ,output wire MemRead
                   ,output wire MemWrite
                   ,output wire MemToReg
                   ,output wire Branch
                   );

   wire [5:0] opcode;

   assign opcode  = instruction[31:26];

   always@(*) begin
      case(opcode)
            6'b000000: begin              // r-type
               RegDst   = 1'b1;
               ALUSrc   = 1'b0;
               RegWrite = 1'b1;
               MemRead  = 1'b0;
               MemWrite = 1'b0;
               MemToReg = 1'b0;
               Branch   = 1'b0;
            end
           .
           .
           .                    
            default: begin
               RegDst   = 1'b0;
               ALUSrc   = 1'b0;
               RegWrite = 1'b0;
               MemRead  = 1'b0;
               MemWrite = 1'b0;
               MemToReg = 1'b0;
               Branch   = 1'b0;
            end
      endcase
   end // end always_comb
endmodule

回答1:


You cannot make a procedural assignment to a wire. You must make a procedural assignment to a reg, regardless of whether the always block describes sequential or combinational logic. Use the following port declarations:

               ,output reg RegDst
               ,output reg ALUSrc
               ,output reg RegWrite
               ,output reg MemRead
               ,output reg MemWrite
               ,output reg MemToReg
               ,output reg Branch


来源:https://stackoverflow.com/questions/37946414/verilog-on-left-hand-side-of-assignment-must-have-a-variable-data-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!