OSDN Git Service

status reg test ok
[motonesfpga/motonesfpga.git] / tools / qt_proj_test5 / testbench_qt_proj_test5.vhd
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4
5 entity testbench_qt_proj_test5 is
6 end testbench_qt_proj_test5;
7
8 architecture stimulus of testbench_qt_proj_test5 is 
9     component qt_proj_test5
10         port (
11
12     signal dbg_cpu_clk  : out std_logic;
13     signal dbg_ppu_clk  : out std_logic;
14     signal dbg_addr : out std_logic_vector( 16 - 1 downto 0);
15     signal dbg_d_io : out std_logic_vector( 8 - 1 downto 0);
16     signal dbg_vram_ad  : out std_logic_vector (7 downto 0);
17     signal dbg_vram_a   : out std_logic_vector (13 downto 8);
18
19     
20     signal dbg_status       : out std_logic_vector(7 downto 0);
21     signal dbg_dec_oe_n    : out std_logic;
22     signal dbg_dec_val     : out std_logic_vector (7 downto 0);
23     signal dbg_int_dbus    : out std_logic_vector (7 downto 0);
24     signal dbg_status_val    : out std_logic_vector (7 downto 0);
25     signal dbg_stat_we_n    : out std_logic;
26     
27 ---monitor inside cpu
28     signal dbg_instruction  : out std_logic_vector(7 downto 0);
29     signal dbg_int_d_bus  : out std_logic_vector(7 downto 0);
30     
31     
32             
33             base_clk    : in std_logic;
34             rst_n       : in std_logic;
35             joypad1     : in std_logic_vector(7 downto 0);
36             joypad2     : in std_logic_vector(7 downto 0);
37             vga_clk     : out std_logic;
38             h_sync_n    : out std_logic;
39             v_sync_n    : out std_logic;
40             r           : out std_logic_vector(3 downto 0);
41             g           : out std_logic_vector(3 downto 0);
42             b           : out std_logic_vector(3 downto 0)
43              );
44     end component;
45
46     component vga_device
47     port (  vga_clk     : in std_logic;
48             rst_n       : in std_logic;
49             h_sync_n    : in std_logic;
50             v_sync_n    : in std_logic;
51             r           : in std_logic_vector(3 downto 0);
52             g           : in std_logic_vector(3 downto 0);
53             b           : in std_logic_vector(3 downto 0)
54             );
55     end component;
56
57     signal base_clk         : std_logic;
58     signal vga_clk         : std_logic;
59     signal reset_input      : std_logic;
60
61     signal h_sync_n    : std_logic;
62     signal v_sync_n    : std_logic;
63     signal r           : std_logic_vector(3 downto 0);
64     signal g           : std_logic_vector(3 downto 0);
65     signal b           : std_logic_vector(3 downto 0);
66     signal joypad1     : std_logic_vector(7 downto 0);
67     signal joypad2     : std_logic_vector(7 downto 0);
68
69     constant powerup_time   : time := 50 ns;
70     constant reset_time     : time := 200 ns;
71
72     ---clock frequency = 21,477,270 (21 MHz)
73     --constant base_clock_time : time := 46 ns;
74     --base clock frequency shares vga clock.
75     constant base_clock_time : time := 40 ns;
76
77
78     signal dbg_cpu_clk  : std_logic;
79     signal dbg_ppu_clk  : std_logic;
80     signal dbg_addr : std_logic_vector( 16 - 1 downto 0);
81     signal dbg_d_io : std_logic_vector( 8 - 1 downto 0);
82     signal dbg_vram_ad  : std_logic_vector (7 downto 0);
83     signal dbg_vram_a   : std_logic_vector (13 downto 8);
84
85     
86     signal dbg_status       : std_logic_vector(7 downto 0);
87     signal dbg_dec_oe_n    : std_logic;
88     signal dbg_dec_val     : std_logic_vector (7 downto 0);
89     signal dbg_int_dbus    : std_logic_vector (7 downto 0);
90     signal dbg_status_val    : std_logic_vector (7 downto 0);
91     signal dbg_stat_we_n    : std_logic;
92     
93 ---monitor inside cpu
94     signal dbg_instruction  : std_logic_vector(7 downto 0);
95     signal dbg_int_d_bus  : std_logic_vector(7 downto 0);
96 begin
97
98     sim_board : qt_proj_test5 port map (
99     dbg_cpu_clk  , 
100     dbg_ppu_clk  , 
101     dbg_addr , 
102     dbg_d_io , 
103     dbg_vram_ad  , 
104     dbg_vram_a   , 
105
106     
107     dbg_status       , 
108     dbg_dec_oe_n    , 
109     dbg_dec_val     , 
110     dbg_int_dbus    , 
111     dbg_status_val    , 
112     dbg_stat_we_n    , 
113     
114     dbg_instruction  , 
115     dbg_int_d_bus  , 
116     
117     
118     base_clk, reset_input, joypad1, joypad2, 
119             vga_clk, h_sync_n, v_sync_n, r, g, b);
120
121 --    dummy_vga_disp : vga_device 
122 --        port map (vga_clk, reset_input, h_sync_n, v_sync_n, r, g, b);
123
124     --- input reset.
125     reset_p: process
126     begin
127         wait for powerup_time;
128         reset_input <= '0';
129
130         wait for reset_time;
131         reset_input <= '1';
132
133         wait;
134     end process;
135
136     --- generate base clock.
137     clock_p: process
138     begin
139         base_clk <= '1';
140         wait for base_clock_time / 2;
141         base_clk <= '0';
142         wait for base_clock_time / 2;
143     end process;
144
145 end stimulus;
146