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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_191.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 SN74LS191N: 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_191 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_191 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  : std_logic;
38
 
39
    signal Q, QB, X : unsigned(3 downto 0);
40
 
41
 
42
    begin
43
    P  <= JC(6 downto 3);
44
    CE <= BC(6);
45
 
46
    process(CP) is
47
    begin
48
        if rising_edge(CP) then
49
            PL <= RS and nand_reduce(std_logic_vector(BC(4 downto 0))) after 10 ns, '1' after 80 ns;
50
            UD <= BC(5);
51
        end if;
52
    end process;
53
 
54
    -----------------------------------------------------------------------
55
    -- Standard testbench components
56
    -----------------------------------------------------------------------
57
    TB: TTLBench
58
    generic map(
59
        StimClk  => StimClk,
60
        CheckClk => CheckClk,
61
        Period   => Period,
62
        Finish   => Finish,
63
        SevLevel => SevLevel
64
   )
65
    port map(
66
        J    => JC,
67
        B    => BC,
68
        CLK  => CP,
69
        RS   => RS,
70
        D    => D,
71
        E    => E
72
   );
73
 
74
    -----------------------------------------------------------------------
75
    -- Generate expected results (with zero delays)
76
    -----------------------------------------------------------------------
77
    T1   <= not (UD);
78
    T2   <= not (UD or CE);
79
    T3   <= not (CE or T1);
80
    T4   <= T1 and Q(0) and Q(1) and Q(2) and Q(3);
81
    T5   <= UD and QB(0) and QB(1) and QB(2) and QB(3);
82
    T6   <= T3 and QB(0);
83
    T7   <= Q(0) and T2;
84
    T8   <= T3 and QB(0) and QB(1);
85
    T9   <= Q(0) and Q(1) and T2;
86
    T10  <= T3 and QB(0) and QB(1) and QB(2);
87
    T11  <= Q(0) and Q(1) and Q(2) and T2;
88
    X(0) <= not (CE);
89
    X(1) <= T6 or T7;
90
    X(2) <= T8 or T9;
91
    X(3) <= T10 or T11;
92
    T12  <= not (CP);
93
    T13  <= not (CE);
94
    T14  <= T4 or T5;
95
 
96
    process(CP, PL) is
97
    begin
98
        if PL = '0' then
99
            Q <= P;
100
        elsif rising_edge(CP) and (CE = '0') then
101
            Q <= Q xor X;       -- 'T' flipflops
102
        end if;
103
    end process;
104
 
105
    QB  <= not Q;
106
 
107
    D(3 downto 0) <= std_logic_vector(Q(3 downto 0));
108
    D(4) <=  T14;
109
    D(5) <= not (T12 and T13 and T14);
110
 
111
    -----------------------------------------------------------------------
112
    -- Device Under Test...                        
113
    -----------------------------------------------------------------------
114
    DUT: SN74LS191N
115
    port map(
116
        X_1  => P(1), --  P1
117
        X_2  => E(1), --  Q1
118
        X_3  => E(0), --  Q0
119
        X_4  => CE,   --  CE\
120
        X_5  => UD,   --  U\/D
121
        X_6  => E(2), --  Q2
122
        X_7  => E(3), --  Q3
123
        X_8  => open, --  GND
124
        X_9  => P(3), --  P3
125
        X_10 => P(2), --  P2
126
        X_11 => PL,   --  PL\
127
        X_12 => E(4), --  TC
128
        X_13 => E(5), --  RC\
129
        X_14 => CP,   --  CP
130
        X_15 => P(0), --  P0
131
        X_16 => open  --  Vcc
132
   );
133
end architecture Test;

powered by: WebSVN 2.1.0

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