Methods 在vhdl中定义记录的方法

Methods 在vhdl中定义记录的方法,methods,record,vhdl,xilinx,Methods,Record,Vhdl,Xilinx,可以为XST识别的VHDL记录定义类似OOP风格的实例方法吗 对于记录类型矩形: type rectangle is record x : integer; y : integer; width : integer; height : integer; end record; 我想定义一些方法,比如is_square,get_area,等等 可以使用属性来完成吗?否,但可以使用受保护的类型 下面是一个例子,摘自 但是,我不知道受保护类型的

可以为XST识别的VHDL记录定义类似OOP风格的实例方法吗

对于记录类型矩形

type rectangle is record
    x      : integer;
    y      : integer;
    width  : integer;
    height : integer;
end record; 
我想定义一些方法,比如is_squareget_area,等等


可以使用属性来完成吗?

否,但可以使用受保护的
类型

下面是一个例子,摘自


但是,我不知道受保护类型的概念是否可以通过XST合成。

有什么原因不想简单地定义一些函数和自定义类型


除了定义新函数(如上面的is_square)外,您还可以覆盖现有函数(如+),原因是这种方法看起来不像OOP。当调用my_std_logic_vector的长度内置属性而不是get_length(my_std_logic_vector)时,它看起来更自然嗯。它们看起来是面向对象的。你自己试过吗(用哪个合成器)?我还发现ISim不支持受保护的类型是的,它们是面向对象的。我在Modelsim的模拟中使用过它们。现在你要提到的是,我用ISim试过它们,是的,它扼杀了它们:(
type shared_counter is protected body
     variable count : integer := 0;
     procedure reset is
     begin
         count := 0;
     end procedure reset;
     procedure increment (by : integer := 1) is
     begin
         count := count + by;
     end procedure increment;
     impure function value return integer is
     begin
         return count;
     end function value;
end protected body shared_counter;