使用EDAPlayground的Verilog Testbench错误多路复用4x1

问题描述

我正在使用EDAPlayground在Verilog中执行Multiplex 4x1,但是我仍然遇到testbench错误,我也不知道为什么。

这是一个错误

ERROR VCP2000“语法错误。意外的令牌:和[_AND]。” “ design.sv” 26 6

module mux4x1(
  input x1,x2,x3,x4,s0,s1,output f);
  wire s0_inv,out_x1,out_x2;
  wire s1_inv,out_x3,out_x4;
  wire out_mux1,out_mux2;
  wire out_mux3,out_mux4;
  
// mux2x1_1
  not (s1_inv,s1);
  and (out_x1,s1_inv,x1);
  and (out_x2,x2);
  or (out_mux1,out_x2);

// mux2x1_2
  not (s1_inv,s1);
  and (out_x3,x3);
  and (out_x4,x4);
  or (out_mux2,out_x4);
  
// mux4x1
  not (s0_inv,s0)
  and (out_mux3,s0_inv,out_mux1);
  and (out_mux4,out_mux2);
  or (f,out_mux3,out_mux4);
endmodule 

链接https://www.edaplayground.com/x/bkNc

解决方法

当我尝试仅编译您的设计代码时,出现此错误:

  and (out_mux3,s0_inv,out_mux1);
    |
xmvlog: *E,EXPSMC : expecting a semicolon (';') [7.1(IEEE)].

这种类型的错误通常是由报告行的上方行引起的:

  not (s0_inv,s0)

只需添加分号:

  not (s0_inv,s0);

EDAplayground提供了几种不同的模拟器,有些提供了比其他更有用的错误消息。您已将其设置为Aldec;例如,切换到Cadence,以查看其他错误消息。