与不同的输入接口SystemVerilog的阵 [英] Array of systemverilog interfaces with different inputs

查看:258
本文介绍了与不同的输入接口SystemVerilog的阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实例化的SystemVerilog的接口数组,其中每个数组元素使用不同的输入。

如果所有元素使用相同的输入,则该实例是简单的:

  x_if x_IF [`NUM_INTERFACES](CLK);

在这里,如果`NUM_INTERFACES 2 ,那么 CLK 输入变为既 x_IF [0] x_IF [1]

但是,如果我也有

 章CLK [`NUM_INTERFACES]

我怎么实例化 x_IF CLK [0] 输入到 x_IF [0] CLK [1] 输入到 x_IF [1] <? / p>

这是一个简单的例子;我期待着在某种循环(可能使用生成)为12接口的阵列来实现这一点。


解决方案

我会尽量避免使用分配语句,尤其是具有层次参考;它使code更难以阅读和维护。

您可能只是做

 章CLK [`NUM_INTERFACES]
x_if x_IF [`NUM_INTERFACES](CLK);

与实例阵列的特征是,如果一个信号的宽度被连接到一个端口的端口宽度的倍数,那么每个实例窗台得到的信号的一个片

请参阅 LRM 1800年至2012年部分的 28.3 0.6原始实例的连接列表适用于模块端口为好。

如果您使用的是生成循环,而不是实例的数组,那么我会做

 章CLK [`NUM_INTERFACES]生成
   对于(genvar我= 0; I&LT;`NUM_INTERFACES;我++)开始:循环
      x_if x_IF(CLK [I]);
   结束
endgenerate

I would like to instantiate an array of systemverilog interfaces where each array element uses a different input.

If all the elements use the same input, then the instantiation is simple:

x_if x_IF[`NUM_INTERFACES](clk);

Here, if `NUM_INTERFACES is 2, then the clk input goes to both x_IF[0] and x_IF[1].

But if I also have

reg clk[`NUM_INTERFACES];

how do I instantiate x_IF so that clk[0] is input to x_IF[0] and clk[1] is input to x_IF[1]?

This is a simple example; I am looking forward to implement this in some sort of loop (probably using generate) for an array of 12 interfaces.

解决方案

I would avoid using assign statements, especially with hierarchical references; it makes the code much more difficult to read and maintain.

You could have just done

reg clk[`NUM_INTERFACES];
x_if x_IF[`NUM_INTERFACES](clk);

A feature with arrays of instances is that if the width of a signal being connected to a port is a multiple of the port width, then each instance sill get a slice of the the signal.

See LRM 1800-2012 section 28.3.6 Primitive instance connection list that applies to module ports as well.

If you use a generate loop instead of an array of instances, then I would do

reg  clk[`NUM_INTERFACES];

generate
   for (genvar i=0; i<`NUM_INTERFACES; i++) begin :loop
      x_if x_IF(clk[i]);
   end
endgenerate

这篇关于与不同的输入接口SystemVerilog的阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆