我最近开始使用记录作为我的端口定义,特别是如果我想对属于某个接口的信号进行分组.但是,我在这里遇到的问题是我无法通过泛型传递给stl_logic_vector的宽度.所以我基本上想做的是以下内容:
library ieee;
use ieee.std_logic_1164.all;
use work.math_pkg.all;
package fifo_pkg is
type fifo_in_type is record
data_in : std_logic_vector(DATA_WIDTH_??- 1 downto 0);
rd : std_logic;
wr : std_logic;
end record;
type fifo_out_type is record
data_out : std_logic_vector(DATA_WIDTH_?? - 1 downto 0);
empty : std_logic;
full : std_logic;
end record;
component fifo is
generic
(
MIN_DEPTH : integer;
DATA_WIDTH : integer
);
port
(
clk : in std_logic;
res_n : in std_logic;
i : in fifo_in_type;
o : out fifo_out_type
);
end component fifo;
end fifo_pkg;
Run Code Online (Sandbox Code Playgroud)
所以理想的解决方案就是当我在记录中使用与我在实体中使用相同的通用时.(因此DATA_WIDTH与DATA_WIDTH_ ??相同).我知道这应该以某种方式与vhdl 2008一起工作,但是我的quartus II 11sp1不支持记录中的泛型.
是否有一种优雅的方式来实现可综合的那种"通用传递"?我知道可以在包中存储一个常量,但是我不能使用相同的fifo包来实例化具有不同宽度的几个fifo.
万分感谢,T
Mar*_*son 10
你可以在Quartus中使用类型泛型吗?
然后保留完全未指定的类型,以便您可以创建FIFO integers或任何其他数据类型:
package fifo_pkg is
generic (type element_type);
type fifo_in_type is record
data_in : element_type;
rd : std_logic;
wr : std_logic;
end record;
type fifo_out_type is record
data_out : element_type;
empty : std_logic;
full : std_logic;
end record;
component fifo is
generic
(
MIN_DEPTH : integer;
DATA_WIDTH : integer
);
port
(
clk : in std_logic;
res_n : in std_logic;
i : in fifo_in_type;
o : out fifo_out_type
);
end component fifo;
end fifo_pkg;
Run Code Online (Sandbox Code Playgroud)
然后当你想要使用它时:
package wide_fifo_pkg is new fifo_pkg
generic map (type => std_logic_vector(31 downto 0));
Run Code Online (Sandbox Code Playgroud)
然后你可以使用fifo_in_type和fifo_out_type:
signal i : fifo_in_type;
Run Code Online (Sandbox Code Playgroud)
如果设计单元中有多个FIFO,则可以创建包的多个版本,并使用包前缀来获得正确的类型:
package narrow_fifo_pkg is new fifo_pkg
generic map (type => std_logic_vector(3 downto 0));
signal i32 : wide_fifo_pkg.fifo_in_type;
signal i4 : narrow_fifo_pkg.fifo_in_type;
Run Code Online (Sandbox Code Playgroud)
另一个VHDL 2008选项:您可以拥有无约束的记录类型:
type fifo_in_type is record
data_in : std_logic_vector;
rd : std_logic;
wr : std_logic;
end record;
Run Code Online (Sandbox Code Playgroud)
然后你可以subtype为你的各种用途创建:
subtype fifo1_data_type is fifo_in_type(data_in(31 downto 0));
subtype fifo2_data_type is fifo_in_type(data_in(15 downto 0));
Run Code Online (Sandbox Code Playgroud)
不知道Quartus是否支持其中任何一个选项 - 请告诉我们!