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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_166.vhd] - Blame information for rev 6

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 SN74LS166N: 8-bit PISO 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_166 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_166 is
27
    signal CLK, ICLK  : std_logic;
28
    signal JC, BC     : unsigned(9 downto 0);           -- Test stimuli
29
    signal D,  E      : std_logic_vector(0 downto 0);   -- Expected & actual results
30
    signal PL, RS     : std_logic;
31
    signal CP1, CP2   : std_logic;
32
    signal P1         : std_logic_vector(7 downto 0) := (others => '0');
33
    signal SR         : std_logic_vector(7 downto 0);
34
 
35
    alias DS : std_logic is BC(1);
36
 
37
    begin
38
    P1   <= std_logic_vector(BC(9 downto 2));
39
    ICLK <= CP1 or CP2;
40
    D(0) <= SR(7);
41
 
42
    process(CLK, RS) is
43
        variable X : unsigned(5 downto 0);
44
    begin
45
        if    RS = '0' then
46
            CP1 <= '0';
47
            CP2 <= '0';
48
            PL  <= '0';
49
        elsif rising_edge(CLK) then
50
            CP1 <= BC(0);
51
            CP2 <= not BC(0);
52
            X := BC(X'range);
53
            case X is
54
                when "000000" => PL <= '0';
55
                when others   => PL <= '1';
56
            end case;
57
        elsif falling_edge(CLK) then
58
            CP1 <= '0';
59
            CP2 <= '0';
60
        end if;
61
    end process;
62
 
63
    -----------------------------------------------------------------------
64
    -- Standard testbench components
65
    -----------------------------------------------------------------------
66
    TB: TTLBench
67
    generic map(
68
        StimClk  => StimClk,
69
        CheckClk => CheckClk,
70
        Period   => Period,
71
        Finish   => Finish,
72
        SevLevel => SevLevel
73
    )
74
    port map(
75
        J    => JC,
76
        B    => BC,
77
        CLK  => CLK,
78
        RS   => RS,
79
        D    => D,
80
        E    => E
81
    );
82
 
83
    -----------------------------------------------------------------------
84
    -- Generate expected results (with zero delays)
85
    -----------------------------------------------------------------------
86
    process(ICLK, RS) is
87
    begin
88
        if RS = '0' then           -- Asynchronous reset
89
            SR <= (others => '0');
90
        elsif rising_edge(ICLK) then
91
            if PL = '0' then
92
                SR <= P1;
93
            else
94
                SR <= SR(6 downto 0) & DS;
95
            end if;
96
        end if;
97
    end process;
98
 
99
    -----------------------------------------------------------------------
100
    -- Device Under Test...                        
101
    -----------------------------------------------------------------------
102
    DUT: SN74LS166N
103
    port map(
104
    X_1  => DS,     -- DS
105
    X_2  => P1(0),  -- P0
106
    X_3  => P1(1),  -- P1
107
    X_4  => P1(2),  -- P2
108
    X_5  => P1(3),  -- P3
109
    X_6  => CP2,    -- CP2
110
    X_7  => CP1,    -- CP1
111
    X_8  => open,   -- GND
112
    X_9  => RS,     -- MR\
113
    X_10 => P1(4),  -- P4
114
    X_11 => P1(5),  -- P5
115
    X_12 => P1(6),  -- P6
116
    X_13 => E(0),   -- Q7
117
    X_14 => P1(7),  -- P7
118
    X_15 => PL,     -- PE\
119
    X_16 => open    -- Vcc
120
    );
121
end architecture Test;

powered by: WebSVN 2.1.0

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