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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_393.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
-- June, 2016.  Perth, Australia                                     --
5
-- Compliance: VHDL 2008                                             --
6
-- Testbench for SN74LS393N: Dual 4-bit 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_393 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_393 is
27
    signal RS, NRS : 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
    RS <= not NRS;
34
 
35
    -----------------------------------------------------------------------
36
    -- Standard testbench components
37
    -----------------------------------------------------------------------
38
    TB: TTLBench
39
    generic map(
40
        StimClk  => StimClk,
41
        CheckClk => CheckClk,
42
        Period   => Period,
43
        Finish   => Finish,
44
        SevLevel => SevLevel
45
    )
46
    port map(
47
        J    => J,
48
        B    => B,
49
        CLK  => CLK,
50
        RS   => NRS,
51
        D    => D,
52
        E    => E
53
    );
54
 
55
    -----------------------------------------------------------------------
56
    -- Generate expected results (with zero delays)
57
    -----------------------------------------------------------------------
58
 
59
    CA: process(B, RS) is
60
        variable NA : natural;
61
    begin
62
        if    RS = '1' then
63
            NA := 0;
64
        elsif falling_edge(B(0)) then
65
            case NA is
66
                when 15     => NA := 0;
67
                when others => NA := NA + 1;
68
            end case;
69
        end if;
70
        D(3 downto 0) <= std_logic_vector(to_unsigned(NA, 4));
71
    end process;
72
 
73
    CB: process(B, RS) is
74
        variable NB : natural;
75
    begin
76
        if    RS = '1' then
77
            NB := 0;
78
        elsif falling_edge(B(1)) then
79
            case NB is
80
                when 15     => NB := 0;
81
                when others => NB := NB + 1;
82
            end case;
83
        end if;
84
        D(7 downto 4) <= std_logic_vector(to_unsigned(NB, 4));
85
    end process;
86
 
87
    -----------------------------------------------------------------------
88
    -- Device Under Test...                        
89
    -----------------------------------------------------------------------
90
    DUT: SN74LS393N
91
    port map(
92
    X_1  => B(0),  -- CPA\
93
    X_2  => RS,    -- MRA
94
    X_3  => E(0),  -- Q0A
95
    X_4  => E(1),  -- Q1A
96
    X_5  => E(2),  -- Q2A
97
    X_6  => E(3),  -- Q3A
98
    X_7  => open,  -- GND
99
    X_8  => E(7),  -- Q3B
100
    X_9  => E(6),  -- Q2B
101
    X_10 => E(5),  -- Q1B
102
    X_11 => E(4),  -- Q0B
103
    X_12 => RS,    -- MRB
104
    X_13 => B(1),  -- CPB\
105
    X_14 => open   -- Vcc
106
);
107
 
108
end architecture Test;

powered by: WebSVN 2.1.0

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