简体   繁体   English

错误(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

I want to make Frequency Divider with Counter and MUX. 我想用计数器和MUX制作分频器。

I make 3 module for project 我为项目制作3个模块

// 4-bit Counter // 4位计数器

module Counter (input clk, input reset, output reg[3:0] out);

   always@(posedge clk or posedge reset)
   begin
      if(reset)
         out = 4'b0000; 
      else
      begin
         if(clk)
            if(out < 4'b1111)
            out = out + 4'b0001;
            else
            out = 4'b0000;
      end
   end


endmodule

//module 4by1 Mux //模块4by1 Mux

module Mux (input [3:0] muxin , input [1:0] sel, output reg muxout);


   function _4by1mux;

      input [3:0] muxin;
      input [1:0] sel;

      case (sel)
         2'b00 : _4by1mux = muxin[0];
         2'b01 : _4by1mux = muxin[1];
         2'b10 : _4by1mux = muxin[2];
         2'b11 : _4by1mux = muxin[3];
      endcase
   endfunction

   assign muxout = _4by1mux(muxin, sel);


endmodule

//module freqDivider //模块freqDivider

 module freqDivider(input clk, input reset, input [1:0] sel, output reg muxout);

   wire [3:0]counterbus;

   Counter ct1 (clk, reset, counterbus);
   Mux mux1 (counterbus, sel, muxout);

endmodule

module freqDivider is top, and I call module Counter and Mux 模块freqDivider位于顶部,我调用模块Counter和Mux

but module Mux has problem with 但是模块Mux有问题

Error (10219): Verilog HDL Continuous Assignment error at Mux.v(19):
object "muxout" on left-hand side of assignment must have a net type

this error 这个错误

ps. ps。 input sel will be changed by time 输入sel将随时间改变

The error is a result of the muxout output having type reg instead of type wire . 该错误是由于muxout输出具有reg类型而不是类型wire In verilog, lines can have two overarching types, either nets (like wire type) or variables (like reg types). 在verilog中,线可以具有两种总体类型,即网络(如wire类型)或变量(如reg类型)。 To assign values/logic to net types, you need to use assign statements and not always blocks. 要将值/逻辑分配给网络类型,您需要使用assign语句,而不always块。 To assign values/logic to variable types, you can only use always blocks and not assign statements. 要将值/逻辑分配给变量类型,只能使用always块,不能assign语句。 So, you can either make your assign in the Mux module an always block or, for an easier solution, don't make the muxout output a reg , just leave out the reg keyword and it will be a wire . 因此,您可以在Mux模块中将您的assign always阻塞,或者,为了更简单的解决方案,不要将muxout输出设置为reg ,而只需忽略reg关键字,它将成为wire

Error is that you have declared mux_out as reg type, instead of wire type. 错误是您已将mux_out声明为reg类型,而不是wire类型。 Default type of any port is wire. 任何端口的默认类型是wire。 You are doing continuous assignment on that net through assign keyword. 您正在通过assign关键字对该网络进行连续分配。 And on reg type nets, assignment can only be done inside procedural block (initial, always). reg类型的网络上,赋值只能在程序块内部进行(初始的,始终是)。

Change to mux_out from output reg to output only. output reg更改为mux_out ,仅output

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

相关问题 Verilog错误:分配左侧的对象必须具有可变数据类型 - Verilog Error: Object on left-hand side of assignment must have a variable data type Verilog HDL错误:左侧分配非法 - Verilog HDL error: Illegal left-hand side assignment Verilog错误:连续分配左侧的寄存器非法 - Verilog error: Register is illegal in left-hand side of continuous assignment Verilog:作业左侧必须具有可变数据类型 - Verilog: on left-hand side of assignment must have a variable data type Verilog错误“连续赋值output必须是网” - Verilog error "continuous assignment output must be a net" 为什么导线变量导致连续分配中的非法左侧? - Why is wire variable causing illegal left-hand side in continuous assignment? 连续分配的左侧是非法的 - The left-hand-side of continuous assignment is illegal 不允许对非寄存器 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 连续赋值中的非法赋值表达式。 Verilog 八进制 2 到 1 多路复用器 - Illegal assignment expression in continuous assignment. Verilog Octal 2 to 1 Mux Verilog中的并发分配错误 - Concurrent assignment error in verilog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM