可以通過使用兩個四輸入的查找表與基於第五位的輸出之間的選擇器選擇表示一個五個輸入的查找表:
library ieee;
use ieee.std_logic_1164.all;
entity lut5 is
generic (
LUTVAL: std_logic_vector (0 to 31)
);
port (
a, b, c, d, e: in std_logic;
z : out std_logic
);
end entity lut5;
architecture behaviour of lut5 is
component mux2 is
port (
a: in std_logic;
b: in std_logic;
s: in std_logic;
y: out std_logic
);
end component;
component lut4 is
generic (
LUTVAL: std_logic_vector (0 to 15)
);
port (
a, b, c, d: in std_logic;
z: out std_logic
);
end component;
signal z0, z1: std_logic;
begin
LUT4_0:
lut4
generic map (
LUTVAL => LUTVAL(0 to 15)
)
port map (
a => a,
b => b,
c => c,
d => d,
z => z0
);
LUT4_1:
lut4
generic map (
LUTVAL => LUTVAL(16 to 31)
)
port map (
a => a,
b => b,
c => c,
d => d,
z => z1
);
MUX_2_1:
mux2
port map (
a => z0,
b => z1,
s => e,
y => z
);
end architecture;
的泛型是遞送的方法從設計模型的頂層查找表格內容。
它添加一個小的測試平臺:
library ieee;
use ieee.std_logic_1164.all;
entity lut5_tb is
end entity;
architecture foo of lut5_tb is
signal a, b, c, d, e: std_logic := '0';
signal z: std_logic;
constant LUTVAL: std_logic_vector (0 to 31) := x"A2201000";
signal index: natural;
begin
DUT:
entity work.lut5
generic map (
LUTVAL => LUTVAL
)
port map (
a => a,
b => b,
c => c,
d => d,
e => e,
z => z
);
STIMULI:
process
use ieee.numeric_std.all;
begin
for i in LUTVAL'RANGE loop
(e, d, c, b, a) <= to_unsigned(i,5);
index <= i;
wait for 10 ns;
end loop;
wait;
end process;
end architecture;
而且我們可以看到,它執行了五個輸入查找表:
您可以在Z輸出端在數位時間使用添加的索引信號並查找輸出重建32位LUTVAL(x「A2201000」)。
這裏是失蹤的點點滴滴:
library ieee;
use ieee.std_logic_1164.all;
entity mux2 is
port (
a: in std_logic;
b: in std_logic;
s: in std_logic;
y: out std_logic
);
end entity;
architecture foo of mux2 is
begin
y <= a when s = '0' else
b;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity lut4 is
generic (
LUTVAL: std_logic_vector (0 to 15)
);
port (
a, b, c, d: in std_logic;
z: out std_logic
);
end entity;
architecture foo of lut4 is
constant lut: std_logic_vector := LUTVAL;
use ieee.numeric_std.all;
begin
LOOKUP:
z <= lut(to_integer(unsigned'(d,c,b,a)));
end architecture;
我還有一個小問題。 如果我想用LUT5描述OR5的功能,我可以這樣做嗎? OR5_1: lut5 通用映射( LUTVAL => LUTVAL(0〜31) ) 端口映射(A || ||乙Ç|| d || E,Z); –
不可以。您想要更改LUT5循環表的內容,在我使用泛型顯示的示例中,如果索引的二進制值中存在一個,則可以有一個'1'。這意味着在lut5_tb'常量LUTVAL:std_logic_vector(0到31):= x「7FFFFFFF」;' – user1155120
中的每個索引都是0,但是我得到了你,但是我怎樣才能結構化描述任何使用LUT5的5輸入邏輯函數,我的意思是OR5或AND5,XOR5例如 –