在vhdl中定义记录方法
是否可以为 VHDL 中的记录定义类似 OOP 风格的实例方法以供 XST 识别?
对于记录类型矩形:
type rectangle is record
x : integer;
y : integer;
width : integer;
height : integer;
end record;
我想定义is_square、get_area等方法。
可以使用属性来完成吗?
Is is possible to define something like OOP-style instance method for a record in VHDL to be recognized by XST?
For a record type rectangle:
type rectangle is record
x : integer;
y : integer;
width : integer;
height : integer;
end record;
I'd like to define methods like is_square, get_area, etc.
Can it be done using attributes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,但您可以接近
protected
类型。这是一个示例,取自 VHDL 中受保护的共享变量:IEEE Std 1076a
我有不知道受保护类型的概念是否可以与 XST 综合。
No, but you can get close with
protected
types.Here's an example, taken from Protected Shared Variables in VHDL: IEEE Std 1076a
I have no idea if the concept of a protected type is synthesisable with XST though.
是否有某种原因您不想简单地定义一些函数以及自定义类型?
除了定义新函数(例如上面的 is_square)之外,您还可以覆盖现有函数(例如 +、< 等)(如果这对您的代码有意义)。
通常,您会将自定义类型和操作它们的函数包装到一个包中,然后在代码中使用。例如,请参阅标准 VHDL math_real 和 numeric_std 包。
Is there some reason you don't want to simply define a few functions along with your custom type(s)?
In addition to defining new functions (such as your is_square, above), you can override existing functions (such as +, <, etc) if that makes sense for your code.
Normally, you'd wrap your custom types and the functions to manipulate them into a package you'd then use in your code. See for example the standard VHDL math_real and numeric_std packages.