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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_193.vhd] - Blame information for rev 3

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

powered by: WebSVN 2.1.0

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