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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_192.vhd] - Blame information for rev 9

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 SN74LS192N: 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_192 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_192 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 CLK, CPU, CPD : std_logic;
32
    signal MR,  RS,  PL  : std_logic;
33
    signal Q, QB         : unsigned(3 downto 0);
34
 
35
    signal T1,  T2, T3, T4, T5,
36
           T6,  T7, T8, T9, T10,
37
           T11, T12       : std_logic;
38
    signal CX, CL, PR, CC : std_logic_vector(3 downto 0);
39
 
40
 
41
    begin
42
    P  <= JC(6 downto 3);
43
    MR <= not RS;       -- Active high
44
 
45
    process(CLK) is
46
    begin
47
        if rising_edge(CLK) then
48
            PL  <= nand_reduce(std_logic_vector(BC(4 downto 0))) after 10 ns, '1' after 80 ns;
49
            CPU <= BC(5);
50
            CPD <= not BC(5);
51
        elsif falling_edge(CLK) then    -- NB Inactive clock should be high
52
            CPU <= '1';
53
            CPD <= '1';
54
        end if;
55
    end process;
56
 
57
    -----------------------------------------------------------------------
58
    -- Standard testbench components
59
    -----------------------------------------------------------------------
60
    TB: TTLBench
61
    generic map(
62
        StimClk  => StimClk,
63
        CheckClk => CheckClk,
64
        Period   => Period,
65
        Finish   => Finish,
66
        SevLevel => SevLevel
67
   )
68
    port map(
69
        J    => JC,
70
        B    => BC,
71
        CLK  => CLK,
72
        RS   => RS,
73
        D    => D,
74
        E    => E
75
   );
76
 
77
    -----------------------------------------------------------------------
78
    -- Generate expected results (with zero delays)
79
    -----------------------------------------------------------------------
80
    T1    <= not (CPD);
81
    T2    <= not (CPU);
82
    T3    <= not (QB(1) and QB(2) and QB(3));
83
    T4    <= T1 and QB(0) and T3;
84
    T5    <= Q(0) and QB(3) and T2;
85
    T6    <= T3 and T1 and QB(0) and QB(1);
86
    T7    <= Q(0) and Q(1) and T2;
87
    T8    <= T1 and QB(0) and QB(1) and QB(2);
88
    T9    <= Q(0) and Q(3) and T2;
89
    T10   <= Q(0) and Q(1) and Q(2) and T2;
90
    T11   <= not (MR);
91
    T12   <= not (PL);
92
    CX(0) <= not (T1 or T2);
93
    CX(1) <= not (T4 or T5);
94
    CX(2) <= not (T6 or T7);
95
    CX(3) <= not (T8 or T9 or T10);
96
 
97
    G: for i in CX'range generate
98
    begin
99
        PR(i) <= not (P(i) and T12 and T11);
100
        CC(i) <= not (PR(i) and T12);
101
        CL(i) <= (T11 and CC(i));
102
 
103
        process(CX, PR, CL) is      -- A 'T' flipflop
104
        begin
105
            if CL(i) = '0' then
106
                Q(i) <= '0';
107
            elsif PR(i) = '0' then
108
                Q(i) <= '1';
109
            elsif rising_edge(CX(i)) then
110
                Q(i) <= not Q(i);
111
            end if;
112
        end process;
113
    end generate;
114
 
115
    QB <= not Q;
116
    D(3 downto 0) <= std_logic_vector(Q);
117
    D(4) <= not (Q(0) and Q(3) and T2);
118
    D(5) <= not (T1 and QB(0) and QB(1) and QB(2) and QB(3));
119
 
120
    -----------------------------------------------------------------------
121
    -- Device Under Test...                        
122
    -----------------------------------------------------------------------
123
    DUT: SN74LS192N
124
    port map(
125
        X_1  => P(1), --  P1
126
        X_2  => E(1), --  Q1
127
        X_3  => E(0), --  Q0
128
        X_4  => CPD,  --  CPD
129
        X_5  => CPU,  --  CPU
130
        X_6  => E(2), --  Q2
131
        X_7  => E(3), --  Q3
132
        X_8  => open, --  GND
133
        X_9  => P(3), --  P3
134
        X_10 => P(2), --  P2
135
        X_11 => PL,   --  PL\
136
        X_12 => E(4), --  TCU\
137
        X_13 => E(5), --  TCD\
138
        X_14 => MR,   --  MR
139
        X_15 => P(0), --  P0
140
        X_16 => open  --  Vcc
141
   );
142
end architecture Test;

powered by: WebSVN 2.1.0

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