VHDL:是否可以用记录定义通用类型?
我正在尝试定义一个复杂类型(即由实部和虚部组成的类型),并试图找到一种使其通用的方法。
This my current static code:
type complex_vector is record
Re : signed(15 downto 0);
Im : signed(15 downto 0);
end record;
现在我想知道是否有一种方法可以使其通用,换句话说:
type complex_vector (Generic: Integer := WIDTH) is record
Re : signed(WIDTH downto 0);
Im : signed(WIDTH downto 0);
end record;
我尝试在谷歌上搜索解决方案并浏览我的书籍,但我找不到任何解决方案。真的没有吗?如果没有记录,就可以写出这样的东西:
type blaaa is array (NATURAL range <>) of STD_LOGIC;
感谢您的任何输入
编辑:
或者我可以做类似以下的事情吗?
type complex_primitives is (re, im);
type complex_vector is array (re to im) of signed(natural range <>);
但编译器抱怨..
I am trying to define a complex type (i.e, a type that consists of both a real and imaginary part) and am trying to find out a way to make it generic.
This my current static code:
type complex_vector is record
Re : signed(15 downto 0);
Im : signed(15 downto 0);
end record;
Now I wonder whether there is a way to make this generic, in in other word something like:
type complex_vector (Generic: Integer := WIDTH) is record
Re : signed(WIDTH downto 0);
Im : signed(WIDTH downto 0);
end record;
I tried to google for a solution as well as going through my books, but I cannot find any solution. Is there really none? Without records it is possible to wright something like this:
type blaaa is array (NATURAL range <>) of STD_LOGIC;
Thanks for any input
EDIT:
Or could I do something like the following?
type complex_primitives is (re, im);
type complex_vector is array (re to im) of signed(natural range <>);
The compiler complains though..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 VHDL-2008 中的合法语法:
重要说明 此示例使用具有无约束数组的记录。目前对 VHDL-2008 的支持还很不稳定。一些工具支持许多 VHDL-2008 功能,但许多工具尚未完全支持所有新功能。
要了解 VHDL-2008 和新功能,请参阅此演示文稿,这是一个很好的总结关于这个问题。
The following is legal syntax in VHDL-2008:
IMPORTANT NOTE This example makes use of records with unconstrained arrays. Support for VHDL-2008 at this point is hit-and-miss. Some tools support many of VHDL-2008 features, but many do not yet fully support all new features.
To read about VHDL-2008 and the new features, see this presentation which is a good summary on the subject.
在支持 VHDL-2008 之前(不要屏住呼吸!),有一个次优的忽悠...
在多个同名的包中创建您想要的不同大小的记录,然后选择在定义宽度的包中进行编译你想使用。
这种方法的严重限制是您在设计中只能支持单一形式的complex_vector,但从好的方面来说您不必担心工具支持!
向工具链中的每个供应商提出有关您的用例的支持/增强请求将很有用。被窃听的越多,VHDL-2008 就会越早得到支持。
Until VHDL-2008 is supported (don't hold your breath!) there are is a sub-optimal fudge...
Create the different sized records you want in multiple packages of the same name and then optionally compile in the package defining the width you want to use.
The severe limitation of this method is that you can only support a single form of complex_vector in the design, but on the plus side you don't have to worry about tool support!
It would be useful to raise a support/enhancement request with every vendor in your toolchain regarding your use case. The more they get bugged the sooner VHDL-2008 will be supported.