描述: 我想写一个带有4个输入和3个输出的LUT(Look Up Table)的VHDL模块。我想我的3位输出是一个二进制数,等于输入中1的个数。VHDL LUT模块的设计
我的真值表:
ABCD | XYZ
0000 | 000
0001 | 001
0010 | 001
0011 | 010
0100 | 011
0101 | 010
0110 | 010
0111 | 011
1000 | 001
1001 | 010
1010 | 010
1011 | 011
1100 | 010
1101 | 011
1110 | 011
1111 | 100
我的VHDL代码:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity lut is
Port (
a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
x : out STD_LOGIC;
y : out STD_LOGIC;
z : out STD_LOGIC);
end lut;
architecture Behavioral of lut is
signal s0: STD_LOGIC;
signal s1: STD_LOGIC;
signal s2: STD_LOGIC;
signal s3: STD_LOGIC;
signal s4: STD_LOGIC;
signal s5: STD_LOGIC;
signal s6: STD_LOGIC;
signal s7: STD_LOGIC;
signal s8: STD_LOGIC;
signal s9: STD_LOGIC;
signal s10: STD_LOGIC;
signal s11: STD_LOGIC;
signal s12: STD_LOGIC;
signal s13: STD_LOGIC;
begin
----------MUX1-----------
process(a,b)
begin
if a='0'
then s0<=a;
else
s0<=b;
end if;
end process;
--------MUX2----------
process(a,b)
begin
if a='0'
then s1<=a;
else
s1<=b;
end if;
end process;
---------MUX3-----------
process(a,b)
begin
if a='0'
then s2<=a;
else
s2<=b;
end if;
end process;
---------MUX4-----------
process(a,b)
begin
if a='0'
then s3<=a;
else
s3<=b;
end if;
end process;
---------MUX5-----------
process(c,d,a)
begin
if a='0'
then s4<=c;
else
s4<=d;
end if;
end process;
---------MUX6-----------
process(c,d,a)
begin
if a='0'
then s5<=c;
else
s5<=d;
end if;
end process;
---------MUX7-----------
process(c,d,a)
begin
if a='0'
then s6<=c;
else
s6<=d;
end if;
end process;
---------MUX8-----------
process(c,d,a)
begin
if a='0'
then s7<=c;
else
s7<=d;
end if;
end process;
---------MUX9-----------
process(s0,s1,b)
begin
if b='0'
then s8<=s0;
else
s8<=s1;
end if;
end process;
---------MUX10-----------
process(s2,s3,b)
begin
if b='0'
then s9<=s2;
else
s9<=s3;
end if;
end process;
---------MUX11-----------
process(s4,s5,b)
begin
if b='0'
then s10<=s4;
else
s10<=s5;
end if;
end process;
---------MUX12-----------
process(s6,s7,b)
begin
if b='0'
then s11<=s6;
else
s11<=s7;
end if;
end process;
---------MUX13-----------
process(s8,s9,c)
begin
if c='0'
then s12<=s8;
x<= s8;
else
s12<=s9;
x<= s9;
end if;
end process;
---------MUX14-----------
process(s10,s11,c)
begin
if c='0'
then s13<=s10;
z<=s10;
else
s13<=s11;
z<=s11
end if;
end process;
---------MUX15-----------
process(s12,s13,d)
begin
if d='0'
then y<=s12;
else
y<=s13;
end if;
end process;
end Behavioral;
假设: 我需要总共15个多路复用器来模拟我需要的东西。他们将被级联到一个输出。 我将总共有15个过程如上所示。
问题:
1.)我对多路复用器ABCD有什么选择?
2.)我的建模是否正确?我会从所给的信息中获得我想要的吗?
3.)如果有更好的方法或者您有不同的想法,请您提供一个例子吗?
4.)我没有得到我的xyz输出,它的结束,但我做错了什么?
我试图提供尽可能多的研究。如果您有任何问题,我会立即回复
你的真值表有ABCD和XYZ。为什么你的VHDL代码没有X,Y或Z,而是有S1,F,G和H?另外,为什么你认为你需要在LUT实现中使用任何'inout'端口? – wjl
你的权利我没有改变,因为我正在玩选择。无论如何,我现在改变了。我不需要在港口。那么,我正在努力去做什么,或者我会怎么做呢? – user2444074