From 42334e0be29331cd0effb903aaad0abfdc83df53 Mon Sep 17 00:00:00 2001 From: Tomek Malesinski Date: Sat, 19 Jul 2008 22:03:40 +0200 Subject: [PATCH] Initial (dummy) arbiter. --- antic.v | 31 +++++++++++-- atari.v | 155 +++++++++++++++++++++++++++++++++++++++++-------------------- atari_tb.v | 4 +- cpu6502.v | 1 + 4 files changed, 135 insertions(+), 56 deletions(-) diff --git a/antic.v b/antic.v index 92b8c5c..ef2892a 100644 --- a/antic.v +++ b/antic.v @@ -16,11 +16,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module antic(rst_i, clk_i, - adr_i, + adr_i, adr_o, dat_i, dat_o, we_i, - stb_i, - ack_o, + stb_i, stb_o, + ack_i, ack_o, clk2_i); input rst_i; input clk_i; @@ -28,9 +28,12 @@ module antic(rst_i, clk_i, input dat_i; input we_i; input stb_i; + input ack_i; input clk2_i; + output adr_o; output dat_o; + output stb_o; output ack_o; wire rst_i, clk_i; @@ -38,9 +41,12 @@ module antic(rst_i, clk_i, wire [7:0] dat_i; wire we_i; wire stb_i; + wire ack_i; wire clk2_i; + reg [15:0] adr_o; reg [7:0] dat_o; + reg stb_o; wire ack_o; reg [1:0] dma_pf_width; @@ -61,6 +67,13 @@ module antic(rst_i, clk_i, reg [7:0] hcount; reg [8:0] vcount; + reg [1:0] adro_sel; + + parameter [1:0] ADRO_DLPTR = 2'b00; + parameter [1:0] ADRO_MEMSCAN = 2'b01; + parameter [1:0] ADRO_CHAR = 2'b10; + parameter [1:0] ADRO_PM = 2'b11; + assign ack_o = stb_i; always @ (adr_i) @@ -149,4 +162,16 @@ module antic(rst_i, clk_i, else vcount <= vcount + 1; + always @ (adro_sel) + case (adro_sel) + ADRO_DLPTR: + begin end + ADRO_MEMSCAN: + begin end + ADRO_CHAR: + begin end + ADRO_PM: + begin end + endcase + endmodule diff --git a/atari.v b/atari.v index 8d9e2d3..fdc293a 100644 --- a/atari.v +++ b/atari.v @@ -32,66 +32,118 @@ module atari(clk_i, clk2_i, rst_i); wire clk2_i; wire rst_i; - wire [15:0] adr; - reg [7:0] cpudat_i; + // Common interconnect signals. + reg [15:0] adr; + reg [7:0] slavedat_o; + reg [7:0] masterdat_o; + reg stb; + reg we; + wire ack; + wire cyc; + + // Masters outputs. + wire [15:0] cpuadr_o, anticadr_o; wire [7:0] cpudat_o; - wire cpustb; - wire we; - wire ack; - - reg ramstb, romstb; - reg anticstb, gtiastb, pokeystb, piastb; - - wire [7:0] ramdat_o, romdat_o; - wire [7:0] anticdat_o, gtiadat_o, pokeydat_o, piadat_o; - - wire ramack_o, romack_o; - wire anticack_o, gtiaack_o, pokeyack_o, piaack_o; + wire cpustb_o, anticstb_o; + wire cpuwe_o; + wire cpucyc_o, anticcyc_o; + + // Outputs from address decoder. + reg ramsel, romsel; + reg anticsel, gtiasel, pokeysel, piasel; + + // Outputs from arbiter. + wire cpugnt, anticgnt; + + // Slaves STB_I signals. + wire ramstb, romstb; + wire anticstb, gtiastb, pokeystb, piastb; + + // Slaves DAT_O signals. + wire [7:0] ramdat_o, romdat_o; + wire [7:0] anticdat_o, gtiadat_o, pokeydat_o, piadat_o; + + // Slaves ACK_O signals. + wire ramack_o, romack_o; + wire anticack_o, gtiaack_o, pokeyack_o, piaack_o; + + // Arbiter. + assign cpugnt = 1; + assign anticgnt = 0; + assign cyc = cpucyc_o | anticcyc_o; + + // Masters outputs multiplexer. + always @ (cpuadr_o or cpudat_o or cpuwe_o or cpustb_o or + anticadr_o or anticstb_o or + cpugnt or anticgnt) begin + if (anticgnt) begin + adr = anticadr_o; + masterdat_o = 0; + we = 0; + stb = anticstb_o; + end else begin + adr = cpuadr_o; + masterdat_o = cpudat_o; + we = cpuwe_o; + stb = cpustb_o; + end + end + // Address decoder. always @ (adr) begin - ramstb = 0; - romstb = 0; - anticstb = 0; - gtiastb = 0; - pokeystb = 0; - anticstb = 0; + ramsel = 0; + romsel = 0; + anticsel = 0; + gtiasel = 0; + pokeysel = 0; + anticsel = 0; if (adr < 'h4000) - ramstb = 1; + ramsel = 1; else if (adr[15:8] == 'hd0) - gtiastb = 1; + gtiasel = 1; else if (adr[15:8] == 'hd2) - pokeystb = 1; + pokeysel = 1; else if (adr[15:8] == 'hd3) - piastb = 1; + piasel = 1; else if (adr[15:8] == 'hd4) - anticstb = 1; + anticsel = 1; else if (adr >= 'hc000) - romstb = 1; + romsel = 1; end - assign ack = ramack_o | romack_o | anticack_o | gtiaack_o | - pokeyack_o | piaack_o; - - always @ (ramstb or ramdat_o or - romstb or romdat_o or - anticstb or anticdat_o or - gtiastb or gtiadat_o or - pokeystb or pokeydat_o or - piastb or piadat_o) - if (ramstb) - cpudat_i = ramdat_o; - else if (romstb) - cpudat_i = romdat_o; - else if (anticstb) - cpudat_i = anticdat_o; - else if (gtiastb) - cpudat_i = gtiadat_o; - else if (pokeystb) - cpudat_i = pokeydat_o; - else if (piastb) - cpudat_i = piadat_o; + // Slaves STB_I. + assign ramstb = ramsel & cyc & stb; + assign romstb = romsel & cyc & stb; + assign anticstb = anticsel & cyc & stb; + assign gtiastb = gtiasel & cyc & stb; + assign pokeystb = pokeysel & cyc & stb; + assign piastb = piasel & cyc & stb; + + // Or'd slaves ACK_O. + assign ack = ramack_o | romack_o | anticack_o | gtiaack_o | + pokeyack_o | piaack_o; + + // Slaves DAT_O multiplexer. + always @ (ramsel or ramdat_o or + romsel or romdat_o or + anticsel or anticdat_o or + gtiasel or gtiadat_o or + pokeysel or pokeydat_o or + piasel or piadat_o) + if (ramsel) + slavedat_o = ramdat_o; + else if (romsel) + slavedat_o = romdat_o; + else if (anticsel) + slavedat_o = anticdat_o; + else if (gtiasel) + slavedat_o = gtiadat_o; + else if (pokeysel) + slavedat_o = pokeydat_o; + else if (piasel) + slavedat_o = piadat_o; else - cpudat_i = 'hff; + slavedat_o = 'hff; defparam u_ram.size = 'h4000; defparam u_ram.adrbits = 14; @@ -116,16 +168,17 @@ module atari(clk_i, clk2_i, rst_i); .dat_o(romdat_o)); cpu6502 u_cpu(.clk_i(clk_i), - .adr_o(adr), - .dat_i(cpudat_i), + .adr_o(cpuadr_o), + .dat_i(slavedat_o), .rst_i(rst_i), .stb_o(cpustb), - .we_o(we), + .we_o(cpuwe_o), .ack_i(ack), .dat_o(cpudat_o)); antic u_antic(.clk_i(clk_i), .adr_i(adr[3:0]), + .adr_o(anticadr_o), .dat_i(cpudat_o), .rst_i(rst_i), .stb_i(anticstb), diff --git a/atari_tb.v b/atari_tb.v index 1c172bd..910c64a 100644 --- a/atari_tb.v +++ b/atari_tb.v @@ -50,10 +50,10 @@ module atari_tb(); if (u_atari.adr >= 'hd000 && u_atari.adr < 'hd800) begin if (u_atari.we) $display("hardware write %h = %h at %h", - u_atari.adr, u_atari.cpudat_i, u_atari.u_cpu.pc); + u_atari.adr, u_atari.slavedat_o, u_atari.u_cpu.pc); else $display("hardware read %h = %h at %h", - u_atari.adr, u_atari.cpudat_o, u_atari.u_cpu.pc); + u_atari.adr, u_atari.masterdat_o, u_atari.u_cpu.pc); end end diff --git a/cpu6502.v b/cpu6502.v index 092a7b1..408f74d 100644 --- a/cpu6502.v +++ b/cpu6502.v @@ -17,6 +17,7 @@ // TODO: separate decoding of addressing mode and execution of instruction // TODO: constants for opcodes +// TODO: on RESET, stb_o and cyc_o=0 (Wishbonem p.38) module cpu6502_alu(a, b, op, out, cin, cout, vout, d); input a; -- 2.11.4.GIT