多驱动网络:合成正常,模拟失败

Multidriven nets: Synthesis ok, Simulation fails

我对 System Verilog 有一个基本的理解问题。我正在研究处理器设计,其中一些总线系统应该在多个处理单元(System Verilog 模块)之间共享。使用仲裁器时,一次只有一个模块处于活动状态,驱动总线,而所有其他模块均为高阻抗。

我在综合期间摆脱了 Vivado 中的多驱动网络警告,不再有任何总线冲突,但模拟器发出警告,总线信号 'might' 是多驱动的。我做了一个很小的示例代码,我希望得到 'data' '11',当 'select' 是 '10'?

虽然在 Vivado 中仿真完全停止,但它可以与 Cadence 仿真器一起使用,但结果错误 - screenshot simulation

testbench.sv

`timescale 1ns / 1ps
module testbench_top();

logic [1:0] select;
logic [1:0] data;

top top_inst(.*);

initial
begin
  select = 0;
  #2 select = 1;
  #2 select = 2;
  #2 select = 0;;
end
  initial
    begin
      $monitor("t=%3d s=%b,d=%b\n",$time,select,data);
    end
endmodule

design.sv

`timescale 1ns / 1ps
module top
(
 input logic [1:0] select,
 output logic [1:0] data 
);

driver_1 driver_1_inst(.*);
driver_2 driver_2_inst(.*);

endmodule



module driver_1
(
 input logic [1:0] select,
 output logic [1:0] data 
);
always_comb
begin
  if (select == 2'b10)
        data = 2'b11;
    else
        data = 'z;
end
endmodule



module driver_2
(
 input logic [1:0] select,
 output logic [1:0] data 
);
always_comb
begin
  if (select == 2'b01)
        data = 2'b01;
    else
        data = 'z;
end
endmodule

我假设您希望 data 的值向 top 模块发出信号,该模块由驱动程序模块的两个输出驱动(例如,当一个驱动器 'z, 另一个得到公共汽车。

如果您将 top.data 信号声明为 output wire logic [1:0] data,就会发生这种情况。

IEEE 1800-2012 标准的 23.2.2.3 确定端口类型、数据类型和方向的规则 指出

For output ports, the default port kind depends on how the data type is specified: — If the data type is omitted or declared with the implicit_data_type syntax, the port kind shall default to a net of default net type. — If the data type is declared with the explicit data_type syntax, the port kind shall default to variable.

在您的情况下,第二个子句适用,因为您将 data 声明为 output logic[1:0],这意味着它被解释为变量而不是网络。变量的多个值未解析(在某些工具中也是非法的)。