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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_279.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 SN74LS279N: 4-bit S-R latch                         --
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_279 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '0';
20
    Period   : time           := 100 ns;
21
    Finish   : time           :=  20 us;
22
    SevLevel : severity_level := warning
23
);
24
end entity;
25
 
26
architecture Test of Testbench_279 is
27
    signal J, B    : unsigned(11 downto 0);         -- Test stimuli
28
    signal D, E    : std_logic_vector(3 downto 0);  -- Expected & actual results
29
    signal X       : std_logic_vector(11 downto 0); -- Shortened R-X-S pulses
30
    signal CLK, RS : std_logic;
31
 
32
    begin
33
    -----------------------------------------------------------------------
34
    -- Standard testbench components
35
    -----------------------------------------------------------------------
36
    TB: TTLBench
37
    generic map(
38
        StimClk  => StimClk,
39
        CheckClk => CheckClk,
40
        Period   => Period,
41
        Finish   => Finish,
42
        SevLevel => SevLevel
43
    )
44
    port map(
45
        J    => J,
46
        B    => B,
47
        CLK  => CLK,
48
        RS   => RS,
49
        D    => D,
50
        E    => E
51
    );
52
 
53
    process(CLK, RS) is                     -- Generate short R-S pulses
54
        variable Y : std_logic_vector(11 downto 0);
55
    begin
56
        if RS = '0' then
57
            X <= "011011011011";            -- General reset
58
        elsif rising_edge(CLK) then
59
            Y := std_logic_vector(J);
60
            Y(9) := Y(9) or not Y(11);      -- Reset dominates, all cases
61
            Y(6) := Y(6) or not (Y(7) and Y(8));
62
            Y(3) := Y(3) or not Y(5);
63
            Y(1) := Y(1) or not Y(2);
64
            Y(0) := Y(0) or not Y(2);
65
            X <= Y, (others => '1') after Period / 2;
66
        end if;
67
    end process;
68
 
69
    -----------------------------------------------------------------------
70
    -- Generate expected results (with zero delays)
71
    -----------------------------------------------------------------------
72
    process(all) is
73
        variable R, S : std_logic_vector(3 downto 0);
74
        variable Z    : std_logic_vector(1 downto 0);
75
    begin
76
        R := (X(11), X(8) and X(7), X(5), X(2));
77
        S := (X(9), X(6), X(3), X(1) and X(0));
78
 
79
        for i in R'range loop
80
            Z := S(i) & R(i);
81
            case Z is
82
                when "11"   => null;
83
                when "01"   => D(i) <= '1';
84
                when "10"   => D(i) <= '0';
85
                when others => D(i) <= 'X';
86
            end case;
87
        end loop;
88
    end process;
89
 
90
    -----------------------------------------------------------------------
91
    -- Device Under Test...                        
92
    -----------------------------------------------------------------------
93
    DUT: SN74LS279N
94
    port map(
95
        X_1  => X(2),  -- 1R\
96
        X_2  => X(1),  -- 1S1\
97
        X_3  => X(0),  -- 1S2\
98
        X_4  => E(0),  -- 1Q
99
        X_5  => X(5),  -- 2R\
100
        X_6  => X(3),  -- 2S\
101
        X_7  => E(1),  -- 2Q
102
        X_8  => open,  -- GND
103
        X_9  => E(2),  -- 3Q
104
        X_10 => X(6),  -- 3S\
105
        X_11 => X(7),  -- 3R1\
106
        X_12 => X(8),  -- 3R2\
107
        X_13 => E(3),  -- 4Q
108
        X_14 => X(9),  -- 4S\
109
        X_15 => X(11), -- 4R\
110
        X_16 => open   -- Vcc
111
    );
112
end architecture Test;

powered by: WebSVN 2.1.0

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