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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_196.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 SN74LS196N: Presettable 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_196 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '0';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           := 120 ns;
21
    Finish   : time           :=  20 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_196 is
27
    signal RS,  PL     : std_logic;
28
    signal CLK, C0, C1 : std_logic;
29
    signal J,  B       : unsigned(3 downto 0);          -- Test stimuli
30
    signal D,  E,  R   : std_logic_vector(3 downto 0);  -- Expected & actual results
31
 
32
    begin
33
    C0 <= CLK;
34
    R  <= std_logic_vector(J);
35
    C1 <= D(0);
36
 
37
    -----------------------------------------------------------------------
38
    -- Standard testbench components
39
    -----------------------------------------------------------------------
40
    TB: TTLBench
41
    generic map(
42
        StimClk  => StimClk,
43
        CheckClk => CheckClk,
44
        Period   => Period,
45
        Finish   => Finish,
46
        SevLevel => SevLevel
47
    )
48
    port map(
49
        J    => J,
50
        B    => B,
51
        CLK  => CLK,
52
        RS   => RS,
53
        D    => D,
54
        E    => E
55
    );
56
 
57
    -----------------------------------------------------------------------
58
    -- Generate irregular LD signal
59
    -----------------------------------------------------------------------
60
    process(RS, CLK) is
61
        variable N : natural;
62
    begin
63
        if RS = '0' then
64
            N  := 1;
65
            PL <= '1';
66
        elsif rising_edge(CLK) then
67
            if N >= 23 then
68
                N := 1;
69
                PL <= '0', '1' after 30 ns;
70
            else
71
                N := N + 1;
72
            end if;
73
        end if;
74
    end process;
75
 
76
    -----------------------------------------------------------------------
77
    -- Generate expected results (with zero delays)
78
    -----------------------------------------------------------------------
79
 
80
    process(C0, PL, RS, R) is
81
        variable Q0 : std_logic;
82
    begin
83
        if    RS = '0' then
84
            Q0 := '0';
85
        elsif PL = '0' then
86
            Q0 := R(0);
87
        elsif falling_edge(C0) then
88
            Q0 := not Q0;
89
        end if;
90
        D(0) <= Q0;
91
    end process;
92
 
93
    process(C1, PL, RS, R) is
94
        variable Q31 : unsigned(2 downto 0);
95
    begin
96
        if    RS = '0' then
97
            Q31 := (others => '0');
98
        elsif PL = '0' then
99
            Q31 := unsigned(R(3 downto 1));
100
        elsif falling_edge(C1) then
101
            case TTL_to_integer(Q31) is
102
                when 4 to 7 => Q31 := Q31 - 4;
103
                when others => Q31 := Q31 + 1;
104
            end case;
105
        end if;
106
        D(3 downto 1) <= std_logic_vector(Q31);
107
    end process;
108
 
109
    -----------------------------------------------------------------------
110
    -- Device Under Test...                        
111
    -----------------------------------------------------------------------
112
    DUT: SN74LS196N
113
    port map(
114
        X_1  => PL,   -- PL\
115
        X_2  => E(2), -- Q2
116
        X_3  => R(2), -- P2
117
        X_4  => R(0), -- P0
118
        X_5  => E(0), -- Q0
119
        X_6  => C1,   -- CP1\
120
        X_7  => open, -- GND
121
        X_8  => C0,   -- CP0\
122
        X_9  => E(1), -- Q1
123
        X_10 => R(1), -- P1
124
        X_11 => R(3), -- P3
125
        X_12 => E(3), -- Q3
126
        X_13 => RS,   -- MR\
127
        X_14 => open  -- Vcc
128
    );
129
 
130
end architecture Test;

powered by: WebSVN 2.1.0

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