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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_95.vhd] - Blame information for rev 11

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 SN74LS95N: 4-bit right/left 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_95 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           :=  50 ns;
21
    Finish   : time           :=  20 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_95 is
27
    signal RS               : std_logic;
28
    signal CLK              : std_logic;
29
    signal JC, BC           : unsigned(3 downto 0);           -- Test stimuli
30
    signal D,  E            : std_logic_vector(3 downto 0);   -- Expected & actual results
31
    signal P                : std_logic_vector(3 downto 0);
32
    signal CP1, CP2, PE, DS : std_logic := '1';
33
 
34
    begin
35
    P  <= std_logic_vector(JC(3 downto 0));
36
    DS <= JC(1);
37
 
38
    process(CLK, RS) is     -- Generate special clocks, etc.
39
        variable X   : unsigned(3 downto 0);
40
        variable IPE, IC1, IC2 : std_logic := '1';
41
    begin
42
        if rising_edge(CLK) then
43
            CP1 <= IC1;
44
            CP2 <= IC2;
45
            IC1 := '1';
46
            IC2 := '1';
47
            X   := BC(X'range);
48
            if (X = "1000") or (RS = '0') then
49
                IPE := '1';
50
                IC2 := '0';  -- Load
51
            else
52
                IPE := '0';
53
                IC1 := '0';  -- Shift
54
            end if;
55
        elsif falling_edge(CLK) then
56
            CP1 <= '1';
57
            CP2 <= '1';
58
            PE  <= IPE;
59
        end if;
60
    end process;
61
 
62
    -----------------------------------------------------------------------
63
    -- Standard testbench components
64
    -----------------------------------------------------------------------
65
    TB: TTLBench
66
    generic map(
67
        StimClk  => StimClk,
68
        CheckClk => CheckClk,
69
        Period   => Period,
70
        Finish   => Finish,
71
        SevLevel => SevLevel
72
    )
73
    port map(
74
        J    => JC,
75
        B    => BC,
76
        CLK  => CLK,
77
        RS   => RS,
78
        D    => D,
79
        E    => E
80
    );
81
 
82
    -----------------------------------------------------------------------
83
    -- Generate expected results (with zero delays)
84
    -----------------------------------------------------------------------
85
    process(CP1, CP2) is
86
    begin
87
        if    falling_edge(CP1) and PE = '0' then
88
            D <= D(2 downto 0) & DS;
89
        elsif falling_edge(CP2) and PE = '1' then
90
            D <= P;
91
        end if;
92
    end process;
93
 
94
    -----------------------------------------------------------------------
95
    -- Device Under Test...                        
96
    -----------------------------------------------------------------------
97
    DUT: SN74LS95N
98
    port map(
99
    X_1  => DS,  -- DS
100
    X_2  => P(0),  -- P0
101
    X_3  => P(1),  -- P1
102
    X_4  => P(2),  -- P2
103
    X_5  => P(3),  -- P3
104
    X_6  => PE,  -- PE
105
    X_7  => open,  -- GND
106
    X_8  => CP2,  -- CP2\
107
    X_9  => CP1,  -- CP1\
108
    X_10 => E(3),  -- Q3
109
    X_11 => E(2),  -- Q2
110
    X_12 => E(1),  -- Q1
111
    X_13 => E(0),  -- Q0
112
    X_14 => open   -- Vcc
113
    );
114
end architecture Test;

powered by: WebSVN 2.1.0

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