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

Subversion Repositories ttl_library

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