Digital Systems - 4: Pere Pal' A - Alexis L Opez
Digital Systems - 4: Pere Pal' A - Alexis L Opez
February 2015
Shift Register
library ieee ; use ieee . std_ logic_1 164 . all ;
entity shift_reg is
port ( serial_in , clk , shift_ena
serial_out
end shift_reg ;
: in std_logic ;
: out std_logic );
ghdl -a
ghdl -a
ghdl -e
ghdl -r
gtkwave
sr.vhd
sr_tb.vhd
sr_tb
sr_tb --vcd=sr.vcd
sr.vcd
Counter
library ieee ; use ieee . std_ logic_1 164 . all ;
use ieee . numeric_std . all ;
entity counter is
port ( clk , reset : in std_logic ;
tc
: out std_logic );
end counter ;
architecture behav of counter is
signal q : unsigned (3 downto 0);
begin
process ( clk ) -- clock process
begin
if rising_edge ( clk ) then
if reset = 1 then
q <= " 0000 " ;
elsif q = 9 then
q <= " 0000 " ;
else
q <= q + 1;
end if ;
end if ;
end process ;
tc <= 1 when q = " 0000 " else 0 ;
end behav ;
...
begin
dut : my_counter port map ...
clk_process : process
begin
-- the clock process
clk <= 0 ;
wait for 5 ns ;
for i in 1 to 40 loop
clk <= not clk ;
wait for 5 ns ;
end loop ;
wait ;
end process clk_process ;
reset <= 1 , 0 after 10 ns ;
end behav ;
$
$
$
$
$
ghdl -a
ghdl -a
ghdl -e
ghdl -r
gtkwave
counter.vhd
counter_tb.vhd
counter_tb
counter_tb --vcd=counter.vcd
counter.vcd