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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_181.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
-- July, 2016.  Perth, Australia                                     --
5
-- Compliance: VHDL 2008                                             --
6
-- Testbench for SN74LS181N: 4-bit arithmetic/logic unit             --
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_181 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           :=  100 ns;
21
    Finish   : time           := 1600 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_181 is
27
    signal JC, BC : unsigned(13 downto 0);          -- Test stimuli
28
    signal D,  E  : std_logic_vector(7 downto 0);   -- Expected & actual results
29
 
30
    signal A,  B,  F, S : unsigned(3 downto 0);
31
    signal CI, M        : std_logic;
32
    signal CO, EQ, P, G : std_logic;
33
 
34
    constant M1 : unsigned(3 downto 0) := (others => '1');
35
 
36
    begin
37
    S  <= BC( 3 downto 0);
38
    A  <= BC( 7 downto 4);
39
    B  <= BC(11 downto 8);
40
    CI <= BC(12);
41
    M  <= BC(13);
42
 
43
    D  <= CO & EQ & P & G & std_logic_vector(F);
44
 
45
    -----------------------------------------------------------------------
46
    -- Standard testbench components
47
    -----------------------------------------------------------------------
48
    TB: TTLBench
49
    generic map(
50
        StimClk  => StimClk,
51
        CheckClk => CheckClk,
52
        Period   => Period,
53
        Finish   => Finish,
54
        SevLevel => SevLevel
55
    )
56
    port map(
57
        J    => JC,
58
        B    => BC,
59
        CLK  => open,
60
        RS   => open,
61
        D    => D,
62
        E    => E
63
    );
64
 
65
    -----------------------------------------------------------------------
66
    -- Generate expected results (with zero delays)
67
    -----------------------------------------------------------------------
68
    process(all) is
69
        variable  BB, XX, YY, ZZ, FF, LL : unsigned(3 downto 0);
70
        variable  MB : std_logic;
71
        variable L01 : std_logic;
72
        variable L02 : std_logic;
73
        variable L03 : std_logic;
74
        variable L04 : std_logic;
75
        variable L05 : std_logic;
76
        variable L06 : std_logic;
77
        variable L07 : std_logic;
78
        variable L08 : std_logic;
79
        variable L09 : std_logic;
80
        variable L10 : std_logic;
81
        variable L11 : std_logic;
82
        variable L12 : std_logic;
83
        variable L13 : std_logic;
84
        variable L14 : std_logic;
85
        variable L15 : std_logic;
86
 
87
    begin
88
        MB    := not ( M );
89
        BB    := not B;
90
 
91
        for i in A'range loop
92
            YY(i) := not ( ( B(i) and S(3) and A(i) ) or ( A(i) and S(2) and BB(i) ) );
93
            XX(i) := not ( ( BB(i) and S(1) ) or ( S(0) and B(i) ) or A(i) );
94
        end loop;
95
 
96
        ZZ    :=  XX xor YY;
97
        L15   := ( XX(3) );
98
        L11   := ( YY(3) and XX(2) );
99
        L12   := ( YY(3) and YY(2) and XX(1) );
100
        L13   := ( YY(3) and YY(2) and YY(1) and XX(0) );
101
        L01   := not ( YY(3) and YY(2) and YY(1) and YY(0) and CI );
102
        L02   := ( CI and YY(0) and YY(1) and YY(2) and MB );
103
        L03   := ( YY(1) and YY(2) and XX(0) and MB );
104
        L04   := ( YY(2) and XX(1) and MB );
105
        L05   := ( XX(2) and MB );
106
        L06   := ( CI and YY(0) and YY(1) and MB );
107
        L07   := ( YY(1) and XX(0) and MB );
108
        L08   := ( XX(1) and MB );
109
        L09   := ( CI and YY(0) and MB );
110
        L10   := ( XX(0) and MB );
111
        LL(0) := not ( CI and MB );
112
        LL(3) := not ( L02 or L03 or L04 or L05 );
113
        LL(2) := not ( L06 or L07 or L08 );
114
        LL(1) := not ( L09 or L10 );
115
        L14   := not ( L15 or L11 or L12 or L13 );
116
        FF    := LL xor ZZ;
117
        G     <= L14;
118
        CO    <= not ( L14 and L01 );
119
        P     <= nand_reduce(std_logic_vector(YY));
120
        EQ    <= and_reduce(std_logic_vector(FF));
121
        F     <= FF;
122
    end process;
123
 
124
    -----------------------------------------------------------------------
125
    -- Device Under Test...                        
126
    -----------------------------------------------------------------------
127
    DUT: SN74LS181N
128
    port map(
129
        X_1  => B(0), -- B(0)\
130
        X_2  => A(0), -- A(0)\
131
        X_3  => S(3), -- S(3)
132
        X_4  => S(2), -- S(2)
133
        X_5  => S(1), -- S(1)
134
        X_6  => S(0), -- S(0)
135
        X_7  => CI,   -- Cn
136
        X_8  => M,    -- M
137
        X_9  => E(0), -- F(0)\
138
        X_10 => E(1), -- F(1)\
139
        X_11 => E(2), -- F(2)\
140
        X_12 => open, -- GND
141
        X_13 => E(3), -- F(3)\
142
        X_14 => E(6), -- A=B
143
        X_15 => E(5), -- P\
144
        X_16 => E(7), -- Cn+4
145
        X_17 => E(4), -- G\
146
        X_18 => B(3), -- B(3)\
147
        X_19 => A(3), -- A(3)\
148
        X_20 => B(2), -- B(2)\
149
        X_21 => A(2), -- A(2)\
150
        X_22 => B(1), -- B(1)\
151
        X_23 => A(1), -- A(1)\
152
        X_24 => open  -- Vcc
153
    );
154
end architecture Test;

powered by: WebSVN 2.1.0

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