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

Subversion Repositories c16

[/] [c16/] [trunk/] [vhdl/] [test.vhd] - Blame information for rev 33

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
 
2
-- VHDL Test Bench Created from source file cpu_engine.vhd -- 12:41:11 06/20/2003
3
--
4
-- Notes: 
5
-- This testbench has been automatically generated using types std_logic and
6
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
7
-- that these types always be used for the top-level I/O of a design in order 
8
-- to guarantee that the testbench will bind correctly to the post-implementation 
9
-- simulation model.
10
--
11
LIBRARY ieee;
12
USE ieee.std_logic_1164.ALL;
13
USE ieee.numeric_std.ALL;
14
 
15
use work.cpu_pack.ALL;
16
 
17
ENTITY testbench IS
18
END testbench;
19
 
20
ARCHITECTURE behavior OF testbench IS
21
 
22
        COMPONENT cpu_engine
23 9 jsauermann
        PORT(
24
                clk_i : IN std_logic;
25
                dat_i : IN std_logic_vector(7 downto 0);
26
                rst_i : IN std_logic;
27
                ack_i : IN std_logic;
28
                int : IN std_logic;
29
                dat_o : OUT std_logic_vector(7 downto 0);
30
                adr_o : OUT std_logic_vector(15 downto 0);
31
                cyc_o : OUT std_logic;
32
                stb_o : OUT std_logic;
33
                tga_o : OUT std_logic_vector(0 to 0);
34
                we_o : OUT std_logic;
35
                halt : OUT std_logic;
36
                q_pc : OUT std_logic_vector(15 downto 0);
37
                q_opc : OUT std_logic_vector(7 downto 0);
38
                q_cat : OUT op_category;
39
                q_imm : OUT std_logic_vector(15 downto 0);
40
                q_cyc : OUT cycle;
41
                q_sx : OUT std_logic_vector(1 downto 0);
42
                q_sy : OUT std_logic_vector(3 downto 0);
43
                q_op : OUT std_logic_vector(4 downto 0);
44
                q_sa : OUT std_logic_vector(4 downto 0);
45
                q_smq : OUT std_logic;
46
                q_we_rr : OUT std_logic;
47
                q_we_ll : OUT std_logic;
48
                q_we_sp : OUT SP_OP;
49
                q_rr : OUT std_logic_vector(15 downto 0);
50
                q_ll : OUT std_logic_vector(15 downto 0);
51
                q_sp : OUT std_logic_vector(15 downto 0)
52 2 jsauermann
                );
53
        END COMPONENT;
54
 
55 9 jsauermann
        signal  CLK_I   : std_logic;
56
        signal  DAT_I   : std_logic_vector( 7 downto 0);
57
        signal  DAT_O   : std_logic_vector( 7 downto 0);
58
        signal  RST_I   : std_logic;
59
        signal  ACK_I   : std_logic;
60
        signal  ADR_O   : std_logic_vector(15 downto 0);
61
        signal  CYC_O   : std_logic;
62
        signal  STB_O   : std_logic;
63
        signal  TGA_O   : std_logic_vector( 0 downto 0);          -- '1' if I/O
64
        signal  WE_O    : std_logic;
65 2 jsauermann
 
66 9 jsauermann
        signal  INT     : std_logic;
67
        signal  HALT    : std_logic;
68 2 jsauermann
 
69 9 jsauermann
                        -- debug signals
70
                        --
71
        signal  Q_PC    : std_logic_vector(15 downto 0);
72
        signal  Q_OPC   : std_logic_vector( 7 downto 0);
73
        signal  Q_CAT   : op_category;
74
        signal  Q_IMM   : std_logic_vector(15 downto 0);
75
        signal  Q_CYC   : cycle;
76 2 jsauermann
 
77
                        -- select signals
78
        signal  Q_SX    : std_logic_vector(1 downto 0);
79
        signal  Q_SY    : std_logic_vector(3 downto 0);
80
        signal  Q_OP    : std_logic_vector(4 downto 0);
81
        signal  Q_SA    : std_logic_vector(4 downto 0);
82
        signal  Q_SMQ   : std_logic;
83
 
84
                        -- write enable/select signal
85 9 jsauermann
        signal  Q_WE_RR : std_logic;
86
        signal  Q_WE_LL : std_logic;
87
        signal  Q_WE_SP : SP_OP;
88 2 jsauermann
 
89 9 jsauermann
        signal  Q_RR    : std_logic_vector(15 downto 0);
90
        signal  Q_LL    : std_logic_vector(15 downto 0);
91
        signal  Q_SP    : std_logic_vector(15 downto 0);
92
 
93
        signal  clk_counter : INTEGER := 0;
94 2 jsauermann
 
95
BEGIN
96
 
97 9 jsauermann
        uut: cpu_engine
98
        PORT MAP(
99
                clk_i => clk_i,
100
                dat_i => dat_i,
101
                dat_o => dat_o,
102
                rst_i => rst_i,
103
                ack_i => ack_i,
104
                adr_o => adr_o,
105
                cyc_o => cyc_o,
106
                stb_o => stb_o,
107
                tga_o => tga_o,
108
                we_o => we_o,
109
                int => int,
110
                halt => halt,
111
                q_pc => q_pc,
112
                q_opc => q_opc,
113
                q_cat => q_cat,
114
                q_imm => q_imm,
115
                q_cyc => q_cyc,
116
                q_sx => q_sx,
117
                q_sy => q_sy,
118
                q_op => q_op,
119
                q_sa => q_sa,
120
                q_smq => q_smq,
121
                q_we_rr => q_we_rr,
122
                q_we_ll => q_we_ll,
123
                q_we_sp => q_we_sp,
124
                q_rr => q_rr,
125
                q_ll => q_ll,
126
                q_sp => q_sp
127
        );
128 2 jsauermann
 
129 9 jsauermann
        ack_i <= stb_o;
130 2 jsauermann
 
131
-- *** Test Bench - User Defined Section ***
132 9 jsauermann
        PROCESS -- clock process for CLK_I,
133 2 jsauermann
        BEGIN
134
                CLOCK_LOOP : LOOP
135 9 jsauermann
                        CLK_I <= transport '0';
136 2 jsauermann
                        WAIT FOR 1 ns;
137 9 jsauermann
                        CLK_I <= transport '1';
138 2 jsauermann
                        WAIT FOR 1 ns;
139
                        WAIT FOR 11 ns;
140 9 jsauermann
                        CLK_I <= transport '0';
141 2 jsauermann
                        WAIT FOR 12 ns;
142
                END LOOP CLOCK_LOOP;
143
        END PROCESS;
144
 
145 9 jsauermann
        PROCESS(CLK_I)
146 2 jsauermann
        BEGIN
147 9 jsauermann
                if (rising_edge(CLK_I)) then
148 2 jsauermann
                        if (Q_CYC = M1) then
149
                                CLK_COUNTER <= CLK_COUNTER + 1;
150
                        end if;
151
 
152 9 jsauermann
                        if (ADR_O(0) = '0') then          DAT_I <= X"44"; -- data
153
                        else                                                    DAT_I <= X"01"; -- control
154 2 jsauermann
                        end if;
155
 
156
                        case CLK_COUNTER is
157 9 jsauermann
                                when 0           =>      RST_I <= '1';   INT <= '0';
158
                                when 1          =>      RST_I <= '0';
159 2 jsauermann
--                              when 20         =>      INT <= '1';
160
 
161
 
162
                                when 1000       =>      CLK_COUNTER <= 0;
163
                                                                ASSERT (FALSE) REPORT
164
                                                                        "simulation done (no error)"
165
                                                                        SEVERITY FAILURE;
166
                                when others     =>
167
                        end case;
168
                end if;
169
        END PROCESS;
170
 
171
END;

powered by: WebSVN 2.1.0

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