Have a full cycle to load playfield and char data
[AtosmChip.git] / atari_tb.v
blob2aa8465e070f0bec1a58067dc0e5fa63ac75db94
1 // Atosm Chip
2 // Copyright (C) 2008 Tomasz Malesinski <tmal@mimuw.edu.pl>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 `include "clock.v"
19 `include "atari.v"
21 module atari_tb();
22 wire clk;
23 wire clk2;
25 reg rst_o;
27 reg [7:0] key_code;
28 reg key_pressed;
29 reg key_shift, key_break;
30 reg key_start, key_select, key_option;
31 reg [7:0] joystick;
32 reg [1:0] trig;
34 parameter monitor = 0;
36 initial begin
37 $readmemh("os/atarios.memh", u_atari.u_rom.memory);
39 key_code = 0;
40 key_pressed = 0;
41 key_shift = 0;
42 key_break = 0;
43 key_start = 0;
44 key_select = 0;
45 key_option = 0;
46 joystick = 0;
47 trig = 0;
49 if (monitor)
50 $monitor("%g\t pc=%h a=%h x=%h y=%h f=%b s=%h",
51 $time,
52 u_atari.u_cpu.pc,
53 u_atari.u_cpu.acc,
54 u_atari.u_cpu.regx,
55 u_atari.u_cpu.regy,
56 u_atari.u_cpu.regf,
57 u_atari.u_cpu.regs);
59 rst_o = 0;
60 #5 rst_o = 1;
61 #40 rst_o = 0;
62 #2_000_000_0;
63 $writememh("ram.memh", u_atari.u_ram.memory);
64 $finish;
65 end
67 always @ (posedge clk) begin
68 if (u_atari.adr >= 'hd000 && u_atari.adr < 'hd800) begin
69 if (u_atari.we)
70 $display("hardware write %h = %h at %h",
71 u_atari.adr, u_atari.masterdat_o, u_atari.u_cpu.pc);
72 else
73 $display("hardware read %h = %h at %h",
74 u_atari.adr, u_atari.slavedat_o, u_atari.u_cpu.pc);
75 end
76 end
78 clkgen u_clkgen(.clk_o(clk), .clk2_o(clk2));
79 atari u_atari(.clk_i(clk), .clk2_i(clk2), .rst_i(rst_o),
80 .key_code(key_code),
81 .key_pressed(key_pressed),
82 .key_shift(key_shift), .key_break(key_break),
83 .key_start(key_start), .key_select(key_select),
84 .key_option(key_option),
85 .joystick(joystick), .trig(trig));
87 endmodule