2 // Copyright (C) 2008 Tomasz Malesinski <tmal@mimuw.edu.pl>
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.
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
26 module atari(clk_i
, clk2_i
, rst_i
);
35 // Common interconnect signals.
38 reg [7:0] masterdat_o
;
45 wire [15:0] cpuadr_o
, anticadr_o
;
47 wire cpustb_o
, anticstb_o
;
49 wire cpucyc_o
, anticcyc_o
;
51 // Outputs from address decoder.
53 reg anticsel
, gtiasel
, pokeysel
, piasel
;
55 // Outputs from arbiter.
56 wire cpugnt
, anticgnt
;
58 // Slaves STB_I signals.
60 wire anticstb
, gtiastb
, pokeystb
, piastb
;
62 // Slaves DAT_O signals.
63 wire [7:0] ramdat_o
, romdat_o
;
64 wire [7:0] anticdat_o
, gtiadat_o
, pokeydat_o
, piadat_o
;
66 // Slaves ACK_O signals.
67 wire ramack_o
, romack_o
;
68 wire anticack_o
, gtiaack_o
, pokeyack_o
, piaack_o
;
73 assign cyc
= cpucyc_o | anticcyc_o
;
75 // Masters outputs multiplexer.
76 always @ (cpuadr_o
or cpudat_o
or cpuwe_o
or cpustb_o
or
77 anticadr_o
or anticstb_o
or
78 cpugnt
or anticgnt
) begin
86 masterdat_o
= cpudat_o
;
102 else if (adr
[15:8] == 'hd0
)
104 else if (adr
[15:8] == 'hd2
)
106 else if (adr
[15:8] == 'hd3
)
108 else if (adr
[15:8] == 'hd4
)
110 else if (adr
>= 'hc000
)
115 assign ramstb
= ramsel
& cyc
& stb
;
116 assign romstb
= romsel
& cyc
& stb
;
117 assign anticstb
= anticsel
& cyc
& stb
;
118 assign gtiastb
= gtiasel
& cyc
& stb
;
119 assign pokeystb
= pokeysel
& cyc
& stb
;
120 assign piastb
= piasel
& cyc
& stb
;
122 // Or'd slaves ACK_O.
123 assign ack
= ramack_o | romack_o | anticack_o | gtiaack_o |
124 pokeyack_o | piaack_o
;
126 // Slaves DAT_O multiplexer.
127 always @ (ramsel
or ramdat_o
or
128 romsel
or romdat_o
or
129 anticsel
or anticdat_o
or
130 gtiasel
or gtiadat_o
or
131 pokeysel
or pokeydat_o
or
134 slavedat_o
= ramdat_o
;
136 slavedat_o
= romdat_o
;
138 slavedat_o
= anticdat_o
;
140 slavedat_o
= gtiadat_o
;
142 slavedat_o
= pokeydat_o
;
144 slavedat_o
= piadat_o
;
148 defparam u_ram.size
= 'h4000
;
149 defparam u_ram.adrbits
= 14;
151 ram
u_ram(.
clk_i(clk_i
),
160 defparam u_rom.size
= 'h4000
;
161 defparam u_rom.adrbits
= 14;
163 rom
u_rom(.
clk_i(clk_i
),
170 cpu6502
u_cpu(.
clk_i(clk_i
),
179 antic
u_antic(.
clk_i(clk_i
),