首页 > 解决方案 > 如何解决verilog模块实例化错误

问题描述

我试图通过实例化另一个模块来连接两个模块的端口,但我遇到了这个错误:

错误 (10170):mlt.v(25) 附近文本的 Verilog HDL 语法错误:“[”;期待“)”。检查并修复紧接在指定关键字之前或处出现的任何语法错误。英特尔 FPGA 知识数据库包含许多文章,其中包含有关如何解决此错误的具体细节。访问 https://www.altera.com/support/support-resources/knowledge-base/search.html上的知识数据库 并搜索此特定错误消息编号。

我正在尝试将[3:0]dwith in1and连接起来in2(对于两个单独的实例)。

这是代码:

module mlt(in1,in2,out,clk,en);
input clk;
input en;
input  wire [3:0] in1,in2;
output reg [7:0] out;
reg [7:0]temp_o;
reg t1;
reg [3:0]temp_1;
reg [3:0]temp_2;
wire w1,w2,w3,w4,w5,w6,w7,w8;


d_latch u1 (.d[0](in1[0]),.d[1](in1[1]),.d[2](in1[2]),.d[3](in1[3]),

.clk(clk),

.q[0](w1),.q[1](w2),.q[2](w3),.q[3](w4));

d_latch u2 (.d[0](in2[0]),.d[1](in2[1]),.d[2](in2[2]),.d[3](in2[3]),

.clk(clk),

.q[0](w5),.q[1](w6),.q[2](w7),.q[3](w8));

//…………
//………

module d_latch (d,clk,q);
    input [3:0]d;
    input clk;
    output reg [3:0]q;

    always @ (posedge clk)
        q<=d;

endmodule

标签: verilogquartusintel-fpga

解决方案


您不能拆分端口。使用串联,并注意信号出现的顺序。

d_latch u1 (.d(in1),

.clk(clk),

.q({w4,w3,w2,w1}));

推荐阅读