























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Professor: Patel; Class: Digital Systems Laboratory; Subject: Electrical and Computer Engr; University: University of Illinois - Urbana-Champaign; Term: Unknown 1989;
Typology: Lab Reports
1 / 31
This page cannot be seen from the preview
Don't miss anything!
























© Janak H Patel©^ Janak H. Patel
Department of Electrical and Computer EngineeringUniversity of Illinois at Urbana-Champaign
y^
p^ g
ENTITY
ARCHITECTURE
library IEEE;
--^ libraries needed for
use IEEE.std_logic_1164.all;
simple logic functions
entity mux isport (sel: in std_logic_vector(1 downto 0);
Din: in std logic vector (3 downto 0);Din: in std_logic_vector (3 downto 0);Dout: out std_logic); end entity mux;architecture my_mux_behavior of mux isbegin
--^ all comments are preceded by two dashes
Dout <= Din(3) when sel=“11” else
first evaluate this
Dout <
Din(3) when sel
else
first^ evaluate this
Din(2) when sel=“10” else
next evaluate this
Din(1) when sel=“01” else
then evaluate thish^
l^
h
Din(0) when sel=“00” else
then evaluate this
--^ if all fails then X
end architecture my mux behavior;
y_^
(“when
Din(3)
s0bar s1bar Din(2)Di^ (1)
Dout =
Din(1) Din(0)
Din(3)●
sel(1)●
sel(0) + Din(2)●
sel(1)●
s0bar + Din(1)●
s1bar●
sel(0) + ( )^
( ) Din(0)●
s1bar●
s0bar
sel(1)
sel(0)
architecture
structure
of^ mux
is
signal
s0bar,
s1bar;
std_logic;
--^ internal
signals
b^ ibegins0bar
<=^ not(sel(0)); s1bar <=^ not(sel(1)); Dout^ <=^ (Din(3)
and^ sel(1)
and^ sel(0))
or
(Din(2)
and^ sel(1)
and^ s0bar)
or
(Din(2)
and^ sel(1)
and^ s0bar)
or
(Din(1)
and^ s1bar and^ sel(0))
or
(Din(0)
and^ s1bar and^ s0bar);
end^ architecture
structure;
library IEEE;use IEEE.std_logic_1164.all;entity mux isport (sel: in std_logic_vector(1 downto 0);
Din: in std logic vector (3 downto 0);Din: in std_logic_vector (3 downto 0);Dout: out std_logic); end entity mux;architecture structure of mux issignal s0bar, s1bar; std_logic; -- internal signalsbegin
--^ following three are concurrent signal assignments (CSAs) g^
f^
g^
g^
g^
s0bar <= not(sel(0)); --
these are not executed sequentially
s1bar <= not(sel(1)); --
order of these CSAs is unimportant!
Dout <= (Din(3) and sel(1) and sel(0))or Dout <
(Din(3) and sel(1) and sel(0))or(Din(2) and sel(1) and s0bar) or(Din(1) and s1bar and sel(0)) or(Din(0) and s1bar and s0bar); (Din(0)
and s1bar and s0bar);
end architecture structure;
A in^
A_out
One-bit wideLogic Unit“compute” A_inB_in^
F_A_B compute
B_out
entity compute isPort ( F : in std logic vector(2 downto 0);Port ( F : in std_logic_vector(2 downto 0);
A_In, B_In : in std_logic;A_Out, B_Out : out std_logic;F A B
o t std logic) F_A_B : out std_logic); end entity compute;
architecture Behavioral of compute isbeginwith F selectF_A_B <= A_In and B_In when "000",
A In or B In when "001",_^
A_In xor B_In when "010",'1' when "011",A In nand B In when "100",A_In nand B_In when
A_In nor B_In when "101",A_In xnor B_In when "110",'0' when others;
must be included
'0' when others; --
must
be included
A_Out <= A_In;B_Out <= B_In;end architecture Behavioral;
entity up_down_counter is
t ( lk
bl^
d^
i^ td l
i
port (clk, enable, up_down : in std_logic;
asynch_clr: in std_logic;Q: out std logic vector(7 downto 0);Q: out std_logic_vector(7 downto 0); end entity;
enableup down
asynch_clr
p_ clk
architecture counter_behavior of up_dn_counter issignal count: std_logic_vector(7 downto 0);Begin
count
is an internal signal to this process
Begin
-- count
is^ an internal signal to this process
process(clk, asynch_reset)
--^ sensitivity list
beginif (asynch reset=‘1’) then count <= “00000000”;if (asynch_reset= 1 ) then count <=
elsif (rising_edge(clk)) then –
synchronous state transitions
if (enable=‘1’) thenif (up down=‘1’) then count <= count+”00000001”;if (up_down
1 ) then count <
count+ 00000001 ; else count <= count-”00000001”;
end if;end if;
-- ‘end if’
is not permitted here to match
‘elsif’
end if;end process;p Q <= count;end architecture counter_behavior; Note: We cannot use
since
Q^ is defined as output only
architecture counter_behavior of up_dn_counter isbeginprocess(clk, synch_reset)
--^ sensitivity list
beginif (rising_edge(clk) then
if(synch_reset=‘1’) then Q <= “00000000”;elsif (enable=‘1’) then
notice no
‘ e’^ in
‘ elsif
if (up down=‘1’) then Q <= Q + ’1’( p_
else Q <= Q - ’1’;
end if;-- “end if
”^ is not permitted here to match the
“elsif
end if
is^ not permitted here to match the
elsif
end if;end if; --
notice it is
‘ end if’
not^
‘endif’
end process;end process;end architecture counter_behavior;
entity reg_4 isPort (Shift_In, Load, Shift_En, Clk
: in std_logic;
D : in std_logic_vector(3 downto 0);Shift Out : out std logic;
_^ g
Data_Out : out std_logic_vector(3 downto 0); end entity reg_4;
4-Bit Register^ “reg 4
Shift_InLoad
Data_OutShift Out 4
reg_
LoadShift_EnClk
Shift_Out