错误:模块边界之外的意外模块实例

问题描述 投票:0回答:1

我正在尝试创建一个32位计数器,该计数器将32个输入分为4组,每组8个,然后将这4组输入到多路复用器中。这就是我所拥有的:

modules Bit32 ( clk, reset, load, D, Q);
input clk, reset, load, D, Q;
input [7:0] D;
input [15:8] D;
input [23:16] D;
input [31:24] D;
output [7:0] Q;
output [15:8] Q;
output [23:16] Q;
output [31:24] Q;
reg [7:0] Q;
reg [15:8] Q;
reg [23:16] Q;
reg [31:24] Q;
always @(posedge clk)
    if(reset) Q <=32'b0; else 
    if (load) Q <=D;
    else Q <=Q + 32'b1
endmodule

我收到这些错误:

错误:HDLCompiler:944-“ C:/用户/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v”第1行:超出模块边界的意外模块实例。

警告:HDLCompiler:1591-“ C:/用户/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v”第1行:在verilog 95 / 2K模式下不允许进行根范围声明]

ERROR:HDLCompiler:806-“ C:/用户/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v”第2行:“输入”附近的语法错误。

我的复用器:

module CounterMux(select, D, Q);
input[1:0] select;
input[3:0] D:
output Q;

wire Q;
wire [1:0] select;
wire [3:0] D;

assign Q=D[select];

endmodule
verilog hdl
1个回答
0
投票

Bit32.v文件的错误和警告归因于输入错误:关键字是module,而不是modules(请注意“ s”)。更改:

modules Bit32 ( clk, reset, load, D, Q);

至:

module Bit32 ( clk, reset, load, D, Q);

编译器认为您正在放置名为modules的模块的实例。进行更改会摆脱您显示的消息。


但是Bit32.v文件中还有其他错误。您不应声明多个具有相同名称的端口。您分别声明了DQ 5次,但必须分别声明一次。例如:

module Bit32 ( clk, reset, load, D, Q);
input clk, reset, load;
input [31:0] D;
output [31:0] Q;
reg [31:0] Q;
always @(posedge clk)
    if(reset) Q <=32'b0; else 
    if (load) Q <=D;
    else Q <=Q + 32'b1;
endmodule

我也遇到了编译错误,因为else Q <=Q + 32'b1之后缺少分号。我相信IEEE标准在每个声明之后都需要使用分号。尽管某些编译器显然不需要它,但最好具有可移植性。

© www.soinside.com 2019 - 2024. All rights reserved.