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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_94.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 SN74LS94N: 4-bit shift register                     --
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_94 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           := 100 ns;
21
    Finish   : time           :=  20 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_94 is
27
    signal RS, RSH    : std_logic;
28
    signal CLK        : std_logic;
29
    signal JC, BC     : unsigned(7 downto 0);           -- Test stimuli
30
    signal D,  E      : std_logic_vector(0 downto 0);   -- Expected & actual results
31
    signal L1, L2     : std_logic;
32
    signal P1, P2, LR : std_logic_vector(3 downto 0);
33
 
34
    alias DS is BC(0);
35
 
36
    begin
37
    RSH <= not RS;
38
    P1  <= std_logic_vector(BC(3 downto 0));
39
    P2  <= std_logic_vector(BC(7 downto 4));
40
 
41
    process(RS, CLK) is
42
        variable X : unsigned(5 downto 0);
43
    begin
44
        if RSH = '1' then
45
            L1 <= '0';
46
            L2 <= '0';
47
        elsif falling_edge(CLK) then    -- Inactive clock edge
48
            X := BC(5 downto 0);
49
            case X is
50
                when "010101" => L1 <= '1';
51
                when "101010" => L2 <= '1';
52
                when others   => L1 <= '0'; L2 <= '0';
53
            end case;
54
        end if;
55
    end process;
56
 
57
    -----------------------------------------------------------------------
58
    -- Standard testbench components
59
    -----------------------------------------------------------------------
60
    TB: TTLBench
61
    generic map(
62
        StimClk  => StimClk,
63
        CheckClk => CheckClk,
64
        Period   => Period,
65
        Finish   => Finish,
66
        SevLevel => SevLevel
67
    )
68
    port map(
69
        J    => JC,
70
        B    => BC,
71
        CLK  => CLK,
72
        RS   => RS,
73
        D    => D,
74
        E    => E
75
    );
76
 
77
    -----------------------------------------------------------------------
78
    -- Generate expected results (with zero delays)
79
    -----------------------------------------------------------------------
80
    process(CLK, RS, L1, L2) is
81
        variable SR : std_logic_vector(3 downto 0);
82
    begin
83
        if    RS = '0' then
84
            SR := (others => '0');
85
        elsif (L1 or L2) = '1' then           -- Asynchronous load
86
            for i in SR'range loop
87
                SR(i) := SR(i) or (L1 and P1(i)) or (L2 and P2(i));
88
            end loop;
89
        elsif rising_edge(CLK) then
90
            SR := SR(2 downto 0) & DS;
91
        end if;
92
            D(0) <= SR(3);
93
            LR   <= SR;                 -- Visibility
94
    end process;
95
 
96
    -----------------------------------------------------------------------
97
    -- Device Under Test...                        
98
    -----------------------------------------------------------------------
99
    DUT: SN74LS94N
100
    port map(
101
    X_1  => P1(0),  -- P1A
102
    X_2  => P1(1),  -- P1B
103
    X_3  => P1(2),  -- P1C
104
    X_4  => P1(3),  -- P1D
105
    X_5  => open,   -- Vcc
106
    X_6  => L1,     -- PL1
107
    X_7  => DS,     -- DS
108
    X_8  => CLK,    -- CP
109
    X_9  => E(0),   -- QD
110
    X_10 => RSH,    -- CL
111
    X_11 => P2(3),  -- P2D
112
    X_12 => open,   -- GND
113
    X_13 => P2(2),  -- P2C
114
    X_14 => P2(1),  -- P2B
115
    X_15 => L2,     -- PL2
116
    X_16 => P2(0)   -- P2A
117
    );
118
end architecture Test;

powered by: WebSVN 2.1.0

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