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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_183.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 SN74H183N: Dual high-speed adder                    --
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_183 is     -- Top-level bench
17
generic(
18
    StimClk  : std_logic      := '1';
19
    CheckClk : std_logic      := '1';
20
    Period   : time           := 25 ns;
21
    Finish   : time           :=  2 us;
22
    SevLevel : severity_level := failure
23
);
24
end entity;
25
 
26
architecture Test of Testbench_183 is
27
    subtype Pair   is std_logic_vector(1 downto 0);
28
    subtype Triple is std_logic_vector(2 downto 0);
29
    type    Table  is array(0 to 7) of Pair;
30
 
31
    signal JC, BC : unsigned(5 downto 0);           -- Test stimuli
32
    signal D, E   : std_logic_vector(3 downto 0);   -- Expected & actual results
33
 
34
    signal X, Y   : Pair;
35
 
36
    alias CIa is BC(0);
37
    alias Aa  is BC(1);
38
    alias Ba  is BC(2);
39
    alias CIb is BC(3);
40
    alias Ab  is BC(4);
41
    alias Bb  is BC(5);
42
 
43
    constant SUM   : natural := 1;
44
    constant CARRY : natural := 0;
45
 
46
    impure function Adder(A, B, C : std_logic) return Pair is   -- impure, as it calls "now"
47
        constant ANS : Table := (("00"), ("10"), ("10"), ("01"), ("10"), ("01"), ("01"), ("11"));
48
        variable Z   : unsigned(2 downto 0) := (others => '0');
49
        variable R   : natural range 7 downto 0 := 0;
50
    begin
51
        if now > 5 ns then      -- Avoid metavalues at T=0
52
            Z := A & B & C;
53
            R := to_integer(Z);
54
        end if;
55
        return ANS(R);
56
    end function;
57
 
58
    begin
59
    -----------------------------------------------------------------------
60
    -- Standard testbench components
61
    -----------------------------------------------------------------------
62
    TB: TTLBench
63
    generic map(
64
        StimClk  => StimClk,
65
        CheckClk => CheckClk,
66
        Period   => Period,
67
        Finish   => Finish,
68
        SevLevel => SevLevel
69
    )
70
    port map(
71
        J    => JC,
72
        B    => BC,
73
        CLK  => open,
74
        RS   => open,
75
        D    => D,
76
        E    => E
77
    );
78
 
79
    -----------------------------------------------------------------------
80
    -- Generate expected results (with zero delays)
81
    -----------------------------------------------------------------------
82
    X <= Adder(Aa, Ba, CIa);
83
    Y <= Adder(Ab, Bb, CIb);
84
    D <= (Y(SUM), Y(CARRY), X(SUM), X(CARRY));
85
 
86
    -----------------------------------------------------------------------
87
    -- Device Under Test...                        
88
    -----------------------------------------------------------------------
89
    DUT: SN74H183N
90
    port map(
91
        X_1  => Aa,    -- Aa
92
        X_3  => Ba,    -- Ba
93
        X_4  => CIa,   -- CIa
94
        X_5  => E(0),  -- COa
95
        X_6  => E(1),  -- Sa
96
        X_7  => open,  -- GND
97
        X_8  => E(3),  -- Sb
98
        X_10 => E(2),  -- COb
99
        X_11 => CIb,   -- CIb
100
        X_12 => Bb,    -- Bb
101
        X_13 => Ab,    -- Ab
102
        X_14 => open   -- Vcc
103
    );
104
end architecture Test;

powered by: WebSVN 2.1.0

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