embeddedlover
Full Member level 5
- Joined
- Aug 10, 2007
- Messages
- 277
- Helped
- 46
- Reputation
- 92
- Reaction score
- 38
- Trophy points
- 1,308
- Activity points
- 3,155
Beginner to VHDL here....
I have written a simple 3:8 decoder using VHDL.
The following is the code...
entity dec3to8 is
Port ( A1 : in STD_LOGIC;
A2 : in STD_LOGIC;
A3 : in STD_LOGIC;
O1 : out STD_LOGIC;
O2 : out STD_LOGIC;
O3 : out STD_LOGIC;
O4 : out STD_LOGIC;
O5 : out STD_LOGIC;
O6 : out STD_LOGIC;
O7 : out STD_LOGIC;
O8 : out STD_LOGIC;
CTRL1 : in STD_LOGIC;
CTRL2 : in STD_LOGIC;
EN : in STD_LOGIC);
end dec3to8;
architecture Behavioral of dec3to8 is
begin
process(A1,A2,A3,CTRL1,CTRL2,EN)
begin
if ((CTRL1 = '1') or (CTRL2 = '1') or (EN = '0'))then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
else
if((A1 = '0') and (A2 = '0') and (A3 = '0')) then
O1 <= '1';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '0') and (A3 = '0')) then
O1 <= '0';O2 <= '1';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '1') and (A3 = '0')) then
O1 <= '0';O2 <= '0';
O3 <= '1';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '1') and (A3 = '0')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '1';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '0') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '1';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '0') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '1';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '1') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '1';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '1') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '1';
end if;
end if;
end process;
end Behavioral;
The problem i face when i run isim is that OUTPUT doesn't toggle even though i force INPUTS to some value. Please, help me where i am going wrong.
Attached is the isim output
I have written a simple 3:8 decoder using VHDL.
The following is the code...
entity dec3to8 is
Port ( A1 : in STD_LOGIC;
A2 : in STD_LOGIC;
A3 : in STD_LOGIC;
O1 : out STD_LOGIC;
O2 : out STD_LOGIC;
O3 : out STD_LOGIC;
O4 : out STD_LOGIC;
O5 : out STD_LOGIC;
O6 : out STD_LOGIC;
O7 : out STD_LOGIC;
O8 : out STD_LOGIC;
CTRL1 : in STD_LOGIC;
CTRL2 : in STD_LOGIC;
EN : in STD_LOGIC);
end dec3to8;
architecture Behavioral of dec3to8 is
begin
process(A1,A2,A3,CTRL1,CTRL2,EN)
begin
if ((CTRL1 = '1') or (CTRL2 = '1') or (EN = '0'))then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
else
if((A1 = '0') and (A2 = '0') and (A3 = '0')) then
O1 <= '1';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '0') and (A3 = '0')) then
O1 <= '0';O2 <= '1';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '1') and (A3 = '0')) then
O1 <= '0';O2 <= '0';
O3 <= '1';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '1') and (A3 = '0')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '1';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '0') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '1';O6 <= '0';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '0') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '1';
O7 <= '0';O8 <= '0';
end if;
if((A1 = '0') and (A2 = '1') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '1';O8 <= '0';
end if;
if((A1 = '1') and (A2 = '1') and (A3 = '1')) then
O1 <= '0';O2 <= '0';
O3 <= '0';O4 <= '0';
O5 <= '0';O6 <= '0';
O7 <= '0';O8 <= '1';
end if;
end if;
end process;
end Behavioral;
The problem i face when i run isim is that OUTPUT doesn't toggle even though i force INPUTS to some value. Please, help me where i am going wrong.
Attached is the isim output