OSDN Git Service

clock enabler update
[motonesfpga/motonesfpga.git] / de0_cv_nes / dummy-mos6502.vhd
1 library ieee;\r
2 use ieee.std_logic_1164.all;\r
3 \r
4 entity mos6502 is \r
5     port (  \r
6             pi_base_clk         : in std_logic;\r
7             pi_cpu_en       : in std_logic_vector (7 downto 0);\r
8             pi_rdy         : in std_logic;\r
9             pi_rst_n       : in std_logic;\r
10             pi_irq_n       : in std_logic;\r
11             pi_nmi_n       : in std_logic;\r
12             po_r_nw        : out std_logic;\r
13             po_addr        : out std_logic_vector ( 15 downto 0);\r
14             pio_d_io       : inout std_logic_vector ( 7 downto 0)\r
15     );\r
16 end mos6502;\r
17 \r
18 architecture rtl of mos6502 is\r
19 \r
20 \r
21 begin\r
22 \r
23     --set ppu value...\r
24     set_ppu_p : process (pi_base_clk, pi_rst_n)\r
25     use ieee.std_logic_arith.conv_std_logic_vector;\r
26 \r
27     variable init_step_cnt, plt_step_cnt, \r
28             nt_step_cnt, spr_step_cnt, dma_step_cnt, scl_step_cnt, \r
29             enable_ppu_step_cnt, nmi_step_cnt : integer;\r
30     variable init_done : std_logic;\r
31     variable global_step_cnt : integer;\r
32     constant cpu_io_multi : integer := 3; --io happens every 4 cpu cycle.\r
33     variable i, j : integer;\r
34     variable ch : integer := 16#41# ;\r
35     variable nmi_oam_x : integer range 0 to 255;\r
36     variable nmi_scl_y : integer range 0 to 255;\r
37 \r
38     variable ref_cnt : integer range 0 to 120;\r
39 \r
40 procedure io_out (ad: in integer; dt : in integer) is\r
41 begin\r
42     po_r_nw <= '0';\r
43     po_addr <= conv_std_logic_vector(ad, 16);\r
44     pio_d_io <= conv_std_logic_vector(dt, 8);\r
45 end;\r
46 \r
47 procedure io_brk is\r
48 begin\r
49     po_addr <= (others => 'Z');\r
50     pio_d_io <= (others => 'Z');\r
51     po_r_nw <= 'Z';\r
52 end;\r
53 \r
54 procedure io_read (ad: in integer) is\r
55 begin\r
56     po_r_nw <= '1';\r
57     po_addr <= conv_std_logic_vector(ad, 16);\r
58     pio_d_io <= (others => 'Z');\r
59 end;\r
60 \r
61     begin\r
62         if (pi_rst_n = '0') then\r
63             \r
64             po_r_nw <= 'Z';\r
65             po_addr <= (others => 'Z');\r
66             pio_d_io <= (others => 'Z');\r
67             \r
68             init_done := '0';\r
69             global_step_cnt := 0;\r
70             init_step_cnt := 0;\r
71             plt_step_cnt := 0;\r
72             nt_step_cnt := 0;\r
73             spr_step_cnt := 0;\r
74             dma_step_cnt := 0;\r
75             scl_step_cnt := 0;\r
76             enable_ppu_step_cnt := 0;\r
77             nmi_step_cnt := 0;\r
78             nmi_oam_x := 0;\r
79             nmi_scl_y := 200;\r
80             ref_cnt := 0;\r
81 \r
82         elsif (rising_edge(pi_base_clk)) then\r
83             if (pi_cpu_en(0) = '1') then\r
84             if (pi_rdy = '1') then\r
85                 if (init_done = '0') then\r
86                     if (global_step_cnt = 0) then\r
87                         --step0.0 = init ppu.\r
88                         if (init_step_cnt = 0 * cpu_io_multi) then\r
89                             --PPUCTRL=01 for test...\r
90                             io_out(16#2000#, 16#01#);\r
91                         elsif (init_step_cnt = 1 * cpu_io_multi) then\r
92                             --PPUMASK=02\r
93                             io_out(16#2001#, 16#02#);\r
94                         elsif (init_step_cnt = 2 * cpu_io_multi) then\r
95                             --PPUCTRL=00\r
96                             io_out(16#2000#, 16#00#);\r
97                         elsif (init_step_cnt = 3 * cpu_io_multi) then\r
98                             --PPUMASK=00\r
99                             io_out(16#2001#, 16#00#);\r
100                         elsif (init_step_cnt = 4 * cpu_io_multi) then\r
101                             --ppuaddr\r
102                             io_out(16#2006#, 16#02#);\r
103                         elsif (init_step_cnt = 5 * cpu_io_multi) then\r
104                             io_out(16#2006#, 16#40#);\r
105                         elsif (init_step_cnt = 6 * cpu_io_multi) then\r
106                             --scroll\r
107                             io_out(16#2005#, 16#21#);\r
108                         elsif (init_step_cnt = 7 * cpu_io_multi) then\r
109                             io_out(16#2005#, 16#5#);\r
110                         else\r
111                             io_brk;\r
112                             if (init_step_cnt > 8 * cpu_io_multi) then\r
113                                 global_step_cnt := global_step_cnt + 1;\r
114                             end if;\r
115                         end if;\r
116                         init_step_cnt := init_step_cnt + 1;\r
117                     elsif (global_step_cnt = 1) then\r
118                         --step0.1 = palette set.\r
119     --palettes:\r
120     --;;;bg palette\r
121     --  .byte   $0f, $00, $10, $20\r
122     --  .byte   $0f, $04, $14, $24\r
123     --  .byte   $0f, $08, $18, $28\r
124     --  .byte   $0f, $0c, $1c, $2c\r
125     --;;;spr palette\r
126     --  .byte   $0f, $00, $10, $20\r
127     --  .byte   $0f, $06, $16, $26\r
128     --  .byte   $0f, $08, $18, $28\r
129     --  .byte   $0f, $0a, $1a, $2a\r
130                         \r
131                         \r
132                         if (plt_step_cnt = 0 * cpu_io_multi) then\r
133                             --set vram addr 3f00\r
134                             io_out(16#2006#, 16#3f#);\r
135                         elsif (plt_step_cnt = 1 * cpu_io_multi) then\r
136                             io_out(16#2006#, 16#00#);\r
137                         \r
138                         elsif (plt_step_cnt = 2 * cpu_io_multi) then\r
139                             --set palette bg data\r
140                             io_out(16#2007#, 16#11#);\r
141                         elsif (plt_step_cnt = 3 * cpu_io_multi) then\r
142                             io_out(16#2007#, 16#01#);\r
143                         elsif (plt_step_cnt = 4 * cpu_io_multi) then\r
144                             io_out(16#2007#, 16#03#);\r
145                         elsif (plt_step_cnt = 5 * cpu_io_multi) then\r
146                             io_out(16#2007#, 16#13#);\r
147 \r
148                         elsif (plt_step_cnt = 6 * cpu_io_multi) then\r
149                             io_out(16#2007#, 16#0f#);\r
150                         elsif (plt_step_cnt = 7 * cpu_io_multi) then\r
151                             io_out(16#2007#, 16#04#);\r
152                         elsif (plt_step_cnt = 8 * cpu_io_multi) then\r
153                             io_out(16#2007#, 16#14#);\r
154                         elsif (plt_step_cnt = 9 * cpu_io_multi) then\r
155                             io_out(16#2007#, 16#24#);\r
156      \r
157                         elsif (plt_step_cnt = 10 * cpu_io_multi) then\r
158                             io_out(16#2007#, 16#0f#);\r
159                         elsif (plt_step_cnt = 11 * cpu_io_multi) then\r
160                             io_out(16#2007#, 16#08#);\r
161                         elsif (plt_step_cnt = 12 * cpu_io_multi) then\r
162                             io_out(16#2007#, 16#18#);\r
163                         elsif (plt_step_cnt = 13 * cpu_io_multi) then\r
164                             io_out(16#2007#, 16#28#);\r
165      \r
166                         elsif (plt_step_cnt = 14 * cpu_io_multi) then\r
167                             io_out(16#2007#, 16#05#);\r
168                         elsif (plt_step_cnt = 15 * cpu_io_multi) then\r
169                             io_out(16#2007#, 16#0c#);\r
170                         elsif (plt_step_cnt = 16 * cpu_io_multi) then\r
171                             io_out(16#2007#, 16#1c#);\r
172                         elsif (plt_step_cnt = 17 * cpu_io_multi) then\r
173                             io_out(16#2007#, 16#2c#);\r
174 \r
175                          elsif (plt_step_cnt = 18 * cpu_io_multi) then\r
176                             --below is sprite pallete\r
177                             io_out(16#2007#, 16#00#);\r
178                         elsif (plt_step_cnt = 19 * cpu_io_multi) then\r
179                             io_out(16#2007#, 16#24#);\r
180                         elsif (plt_step_cnt = 20 * cpu_io_multi) then\r
181                             io_out(16#2007#, 16#1b#);\r
182                         elsif (plt_step_cnt = 21 * cpu_io_multi) then\r
183                             io_out(16#2007#, 16#11#);\r
184 \r
185                         elsif (plt_step_cnt = 22 * cpu_io_multi) then\r
186                             io_out(16#2007#, 16#00#);\r
187                         elsif (plt_step_cnt = 23 * cpu_io_multi) then\r
188                             io_out(16#2007#, 16#32#);\r
189                         elsif (plt_step_cnt = 24 * cpu_io_multi) then\r
190                             io_out(16#2007#, 16#16#);\r
191                         elsif (plt_step_cnt = 25 * cpu_io_multi) then\r
192                             io_out(16#2007#, 16#20#);\r
193 \r
194                         elsif (plt_step_cnt = 26 * cpu_io_multi) then\r
195                             io_out(16#2007#, 16#00#);\r
196                         elsif (plt_step_cnt = 27 * cpu_io_multi) then\r
197                             io_out(16#2007#, 16#26#);\r
198                         elsif (plt_step_cnt = 28 * cpu_io_multi) then\r
199                             io_out(16#2007#, 16#01#);\r
200                         elsif (plt_step_cnt = 29 * cpu_io_multi) then\r
201                             io_out(16#2007#, 16#31#);\r
202 \r
203                         else\r
204                             io_brk;\r
205                             if (plt_step_cnt > 30 * cpu_io_multi) then\r
206                                 global_step_cnt := global_step_cnt + 1;\r
207                             end if;\r
208                         end if;\r
209                         plt_step_cnt := plt_step_cnt + 1;\r
210                         \r
211                     elsif (global_step_cnt = 2) then\r
212                         --step1 = name table set.\r
213                         if (nt_step_cnt = 0 * cpu_io_multi) then\r
214                             --set vram addr 2005 (first row, 6th col)\r
215                             io_out(16#2006#, 16#20#);\r
216                         elsif (nt_step_cnt = 1 * cpu_io_multi) then\r
217                             io_out(16#2006#, 16#03#);\r
218                         elsif (nt_step_cnt = 2 * cpu_io_multi) then\r
219                             --set name tbl data\r
220                             --0x44, 45, 45 = DEE\r
221                             io_out(16#2007#, 16#44#);\r
222                         elsif (nt_step_cnt = 3 * cpu_io_multi) then\r
223                             io_out(16#2007#, 16#45#);\r
224                         elsif (nt_step_cnt = 4 * cpu_io_multi) then\r
225                             io_out(16#2007#, 16#45#);\r
226 \r
227 \r
228                         elsif (nt_step_cnt = 5 * cpu_io_multi) then\r
229                             io_out(16#2006#, 16#20#);\r
230                         elsif (nt_step_cnt = 6 * cpu_io_multi) then\r
231                             io_out(16#2006#, 16#2a#);\r
232                         elsif (nt_step_cnt = 7 * cpu_io_multi) then\r
233                             io_out(16#2007#, 16#44#);\r
234 \r
235                         elsif (nt_step_cnt = 8 * cpu_io_multi) then\r
236                             io_out(16#2006#, 16#24#);\r
237                         elsif (nt_step_cnt = 9 * cpu_io_multi) then\r
238                             io_out(16#2006#, 16#43#);\r
239                         elsif (nt_step_cnt = 10 * cpu_io_multi) then\r
240                             io_out(16#2007#, 16#6d#);\r
241                         elsif (nt_step_cnt = 11 * cpu_io_multi) then\r
242                             io_out(16#2007#, 16#6f#);\r
243                         elsif (nt_step_cnt = 12 * cpu_io_multi) then\r
244                             io_out(16#2007#, 16#74#);\r
245                         elsif (nt_step_cnt = 13 * cpu_io_multi) then\r
246                             io_out(16#2007#, 16#6f#);\r
247                             \r
248                         elsif (nt_step_cnt = 14 * cpu_io_multi) then\r
249                             io_out(16#2006#, 16#2e#);\r
250                         elsif (nt_step_cnt = 15 * cpu_io_multi) then\r
251                             io_out(16#2006#, 16#93#);\r
252                         elsif (nt_step_cnt = 16 * cpu_io_multi) then\r
253                             io_out(16#2007#, 16#59#);\r
254 \r
255                         elsif (nt_step_cnt = 17 * cpu_io_multi) then\r
256                             io_out(16#2007#, 16#00#);\r
257 \r
258                         else\r
259                             io_brk;\r
260                             if (nt_step_cnt > 4 * cpu_io_multi) then\r
261                                 global_step_cnt := global_step_cnt + 1;\r
262                             end if;\r
263                         end if;\r
264                         \r
265                         nt_step_cnt := nt_step_cnt + 1;\r
266                         \r
267                     elsif (global_step_cnt = 3) then\r
268                         --step2 = sprite set.\r
269                         if (spr_step_cnt = 0) then\r
270                             --set sprite addr=00 (first sprite)\r
271                             io_out(16#2003#, 16#00#);\r
272                         \r
273                         elsif (spr_step_cnt = 1 * cpu_io_multi) then\r
274                             --set sprite data: y=02\r
275                             io_out(16#2004#, 16#05#);\r
276                         elsif (spr_step_cnt = 2 * cpu_io_multi) then\r
277                             --tile=0x4d (ascii 'O')\r
278                             io_out(16#2004#, 16#4f#);\r
279                         elsif (spr_step_cnt = 3 * cpu_io_multi) then\r
280                             --set sprite attr=01 (palette 01)\r
281                             io_out(16#2004#, 16#01#);\r
282                         elsif (spr_step_cnt = 4 * cpu_io_multi) then\r
283                             --set sprite data: x=60\r
284                             io_out(16#2004#, 16#3c#);\r
285 \r
286                         elsif (spr_step_cnt = 5 * cpu_io_multi) then\r
287                             --set sprite data: y=50\r
288                             io_out(16#2004#, 1);\r
289                         elsif (spr_step_cnt = 6 * cpu_io_multi) then\r
290                             --tile=0x4f (ascii 'M')\r
291                             io_out(16#2004#, 16#4d#);\r
292                         elsif (spr_step_cnt = 7 * cpu_io_multi) then\r
293                             --set sprite attr=02\r
294                             io_out(16#2004#, 16#02#);\r
295                         elsif (spr_step_cnt = 8 * cpu_io_multi) then\r
296                             --set sprite data: x=100\r
297                             io_out(16#2004#, 16#64#);\r
298 \r
299                         elsif (spr_step_cnt = 9 * cpu_io_multi) then\r
300                             --set sprite data: y=60\r
301                             io_out(16#2004#, 60);\r
302                         elsif (spr_step_cnt = 10 * cpu_io_multi) then\r
303                             --tile=0x4d (ascii 'P')\r
304                             io_out(16#2004#, 16#50#);\r
305                         elsif (spr_step_cnt = 11 * cpu_io_multi) then\r
306                             --set sprite attr=01\r
307                             io_out(16#2004#, 16#01#);\r
308                         elsif (spr_step_cnt = 12 * cpu_io_multi) then\r
309                             --set sprite data: x=33\r
310                             io_out(16#2004#, 16#21#);\r
311 \r
312                         elsif (spr_step_cnt = 13 * cpu_io_multi) then\r
313                             --set sprite data: y=61\r
314                             io_out(16#2004#, 16#3d#);\r
315                         elsif (spr_step_cnt = 14 * cpu_io_multi) then\r
316                             --tile=0x4d (ascii 'Q')\r
317                             io_out(16#2004#, 16#51#);\r
318                         elsif (spr_step_cnt = 15 * cpu_io_multi) then\r
319                             --set sprite attr=02\r
320                             io_out(16#2004#, 16#02#);\r
321                         elsif (spr_step_cnt = 16 * cpu_io_multi) then\r
322                             --set sprite data: x=45\r
323                             io_out(16#2004#, 45);\r
324 \r
325                         else\r
326                             io_brk;\r
327                             if (spr_step_cnt > 8 * cpu_io_multi) then\r
328                                 global_step_cnt := global_step_cnt + 2;\r
329                             end if;\r
330                         end if;\r
331                         spr_step_cnt := spr_step_cnt + 1;\r
332 \r
333                     elsif (global_step_cnt = 4) then\r
334                         --step3 = dma set.\r
335                         for i in 0 to 64 loop\r
336                             j := i * 4;\r
337                             if (ch = 16#5b#) then\r
338                                 ch := 16#41#;\r
339                             else\r
340                                 ch := 16#41# + i;\r
341                             end if;\r
342 \r
343                             --if (i < 64) then\r
344                             if (i < 10) then\r
345                                 --set dma value on the ram.\r
346                                 if    (dma_step_cnt = (0 + j) * cpu_io_multi) then\r
347                                     io_out(16#0200# + j, i);\r
348                                 elsif (dma_step_cnt = (1 + j) * cpu_io_multi) then\r
349                                     io_out(16#0201# + j, ch);\r
350                                 elsif (dma_step_cnt = (2 + j) * cpu_io_multi) then\r
351                                     io_out(16#0202# + j, 16#01#);\r
352                                 elsif (dma_step_cnt = (3 + j) * cpu_io_multi) then\r
353                                     io_out(16#0203# + j, j);\r
354                                 elsif (dma_step_cnt = (0 + j) * cpu_io_multi + 1) or\r
355                                         (dma_step_cnt = (1 + j) * cpu_io_multi + 1) or\r
356                                         (dma_step_cnt = (2 + j) * cpu_io_multi + 1) or\r
357                                         (dma_step_cnt = (3 + j) * cpu_io_multi + 1) then\r
358                                     io_brk;\r
359                                 end if;\r
360                             else\r
361                                 if    (dma_step_cnt = (0 + j) * cpu_io_multi) then\r
362                                     --start dma\r
363                                     io_out(16#4014#, 16#02#);\r
364                                 elsif (dma_step_cnt = (0 + j) * cpu_io_multi + 1) then\r
365                                     io_brk;\r
366                                 elsif (dma_step_cnt = (0 + j) * cpu_io_multi + 2) then\r
367                                     io_brk;\r
368                                     global_step_cnt := global_step_cnt + 1;\r
369                                 end if;\r
370                             end if;\r
371                         end loop;\r
372                         \r
373                         dma_step_cnt := dma_step_cnt + 1;\r
374 \r
375                     elsif (global_step_cnt = 5) then\r
376                         --step4 = scroll test and ppu reg read test.\r
377                         if (scl_step_cnt = 0) then\r
378                             --x scroll pos=123\r
379                             io_out(16#2005#, 11);\r
380                         elsif (scl_step_cnt = 1 * cpu_io_multi) then\r
381                             --y scroll pos=100\r
382                             io_out(16#2005#, 0);\r
383 \r
384                         elsif (scl_step_cnt = 2 * cpu_io_multi) then\r
385                             --read status reg.\r
386                             io_read(16#2002#);\r
387 \r
388                         elsif (scl_step_cnt = 3 * cpu_io_multi) then\r
389                             --read vram nt0.\r
390                             io_out(16#2006#, 16#20#);\r
391 \r
392                         elsif (scl_step_cnt = 4 * cpu_io_multi) then\r
393                             io_out(16#2006#, 16#03#);\r
394 \r
395                         elsif (scl_step_cnt = 5 * cpu_io_multi) then\r
396                             io_read(16#2007#);\r
397 \r
398                         elsif (scl_step_cnt = 6 * cpu_io_multi) then\r
399                             --pattern tbl.\r
400                             io_out(16#2006#, 16#04#);\r
401 \r
402                         elsif (scl_step_cnt = 7 * cpu_io_multi) then\r
403                             io_out(16#2006#, 16#d1#);\r
404 \r
405                         elsif (scl_step_cnt = 8 * cpu_io_multi) then\r
406                             io_read(16#2007#);\r
407 \r
408                         elsif (scl_step_cnt = 9 * cpu_io_multi) then\r
409                             --attr tbl.\r
410                             io_out(16#2006#, 16#23#);\r
411 \r
412                         elsif (scl_step_cnt = 10 * cpu_io_multi) then\r
413                             io_out(16#2006#, 16#c0#);\r
414 \r
415                         elsif (scl_step_cnt = 11 * cpu_io_multi) then\r
416                             --set attr first.\r
417                             io_out(16#2007#, 16#5a#);\r
418 \r
419                         elsif (scl_step_cnt = 12 * cpu_io_multi) then\r
420                             io_out(16#2006#, 16#23#);\r
421 \r
422                         elsif (scl_step_cnt = 13 * cpu_io_multi) then\r
423                             io_out(16#2006#, 16#c0#);\r
424 \r
425                         elsif (scl_step_cnt = 14 * cpu_io_multi) then\r
426                             io_read(16#2007#);\r
427 \r
428                         elsif (scl_step_cnt = 15 * cpu_io_multi) then\r
429                             --read palette tbl.\r
430                             io_out(16#2006#, 16#3f#);\r
431 \r
432                         elsif (scl_step_cnt = 16 * cpu_io_multi) then\r
433                             io_out(16#2006#, 16#11#);\r
434 \r
435                         elsif (scl_step_cnt = 17 * cpu_io_multi) then\r
436                             io_read(16#2007#);\r
437 \r
438                         else\r
439                             io_brk;\r
440                             if (scl_step_cnt > 17 * cpu_io_multi) then\r
441                                 global_step_cnt := global_step_cnt + 1;\r
442                             end if;\r
443                         end if;\r
444                         scl_step_cnt := scl_step_cnt + 1;\r
445 \r
446                     elsif (global_step_cnt = 6) then\r
447                         --final step = enable ppu.\r
448                         if (enable_ppu_step_cnt = 0 * cpu_io_multi) then\r
449                             --show bg\r
450                             --PPUMASK=1e (show bg and sprite)\r
451                             --PPUMASK=0e (show bg only)\r
452                             io_out(16#2001#, 16#1e#);\r
453                         elsif (enable_ppu_step_cnt = 1 * cpu_io_multi) then\r
454                             --enable nmi\r
455                             --PPUCTRL=80\r
456                             io_out(16#2000#, 16#80#);\r
457                         else\r
458                             io_brk;\r
459                             if (enable_ppu_step_cnt > 1 * cpu_io_multi) then\r
460                                 global_step_cnt := global_step_cnt + 1;\r
461                             end if;\r
462                         end if;\r
463                         enable_ppu_step_cnt := enable_ppu_step_cnt + 1;\r
464 \r
465                     elsif (global_step_cnt = 7) then\r
466                         ----nmi tests.....\r
467                         if (pi_nmi_n = '0') then\r
468 \r
469                             if (nmi_step_cnt = 0 * cpu_io_multi) then\r
470                                 --set sprite addr=00 (first sprite)\r
471                                 io_out(16#2003#, 16#03#);\r
472                             elsif (nmi_step_cnt = 1 * cpu_io_multi) then\r
473                                 --set sprite data: x=100\r
474                                 io_out(16#2004#, nmi_oam_x);\r
475                             elsif (nmi_step_cnt = 2 * cpu_io_multi) then\r
476                                 --scroll x=0\r
477 --                                io_out(16#2005#, nmi_scl_y);\r
478                                 io_brk;\r
479                             elsif (nmi_step_cnt = 3 * cpu_io_multi) then\r
480                                 --scroll y++\r
481 --                                io_out(16#2005#, nmi_scl_y);\r
482                                 io_brk;\r
483                             elsif (nmi_step_cnt = 4 * cpu_io_multi) then\r
484                                 --set sprite addr=00 (first sprite)\r
485                                 io_out(16#2003#, 16#04#);\r
486                             elsif (nmi_step_cnt = 5 * cpu_io_multi) then\r
487                                 --set sprite data: x=100\r
488                                 io_out(16#2004#, nmi_oam_x);\r
489                             else\r
490                                 if (ref_cnt = 0) then\r
491                                     nmi_oam_x := nmi_oam_x + 1;\r
492                                 end if;\r
493                                 if (nmi_step_cnt mod 10 = 0) then\r
494                                     nmi_scl_y := nmi_scl_y + 1;\r
495                                 end if;\r
496                                 io_brk;\r
497                                 if (nmi_step_cnt > 5 * cpu_io_multi) then\r
498                                     ref_cnt := ref_cnt + 1;\r
499                                     global_step_cnt := global_step_cnt + 1;\r
500                                 end if;\r
501                             end if;\r
502                             nmi_step_cnt := nmi_step_cnt + 1;\r
503                         end if;\r
504                     elsif (global_step_cnt = 8) then\r
505                         ----back to nmi tests.....\r
506                         if (pi_nmi_n = '1') then\r
507                             nmi_step_cnt := 0;\r
508                             global_step_cnt := global_step_cnt - 1;\r
509                         end if;\r
510                     else\r
511                         io_brk;\r
512                         init_done := '1';\r
513                     end if;\r
514                 end if;--if (init_done = '0') then\r
515             else\r
516                 po_r_nw <= 'Z';\r
517                 po_addr <= (others => 'Z');\r
518                 pio_d_io <= (others => 'Z');\r
519             end if;--if (rdy = '1') then\r
520             end if;--if (pi_cpu_en(0) = '1') then\r
521         end if; --if (rst_n = '0') then\r
522     end process;\r
523 \r
524 end rtl;\r
525 \r
526 \r
527 \r
528 \r
529 \r