OpenCores
URL https://opencores.org/ocsvn/ttl_library/ttl_library/trunk

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_190.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 david237
-----------------------------------------------------------------------
2
-- Bipolar TTL models (VHDL)                                         --
3
-- David R Brooks                                                    --
4
-- August, 2016.  Perth, Australia                                   --
5
-- Compliance: VHDL 2008                                             --
6
-- Testbench for SN74LS190N: Up/down decade counter                  --
7
-----------------------------------------------------------------------
8
 
9
library ieee;
10
    use ieee.std_logic_1164.all;
11
    use ieee.std_logic_misc.all;
12
    use ieee.numeric_std.all;
13
    use work.LSTTL.all;
14
    use work.TTLPrivate.all;
15
 
16
entity Testbench_190 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           := 100 ns;
21
    Finish   : time           :=  15 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_190 is
27
    signal JC, BC : unsigned(6 downto 0);           -- Test stimuli
28
    signal D, E   : std_logic_vector(5 downto 0);   -- Expected & actual results
29
 
30
    signal P      : unsigned(3 downto 0);
31
    signal CP     : std_logic;
32
    signal RS, PL : std_logic;
33
    signal CE, UD : std_logic;
34
 
35
    signal T1,  T2,  T3,  T4,  T5,
36
           T6,  T7,  T8,  T9,  T10,
37
           T11, T12, T13, T14, T15,
38
           T16      : std_logic;
39
 
40
    signal Q, QB, X : unsigned(3 downto 0);
41
 
42
 
43
    begin
44
    P  <= JC(6 downto 3);
45
    CE <= BC(6);
46
 
47
    process(CP) is
48
    begin
49
        if rising_edge(CP) then
50
            PL <= RS and nand_reduce(std_logic_vector(BC(4 downto 0))) after 10 ns, '1' after 80 ns;
51
            UD <= BC(5);
52
        end if;
53
    end process;
54
 
55
    -----------------------------------------------------------------------
56
    -- Standard testbench components
57
    -----------------------------------------------------------------------
58
    TB: TTLBench
59
    generic map(
60
        StimClk  => StimClk,
61
        CheckClk => CheckClk,
62
        Period   => Period,
63
        Finish   => Finish,
64
        SevLevel => SevLevel
65
   )
66
    port map(
67
        J    => JC,
68
        B    => BC,
69
        CLK  => CP,
70
        RS   => RS,
71
        D    => D,
72
        E    => E
73
   );
74
 
75
    -----------------------------------------------------------------------
76
    -- Generate expected results (with zero delays)
77
    -----------------------------------------------------------------------
78
    T1   <= not (UD);
79
    T2   <= not (UD or CE);
80
    T3   <= not (CE or T1);
81
    T4   <= not (QB(1) and QB(2) and QB(3));
82
    T5   <= T3 and QB(0) and T4;
83
    T6   <= Q(0) and QB(3) and T2;
84
    T7   <= T4 and T3 and QB(0) and QB(1);
85
    T8   <= Q(0) and Q(1) and T2;
86
    T9   <= T3 and QB(0) and QB(1) and QB(2);
87
    T10  <= Q(0) and Q(3) and T2;
88
    T11  <= Q(0) and Q(1) and Q(2) and T2;
89
    X(0) <= not (CE);
90
    X(1) <= T5 or T6;
91
    X(2) <= T7 or T8;
92
    X(3) <= T9 or T10 or T11;
93
 
94
    process(CP, PL) is
95
    begin
96
        if PL = '0' then
97
            Q <= P;
98
        elsif rising_edge(CP) and (CE = '0') then
99
            Q <= Q xor X;       -- 'T' flipflops
100
        end if;
101
    end process;
102
 
103
    QB  <= not Q;
104
 
105
    T15  <= (T1 and Q(0) and Q(3));   -- True for count = 9, 11, 13, 15
106
    T16  <= (UD and QB(0) and QB(1) and QB(2) and QB(3));
107
    T12  <= (T15 or T16);
108
 
109
    T13  <= not (CP);
110
    T14  <= not (CE);
111
 
112
    D(3 downto 0) <= std_logic_vector(Q);
113
    D(4) <=  T12;
114
    D(5) <= not (T13 and T14 and T12);
115
 
116
    -----------------------------------------------------------------------
117
    -- Device Under Test...                        
118
    -----------------------------------------------------------------------
119
    DUT: SN74LS190N
120
    port map(
121
        X_1  => P(1), --  P1
122
        X_2  => E(1), --  Q1
123
        X_3  => E(0), --  Q0
124
        X_4  => CE,   --  CE\
125
        X_5  => UD,   --  U\/D
126
        X_6  => E(2), --  Q2
127
        X_7  => E(3), --  Q3
128
        X_8  => open, --  GND
129
        X_9  => P(3), --  P3
130
        X_10 => P(2), --  P2
131
        X_11 => PL,   --  PL\
132
        X_12 => E(4), --  TC
133
        X_13 => E(5), --  RC\
134
        X_14 => CP,   --  CP
135
        X_15 => P(0), --  P0
136
        X_16 => open  --  Vcc
137
   );
138
end architecture Test;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.