简体   繁体   English

verilog testbench组件使用generate实例化

[英]verilog testbench component instantiate using generate

I'm new to verilog and learning. 我是Verilog和学习的新手。 I have a testbench questions. 我有一个测试台问题。 Suppose in Verilog testbench I have 8 instances of a module. 假设在Verilog测试平台中,我有8个模块实例。 Is there a way to instantiate them in the testbench using a generate loop like a module can be declared in the HDL part of the code. 有没有一种方法可以使用生成循环在测试台中实例化它们,就像可以在代码的HDL部分中声明模块一样。 For example 例如

module my_test_bench;
reg one_r;
reg two_r;

wire one_w;
wire two_w;

genvar i;
generate
(for i = 0; i < 8; i=i+1)
begin
   DDR3_module uut[i]( .clk(), .rst(), );
end
endgenerate

initial begin
 ... test stimulus
end

end module

Thanks. 谢谢。

Yes, you can. 是的你可以。 Use the following syntax: 使用以下语法:

genvar i;
generate
  for (i = 0; i < 8; i = i + 1) begin
    DDR3_module uut (.clk(clk[i]), .rst(rst[i]));
  end
endgenerate

Note that you need vectors for the clk and rst signals for each instance, such as the following preceding declaration lines: 请注意,每个实例的clkrst信号都需要向量,例如以下前面的声明行:

wire [7:0] clk;
wire [7:0] rst;

If you want to drive those directly from within your initial block however, those need to be reg s instead of wire s. 但是,如果要直接从initial块中驱动它们,则需要使用reg而不是wire

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 生成动态组件 - Angular generate dynamic component 使用Vaadin TestBench打开和测试在Vaadin中以编程方式创建的子窗口 - Opening and testing a sub-window programmatically made in Vaadin, using Vaadin TestBench 您可以在将服务注入测试组件之前手动实例化服务吗? - Can you instantiate a service manually before it is injected into a tested component? 使用@BeforeAll 在 JUnit 中实例化一个 object 返回 null - Using @BeforeAll to instantiate an object in JUnit returns null Laravel管弦乐/测试台问题与Mockery - Laravel orchestral/testbench issues with Mockery 散列算法的测试平台过程是什么? - What is the testbench process for hashing algorithms? 在PHP中使用模拟对象,在实例化自己的对象的函数中 - Using mock objects in PHP inside functions that instantiate their own objects 使用INSTANTIATE_TEST_CASE_P针对同一灯具的不同实例 - Different instances for the same Fixture using INSTANTIATE_TEST_CASE_P 无法使用InjectMocks-Mockito实例化模拟对象 - Cannot instantiate mock objects using InjectMocks-Mockito 使用Ninject时如何正确实例化新控制器? - How do I correctly instantiate a new controller when using Ninject?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM