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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_68.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
-- June, 2016.  Perth, Australia                                     --
5
-- Compliance: VHDL 2008                                             --
6
-- Testbench for SN74LS68N: Dual 4-bit 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_68 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      :=  '0';
19
    CheckClk : std_logic      :=  '0';
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_68 is
27
    signal RS, C0 : std_logic;
28
    signal CLK    : std_logic;
29
    signal J,  B  : unsigned(1 downto 0);           -- Test stimuli
30
    signal D,  E  : std_logic_vector(7 downto 0);   -- Expected & actual results
31
 
32
    begin
33
    -----------------------------------------------------------------------
34
    -- Standard testbench components
35
    -----------------------------------------------------------------------
36
    TB: TTLBench
37
    generic map(
38
        StimClk  => StimClk,
39
        CheckClk => CheckClk,
40
        Period   => Period,
41
        Finish   => Finish,
42
        SevLevel => SevLevel
43
    )
44
    port map(
45
        J   => J,
46
        B   => B,
47
        CLK => CLK,
48
        RS  => RS,
49
        D   => D,
50
        E   => E
51
    );
52
 
53
    -----------------------------------------------------------------------
54
    -- Generate expected results (with zero delays)
55
    -----------------------------------------------------------------------
56
 
57
    -- Low bits: the 2+5 counter
58
    process(B, RS) is
59
        variable Q0 : std_logic;
60
    begin
61
        if    RS = '0' then
62
            Q0 := '0';
63
        elsif falling_edge(B(0)) then
64
            Q0 := not Q0;
65
        end if;
66
        D(0) <= Q0;
67
    end process;
68
 
69
    process(D, RS) is
70
        variable Q31 : unsigned(2 downto 0);
71
    begin
72
        if    RS = '0' then
73
            Q31 := (others => '0');
74
        elsif falling_edge(D(0)) then
75
            case TTL_to_integer(Q31) is
76
                when 4 to 7 => Q31 := Q31 - 4;
77
                when others => Q31 := Q31 + 1;
78
            end case;
79
        end if;
80
        D(3 downto 1) <= std_logic_vector(Q31);
81
    end process;
82
 
83
    -- High bits: straight BCD counter
84
    process(B, RS) is
85
        variable Q30 : unsigned(3 downto 0);
86
    begin
87
        if    RS = '0' then
88
            Q30 := (others => '0');
89
        elsif falling_edge(B(1)) then
90
            case TTL_to_integer(Q30) is
91
                when      9 => Q30 := "0000";
92
                when     11 => Q30 := "0010";
93
                when     13 => Q30 := "0100";
94
                when     15 => Q30 := "0110";
95
                when others => Q30 := Q30 + 1;
96
            end case;
97
        end if;
98
        D(7 downto 4) <= std_logic_vector(Q30);
99
    end process;
100
 
101
    -----------------------------------------------------------------------
102
    -- Device Under Test...                        
103
    -----------------------------------------------------------------------
104
    DUT: SN74LS68N
105
    port map(
106
    X_1  => B(0),  -- 1CLKA
107
    X_2  => E(1),  -- 1QB
108
    X_3  => E(3),  -- 1QD
109
    X_4  => RS,    -- \1CLR
110
    X_5  => E(6),  -- 2QC
111
                   -- 
112
    X_7  => E(4),  -- 2QA
113
    X_8  => open,  -- GND
114
    X_9  => B(1),  -- 2CLK
115
    X_10 => E(5),  -- 2QB
116
    X_11 => RS,    -- \2CLR
117
    X_12 => E(7),  -- 2QD
118
    X_13 => E(2),  -- 1QC
119
    X_14 => C0,    -- 1QA
120
    X_15 => C0,    -- 1CLKB
121
    X_16 => open   -- Vcc
122
);
123
    E(0) <= C0;
124
 
125
end architecture Test;

powered by: WebSVN 2.1.0

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