Description: I am trying to write vhdl module a LUT (Look Up Table) with 4 inputs and 3 outputs. I want my 3 bit output to be a binary number equal to the number of 1's in the input.
My Truth Table:
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
My VHDL code:
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;
Assumptions: I need a total of 15 multiplexers to model what I need. They will be cascaded to one output. I would have a total of 15 processes shown above.
Questions:
1.) What are my selects for the mux, ABCD?
2.) Am I modeling this the correct way? Will I achieve what I want from the info given?
3.) If there is a better way or you have a different Idea could you please provide an example?
4.) I am not getting my xyz output, its close but what am i doing wrong?
I have tried to provide as much research as possible. If you have any questions I will respond immediately
inout
ports in a LUT implementation? – wjl