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

Subversion Repositories ttl_library

[/] [ttl_library/] [trunk/] [Testbench/] [Testbench_178.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 SN74178N: 4-bit shift register                      --
7
-- Note: 74178 is 74179 without MR\ & Q3\ pins                       --
8
-----------------------------------------------------------------------
9
 
10
library ieee;
11
    use ieee.std_logic_1164.all;
12
    use ieee.std_logic_misc.all;
13
    use ieee.numeric_std.all;
14
    use work.LSTTL.all;
15
    use work.TTLPrivate.all;
16
 
17
entity Testbench_178 is     -- Top-level bench
18
generic(
19
    StimClk  : std_logic      := '1';
20
    CheckClk : std_logic      := '1';
21
    Period   : time           := 100 ns;
22
    Finish   : time           :=  20 us;
23
    SevLevel : severity_level := failure
24
);
25
end entity;
26
 
27
architecture Test of Testbench_178 is
28
    signal RS, PE, SE : std_logic;
29
    signal CLK,DS     : std_logic;
30
    signal JC, BC     : unsigned(7 downto 0);           -- Test stimuli
31
    signal D,  E      : std_logic_vector(3 downto 0);   -- Expected & actual results
32
    signal P, REG     : std_logic_vector(3 downto 0);
33
 
34
    begin
35
        D(3 downto 0) <= REG;
36
        P             <= std_logic_vector(JC(3 downto 0));
37
        DS            <= JC(4);
38
 
39
    process(CLK, RS) is
40
        variable N : natural := 1;
41
    begin
42
        if    RS = '0' then
43
            N  :=  1;
44
            PE <= '0';
45
            SE <= '0';
46
        elsif falling_edge(CLK) then
47
            PE <= '0';
48
            SE <= '0';
49
            N  := N - 1;
50
            case N is
51
                when 1                 => PE <= '1';
52
                when 2 | 4 | 6 | 8 | 9 => SE <= '1';
53
                when 0                 => N  := 16;
54
                when others            => null;
55
            end case;
56
        end if;
57
    end process;
58
 
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  => CLK,
74
        RS   => RS,
75
        D    => D,
76
        E    => E
77
    );
78
 
79
    -----------------------------------------------------------------------
80
    -- Generate expected results (with zero delays)
81
    -----------------------------------------------------------------------
82
    process(CLK) is
83
    begin
84
        if falling_edge(CLK) then
85
            if SE    = '1' then
86
                REG <= REG(2 downto 0) & DS;
87
            elsif PE = '1' then
88
                REG <= P;
89
            end if;
90
        end if;
91
    end process;
92
 
93
    -----------------------------------------------------------------------
94
    -- Device Under Test...                        
95
    -----------------------------------------------------------------------
96
    DUT: SN74178N
97
    port map(
98
        X_1  => P(1),  -- P1
99
        X_2  => P(0),  -- P0
100
        X_3  => DS,    -- DS
101
        X_4  => E(0),  -- Q0
102
        X_5  => CLK,    -- CP\
103
        X_6  => E(1),  -- Q1
104
        X_7  => open,  -- GND
105
        X_8  => E(2),  -- Q2
106
        X_9  => PE,    -- PE
107
        X_10 => E(3),  -- Q3
108
        X_11 => SE,    -- SE
109
        X_12 => P(3),  -- P3
110
        X_13 => P(2),  -- P2
111
        X_14 => open   -- Vcc
112
    );
113
end architecture Test;

powered by: WebSVN 2.1.0

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