Verilog编译器错误

发布于 2024-12-12 11:27:43 字数 1046 浏览 0 评论 0原文

    module router (clock, ValidPacket0, ValidPacket1, ValidPacket2, ValidPacket3, PacketIn0, PacketIn1, PacketIn2, PacketIn3, PacketOut0, PacketOut1, PacketOut2, PacketOut3);

   input   clock;
   input   ValidPacket0, ValidPacket1, ValidPacket2, ValidPacket3;  
   input [7:0] PacketIn0, PacketIn1, PacketIn2, PacketIn3;
   output [7:0] PacketOut0,PacketOut1, PacketOut2, PacketOut3;

   reg [3:0]   bvp, vp;
   reg [1:0]   counter0, counter1, counter2, counter3;
   reg [2:0]   sel0, sel1, sel2, sel3;
   reg [3:0]   zero=0;
   reg [7:0]   addr0, addr1, addr2, addr3, out0, out1, out2, out3l;
   wire        np0, np1, np2, np3;
   wire [7:0]  PacketOut0, PacketOut1, Packetout2, Packetout3;

   always@(posedge clock)
     bvp[0]<=ValidPacket0;
   if (ValidPacket0 && !bvp[0]) vp[0]=1'b1;
   else vp[0]=0;

上面的代码给了我以下错误:

** Error: proj1a.v(23): near "[": syntax error, unexpected '[', expecting "IDENTIFIER" or "TYPE_IDENTIFIER" or '#' or '('
Line 23 is at the if statement.

有见解吗?

    module router (clock, ValidPacket0, ValidPacket1, ValidPacket2, ValidPacket3, PacketIn0, PacketIn1, PacketIn2, PacketIn3, PacketOut0, PacketOut1, PacketOut2, PacketOut3);

   input   clock;
   input   ValidPacket0, ValidPacket1, ValidPacket2, ValidPacket3;  
   input [7:0] PacketIn0, PacketIn1, PacketIn2, PacketIn3;
   output [7:0] PacketOut0,PacketOut1, PacketOut2, PacketOut3;

   reg [3:0]   bvp, vp;
   reg [1:0]   counter0, counter1, counter2, counter3;
   reg [2:0]   sel0, sel1, sel2, sel3;
   reg [3:0]   zero=0;
   reg [7:0]   addr0, addr1, addr2, addr3, out0, out1, out2, out3l;
   wire        np0, np1, np2, np3;
   wire [7:0]  PacketOut0, PacketOut1, Packetout2, Packetout3;

   always@(posedge clock)
     bvp[0]<=ValidPacket0;
   if (ValidPacket0 && !bvp[0]) vp[0]=1'b1;
   else vp[0]=0;

The above code gives me the following error:

** Error: proj1a.v(23): near "[": syntax error, unexpected '[', expecting "IDENTIFIER" or "TYPE_IDENTIFIER" or '#' or '('
Line 23 is at the if statement.

Any Insight?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶茶白久 2024-12-19 11:27:43

根据您想要执行的操作,您需要在 always @(posedge) 之后的语句周围添加 beginend 关键字 (并修复您的分配类型,请参阅如何解释 Verilog 中的阻塞与非阻塞分配?),或者您需要添加 总是@(*)之前if/else 引入组合逻辑。

Depending on what you're trying to do, you either need to add begin and end keywords around the statements after always @(posedge) (and fix your assignment type, see How to interpret blocking vs non blocking assignments in Verilog?), or you need to add always @(*) before the if/else to introduce combinational logic.

音栖息无 2024-12-19 11:27:43
   always@(posedge clock)
     bvp[0]<=ValidPacket0;
   if (ValidPacket0 && !bvp[0]) vp[0]=1'b1;
   else vp[0]=0;

这个“if”块表示生成块,因为它出现在模块级别。代码 vp[0]=1'b1; 是一个过程语句,仅允许在过程块内使用。编译器抱怨是因为它需要一个模块或 udp 实例,而该实例永远不会是后跟“[”的标识符。

   always@(posedge clock)
     bvp[0]<=ValidPacket0;
   if (ValidPacket0 && !bvp[0]) vp[0]=1'b1;
   else vp[0]=0;

This 'if' block indicates a generate block because it appears at the module level. The code vp[0]=1'b1; is a procedural statement which is only allowed inside a procedural block. The compiler is complaining because it is expecting a module or udp instance which would never be an identifier followed by a '['.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文