Contador 3 bits - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

204


29
 
1
library IEEE;
2
use IEEE.std_logic_1164.all;
3
4
entity TB_cont_3_bits is
5
end;
6
7
8
9
architecture beh of TB_cont_3_bits is
10
11
    signal clk,rst : std_logic:='0';
12
    signal Q2,Q1,Q0: std_logic;
13
    component cont_3_bits is
14
        port(   clk: in std_logic;
15
            rst: in std_logic;
16
            Q2: out std_logic;
17
            Q1: out std_logic;
18
            Q0: out std_logic);
19
    end component;
20
21
begin
22
    DUT: cont_3_bits port map (clk,rst,Q2,Q1,Q0);
23
    clk <= not clk after 10 ns;
24
25
    rst <= '0','1' after 5 ns,'0' after 45 ns, '1' after 215 ns, '0' after 235 ns;
26
    
27
    
28
    end;
29
32
 
1
library IEEE;
2
use IEEE.std_logic_1164.all;
3
4
entity cont_3_bits is
5
    port(   clk: in std_logic;
6
        rst: in std_logic;
7
        Q2: out std_logic;
8
        Q1: out std_logic;
9
        Q0: out std_logic);
10
end;
11
12
architecture beh of cont_3_bits is
13
    signal D2,D1,D0 : std_logic;
14
    signal Q2_aux,Q1_aux,Q0_aux : std_logic;
15
    component FF_D is
16
        port(   D: in std_logic;
17
            clk: in std_logic;
18
            rst: in std_logic;
19
            Q: out std_logic);
20
    end component;
21
begin
22
    D2 <= (Q2_aux and not Q1_aux) or (not Q2_aux and Q1_aux and Q0_aux) or(Q2_aux and not Q0_aux);
23
    D1 <= Q1_aux xor Q0_aux;
24
    D0 <= not Q0_aux;
25
    FF2: FF_D port map (D2,clk,rst,Q2_aux);
26
    FF1: FF_D port map (D1,clk,rst,Q1_aux);
27
    FF0: FF_D port map (D0,clk,rst,Q0_aux);
28
    Q2<= Q2_aux;
29
    Q1<= Q1_aux;
30
    Q0<= Q0_aux;
31
end; 
32
77 views and 0 likes     
A short description will be helpful for you to remember your playground's details
 
100:0