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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_322.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
-- December, 2016.  Perth, Australia                                 --
5
-- Compliance: VHDL 2008                                             --
6
-- Testbench for SN74LS322N: 8 bit ser/par register + sign extend    --
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_322 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           := 40 ns;
21
    Finish   : time           := 50 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_322 is
27
    signal J,  B     : unsigned(14 downto 0);        -- Test stimuli
28
    signal D,  E     : std_logic_vector(8 downto 0); -- Expected & actual results
29
    signal RS, CLK   : std_logic;
30
    signal OEI, DIN  : std_logic;
31
    signal DI, R, DT : std_logic_vector(7 downto 0);
32
 
33
    alias  RE  is J(8);
34
    alias  SP  is J(9);
35
    alias  D0  is J(10);
36
    alias  D1  is J(11);
37
    alias  OE  is J(12);
38
    alias  SE  is J(13);
39
    alias  S   is J(14);
40
 
41
begin
42
    OEI  <= (SP or RE) and not(OE);
43
    DIN  <= D0 when S = '0' else D1;
44
    DI   <= std_logic_vector(J(7 downto 0)) when OE  = '1' else (others => 'Z');
45
    E    <= "Z" & DI;
46
    DT   <= std_logic_vector(J(7 downto 0)) when OE  = '1' else
47
            R                               when OEI = '1' else
48
            (others => 'Z');
49
    D    <= R(0) & DT;
50
 
51
    -----------------------------------------------------------------------
52
    -- Standard testbench components
53
    -----------------------------------------------------------------------
54
    TB: TTLBench
55
    generic map(
56
        StimClk  => StimClk,
57
        CheckClk => CheckClk,
58
        Period   => Period,
59
        Finish   => Finish,
60
        SevLevel => SevLevel
61
    )
62
    port map(
63
        J   => J,
64
        B   => B,
65
        CLK => CLK,
66
        RS  => RS,
67
        D   => D,
68
        E   => E
69
    );
70
 
71
    -----------------------------------------------------------------------
72
    -- Generate expected results (with zero delays)
73
    -----------------------------------------------------------------------
74
    process(RS, CLK) is
75
        variable SEL : unsigned(2 downto 0);
76
    begin
77
        if RS = '0' then
78
            R <= (others => '0');
79
        elsif rising_edge(CLK) then
80
            SEL := RE & SP & SE;
81
            case SEL is
82
                when "011"   => R <= DIN  & R(7 downto 1);  -- Shift right
83
                when "010"   => R <= R(7) & R(7 downto 1);  -- Shift left
84
                when "00-"   => R <= DT;                    -- Parallel load
85
                when others  => null;                       -- Hold
86
            end case;
87
        end if;
88
    end process;
89
 
90
    -----------------------------------------------------------------------
91
    -- Device Under Test...                        
92
    -----------------------------------------------------------------------
93
    DUT: SN74LS322N
94
    port map(
95
        X_1  => RE,    -- RE\
96
        X_2  => SP,    -- S/P\
97
        X_3  => D0,    -- D0
98
        X_4  => DI(7), -- IO7
99
        X_5  => DI(5), -- IO5
100
        X_6  => DI(3), -- IO3
101
        X_7  => DI(1), -- IO1
102
        X_8  => OE,    -- OE\
103
        X_9  => RS,    -- MR\
104
        X_10 => open,  -- GND
105
        X_11 => CLK,   -- CP
106
        X_12 => E(8),  -- Q0
107
        X_13 => DI(0), -- IO0
108
        X_14 => DI(2), -- IO2
109
        X_15 => DI(4), -- IO4
110
        X_16 => DI(6), -- IO6
111
        X_17 => D1,    -- D1
112
        X_18 => SE,    -- SE\
113
        X_19 => S,     -- S
114
        X_20 => open   -- Vcc
115
    );
116
end architecture Test;

powered by: WebSVN 2.1.0

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