简体   繁体   English

Verilog错误:连续分配左侧的寄存器非法

[英]Verilog error: Register is illegal in left-hand side of continuous assignment

I'm a verilog noob and I have to do this ALU for a processor but I get this error for this line: 我是verilog noob,我必须为处理器执行此ALU,但在此行中遇到此错误:

assign SP_out = SP; 分配SP_out = SP;

"Register is illegal in left-hand side of continuous assignment" “在连续分配的左侧注册无效”

I'm using modelsim. 我正在使用modelsim。

module ALU(opcode,ra,rb,ra_out,cin,co,res,rst,clk,pc,npc,CCRin,CCRo,SP,SP_out);
  output [1:0] res; // result 
  input wire [7:0]pc;
  output reg [7:0] npc;
  input rst,clk;
  input wire cin;
  input wire [3:0] opcode;
  input wire[1:0] ra;
  input wire[1:0] rb;
  output reg[1:0] ra_out;
  input wire[7:0] SP; // testbench haygebli SP el mafroud yeb2a = 255
  output reg[7:0] SP_out;

  reg[255:0] dmem;

  input wire [3:0] CCRin;
  output reg [3:0] CCRo;
  output co;

  wire [2:0] result; //total result

  assign SP_out = SP;

  assign result = alu_out(ra,rb,cin); 
  assign res = result[1:0];
  assign co = result[2];



  function [2:0] alu_out;
   input [1:0] ra,rb;
   input cin;

  case (opcode)
    0: ;
    4: assign alu_out = ra + rb;
    5: assign alu_out = ra - rb;
    6: assign alu_out = ~(ra & rb);
    7: assign alu_out = {ra[1:0],cin};
    8: assign alu_out = {ra[0],cin,ra[1]};
    10: if (ra == 1)
          begin
         dmem[SP_out] = rb;
         SP_out = SP_out-1;
       end
     else
       begin
       SP_out = SP_out +1;
       rb = dmem[SP_out];
     end
    13: assign ra_out = rb;
    default: begin
    alu_out = 8'bxxxxxxxx; 
    npc = pc+1;


end
endcase 
endfunction
  always@( res)
   begin 
  if (res == 0)
     CCRo[0] = 1;
  else if ( res < 0)
   CCRo[1] = 1;
  else if (co == 1)
    CCRo[2] = 1;
  else if ( res < 0 & res > result)
    CCRo[3] = 1;
  else
    CCRo = CCRin;
end
endmodule

assign statements are only legal on wire types, not reg types. assign语句仅在wire类型上合法,而在reg类型上无效。

If you have a reg , then you want to assign it from a block: 如果您有一个reg ,那么您想从一个块中分配它:

always @* begin
   SP_out = SP;
end

Alternatively, remove the reg declaration from SP_out to treat it as a wire, then your assign statement will work. 或者,从SP_out删除reg声明以将其视为连接,然后您的assign语句将起作用。

Both options will behave in the exact same way. 这两个选项的行为完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Verilog HDL错误:左侧分配非法 - Verilog HDL error: Illegal left-hand side assignment 为什么导线变量导致连续分配中的非法左侧? - Why is wire variable causing illegal left-hand side in continuous assignment? 连续分配的左侧是非法的 - The left-hand-side of continuous assignment is illegal 错误(10219):Mux.v处的Verilog HDL连续分配错误(19):分配左侧的对象“ muxout”必须具有网络类型 - Error (10219): Verilog HDL Continuous Assignment error at Mux.v(19): object “muxout” on left-hand side of assignment must have a net type Verilog错误:分配左侧的对象必须具有可变数据类型 - Verilog Error: Object on left-hand side of assignment must have a variable data type Verilog:作业左侧必须具有可变数据类型 - Verilog: on left-hand side of assignment must have a variable data type 不允许对非寄存器 shifty 进行程序分配,左侧应该是 reg/integer/time/genvar——这是我得到的错误 - Procedural assignment to a non-register shiftedy is not permitted, left-hand side should be reg/integer/time/genvar -- this is the error I am getting 封锁作业的左侧无效 - Illegal left hand side of blocking assignment Verilog 寄存器不能由原语或连续赋值驱动 - Verilog register cannot be driven by primitives or continuous assignment Verilog:不支持程序连续分配注册 - Verilog:Procedural Continuous Assignment to register is not supported
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM