|
@@ -10,93 +10,93 @@
|
|
|
|
|
|
module max80 (
|
|
module max80 (
|
|
// Clock oscillator
|
|
// Clock oscillator
|
|
- input clock_48, // 48 MHz
|
|
|
|
|
|
+ input clock_48, // 48 MHz
|
|
|
|
|
|
// ABC-bus
|
|
// ABC-bus
|
|
- input abc_clk, // ABC-bus 3 MHz clock
|
|
|
|
|
|
+ input abc_clk, // ABC-bus 3 MHz clock
|
|
input [15:0] abc_a, // ABC address bus
|
|
input [15:0] abc_a, // ABC address bus
|
|
inout [7:0] abc_d, // ABC data bus
|
|
inout [7:0] abc_d, // ABC data bus
|
|
- output abc_d_oe, // Data bus output enable
|
|
|
|
- input abc_rst_n, // ABC bus reset strobe
|
|
|
|
- input abc_cs_n, // ABC card select strobe
|
|
|
|
|
|
+ output abc_d_oe, // Data bus output enable
|
|
|
|
+ input abc_rst_n, // ABC bus reset strobe
|
|
|
|
+ input abc_cs_n, // ABC card select strobe
|
|
input [4:0] abc_out_n, // OUT, C1-C4 strobe
|
|
input [4:0] abc_out_n, // OUT, C1-C4 strobe
|
|
input [1:0] abc_inp_n, // INP, STATUS strobe
|
|
input [1:0] abc_inp_n, // INP, STATUS strobe
|
|
- input abc_xmemfl_n, // Memory read strobe
|
|
|
|
- input abc_xmemw800_n, // Memory write strobe (ABC800)
|
|
|
|
- input abc_xmemw80_n, // Memory write strobe (ABC80)
|
|
|
|
- input abc_xinpstb_n, // I/O read strobe (ABC800)
|
|
|
|
- input abc_xoutpstb_n, // I/O write strobe (ABC80)
|
|
|
|
|
|
+ input abc_xmemfl_n, // Memory read strobe
|
|
|
|
+ input abc_xmemw800_n, // Memory write strobe (ABC800)
|
|
|
|
+ input abc_xmemw80_n, // Memory write strobe (ABC80)
|
|
|
|
+ input abc_xinpstb_n, // I/O read strobe (ABC800)
|
|
|
|
+ input abc_xoutpstb_n, // I/O write strobe (ABC80)
|
|
// The following are inverted versus the bus IF
|
|
// The following are inverted versus the bus IF
|
|
// the corresponding MOSFETs are installed
|
|
// the corresponding MOSFETs are installed
|
|
- output abc_rdy_x, // RDY = WAIT#
|
|
|
|
- output abc_resin_x, // System reset request
|
|
|
|
- output abc_int80_x, // System INT request (ABC80)
|
|
|
|
- output abc_int800_x, // System INT request (ABC800)
|
|
|
|
- output abc_nmi_x, // System NMI request (ABC800)
|
|
|
|
- output abc_xm_x, // System memory override (ABC800)
|
|
|
|
|
|
+ output abc_rdy_x, // RDY = WAIT#
|
|
|
|
+ output abc_resin_x, // System reset request
|
|
|
|
+ output abc_int80_x, // System INT request (ABC80)
|
|
|
|
+ output abc_int800_x, // System INT request (ABC800)
|
|
|
|
+ output abc_nmi_x, // System NMI request (ABC800)
|
|
|
|
+ output abc_xm_x, // System memory override (ABC800)
|
|
// Master/slave control
|
|
// Master/slave control
|
|
- output abc_master, // 1 = master, 0 = slave
|
|
|
|
- output abc_a_oe,
|
|
|
|
|
|
+ output abc_master, // 1 = master, 0 = slave
|
|
|
|
+ output abc_a_oe,
|
|
// Bus isolation
|
|
// Bus isolation
|
|
- output abc_d_ce_n,
|
|
|
|
|
|
+ output abc_d_ce_n,
|
|
|
|
|
|
// ABC-bus extension header
|
|
// ABC-bus extension header
|
|
// (Note: cannot use an array here because HC and HH are
|
|
// (Note: cannot use an array here because HC and HH are
|
|
// input only.)
|
|
// input only.)
|
|
- inout exth_ha,
|
|
|
|
- inout exth_hb,
|
|
|
|
- input exth_hc,
|
|
|
|
- inout exth_hd,
|
|
|
|
- inout exth_he,
|
|
|
|
- inout exth_hf,
|
|
|
|
- inout exth_hg,
|
|
|
|
- input exth_hh,
|
|
|
|
|
|
+ inout exth_ha,
|
|
|
|
+ inout exth_hb,
|
|
|
|
+ input exth_hc,
|
|
|
|
+ inout exth_hd,
|
|
|
|
+ inout exth_he,
|
|
|
|
+ inout exth_hf,
|
|
|
|
+ inout exth_hg,
|
|
|
|
+ input exth_hh,
|
|
|
|
|
|
// SDRAM bus
|
|
// SDRAM bus
|
|
- output sr_clk,
|
|
|
|
- output sr_cke,
|
|
|
|
|
|
+ output sr_clk,
|
|
|
|
+ output sr_cke,
|
|
output [1:0] sr_ba, // Bank address
|
|
output [1:0] sr_ba, // Bank address
|
|
output [12:0] sr_a, // Address within bank
|
|
output [12:0] sr_a, // Address within bank
|
|
inout [15:0] sr_dq, // Also known as D or IO
|
|
inout [15:0] sr_dq, // Also known as D or IO
|
|
output [1:0] sr_dqm, // DQML and DQMH
|
|
output [1:0] sr_dqm, // DQML and DQMH
|
|
- output sr_cs_n,
|
|
|
|
- output sr_we_n,
|
|
|
|
- output sr_cas_n,
|
|
|
|
- output sr_ras_n,
|
|
|
|
|
|
+ output sr_cs_n,
|
|
|
|
+ output sr_we_n,
|
|
|
|
+ output sr_cas_n,
|
|
|
|
+ output sr_ras_n,
|
|
|
|
|
|
// SD card
|
|
// SD card
|
|
- output sd_clk,
|
|
|
|
- output sd_cmd,
|
|
|
|
|
|
+ output sd_clk,
|
|
|
|
+ output sd_cmd,
|
|
inout [3:0] sd_dat,
|
|
inout [3:0] sd_dat,
|
|
|
|
|
|
// USB serial (naming is FPGA as DCE)
|
|
// USB serial (naming is FPGA as DCE)
|
|
- input tty_txd,
|
|
|
|
- output tty_rxd,
|
|
|
|
- input tty_rts,
|
|
|
|
- output tty_cts,
|
|
|
|
- input tty_dtr,
|
|
|
|
|
|
+ input tty_txd,
|
|
|
|
+ output tty_rxd,
|
|
|
|
+ input tty_rts,
|
|
|
|
+ output tty_cts,
|
|
|
|
+ input tty_dtr,
|
|
|
|
|
|
// SPI flash memory (also configuration)
|
|
// SPI flash memory (also configuration)
|
|
- output flash_cs_n,
|
|
|
|
- output flash_sck,
|
|
|
|
|
|
+ output flash_cs_n,
|
|
|
|
+ output flash_sck,
|
|
inout [1:0] flash_io,
|
|
inout [1:0] flash_io,
|
|
|
|
|
|
// SPI bus (connected to ESP32 so can be bidirectional)
|
|
// SPI bus (connected to ESP32 so can be bidirectional)
|
|
- inout spi_clk,
|
|
|
|
- inout spi_miso,
|
|
|
|
- inout spi_mosi,
|
|
|
|
- inout spi_cs_esp_n, // ESP32 IO10
|
|
|
|
- inout spi_cs_flash_n, // ESP32 IO01
|
|
|
|
|
|
+ inout spi_clk,
|
|
|
|
+ inout spi_miso,
|
|
|
|
+ inout spi_mosi,
|
|
|
|
+ inout spi_cs_esp_n, // ESP32 IO10
|
|
|
|
+ inout spi_cs_flash_n, // ESP32 IO01
|
|
|
|
|
|
// Other ESP32 connections
|
|
// Other ESP32 connections
|
|
- inout esp_io0, // ESP32 IO00
|
|
|
|
- inout esp_int, // ESP32 IO09
|
|
|
|
|
|
+ inout esp_io0, // ESP32 IO00
|
|
|
|
+ inout esp_int, // ESP32 IO09
|
|
|
|
|
|
// I2C bus (RTC and external)
|
|
// I2C bus (RTC and external)
|
|
- inout i2c_scl,
|
|
|
|
- inout i2c_sda,
|
|
|
|
- input rtc_32khz,
|
|
|
|
- input rtc_int_n,
|
|
|
|
|
|
+ inout i2c_scl,
|
|
|
|
+ inout i2c_sda,
|
|
|
|
+ input rtc_32khz,
|
|
|
|
+ input rtc_int_n,
|
|
|
|
|
|
// LED (2 = D23/G, 1 = D22/R, 0 = D17/B)
|
|
// LED (2 = D23/G, 1 = D22/R, 0 = D17/B)
|
|
output [2:0] led,
|
|
output [2:0] led,
|
|
@@ -106,10 +106,10 @@ module max80 (
|
|
|
|
|
|
// HDMI
|
|
// HDMI
|
|
output [2:0] hdmi_d,
|
|
output [2:0] hdmi_d,
|
|
- output hdmi_clk,
|
|
|
|
- inout hdmi_scl,
|
|
|
|
- inout hdmi_sda,
|
|
|
|
- inout hdmi_hpd
|
|
|
|
|
|
+ output hdmi_clk,
|
|
|
|
+ inout hdmi_scl,
|
|
|
|
+ inout hdmi_sda,
|
|
|
|
+ inout hdmi_hpd
|
|
);
|
|
);
|
|
|
|
|
|
// Set if MOSFETs Q1-Q6 are installed rather than the corresponding
|
|
// Set if MOSFETs Q1-Q6 are installed rather than the corresponding
|
|
@@ -130,7 +130,7 @@ module max80 (
|
|
wire vid_hdmiclk; // D:o in the HDMI clock domain
|
|
wire vid_hdmiclk; // D:o in the HDMI clock domain
|
|
wire flash_clk; // Serial flash ROM clock
|
|
wire flash_clk; // Serial flash ROM clock
|
|
|
|
|
|
- reg reset_cmd_q = 1'b0;
|
|
|
|
|
|
+ reg reset_cmd_q = 1'b0;
|
|
wire reset_cmd;
|
|
wire reset_cmd;
|
|
|
|
|
|
pll pll (
|
|
pll pll (
|
|
@@ -458,11 +458,6 @@ module max80 (
|
|
.wacc2 ( sdram_rom_wacc )
|
|
.wacc2 ( sdram_rom_wacc )
|
|
);
|
|
);
|
|
|
|
|
|
- // SD card
|
|
|
|
- assign sd_clk = 1'b1;
|
|
|
|
- assign sd_cmd = 1'b1;
|
|
|
|
- assign sd_dat = 4'hz;
|
|
|
|
-
|
|
|
|
// SPI bus (free for ESP32)
|
|
// SPI bus (free for ESP32)
|
|
assign spi_clk = 1'bz;
|
|
assign spi_clk = 1'bz;
|
|
assign spi_miso = 1'bz;
|
|
assign spi_miso = 1'bz;
|
|
@@ -545,13 +540,15 @@ module max80 (
|
|
sdram_rdata <= sdram_rd;
|
|
sdram_rdata <= sdram_rd;
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ tri1 [15:0] iodev_wait_n;
|
|
|
|
+
|
|
always @(*)
|
|
always @(*)
|
|
case ( cpu_mem_quad )
|
|
case ( cpu_mem_quad )
|
|
4'b0000: cpu_mem_ready = 1'b0;
|
|
4'b0000: cpu_mem_ready = 1'b0;
|
|
4'b0001: cpu_mem_ready = 1'b1;
|
|
4'b0001: cpu_mem_ready = 1'b1;
|
|
4'b0010: cpu_mem_ready = sdram_mem_ready;
|
|
4'b0010: cpu_mem_ready = sdram_mem_ready;
|
|
4'b0100: cpu_mem_ready = 1'b1;
|
|
4'b0100: cpu_mem_ready = 1'b1;
|
|
- 4'b1000: cpu_mem_ready = 1'b1;
|
|
|
|
|
|
+ 4'b1000: cpu_mem_ready = &iodev_wait_n;
|
|
default: cpu_mem_ready = 1'bx;
|
|
default: cpu_mem_ready = 1'bx;
|
|
endcase // case ( mem_quad )
|
|
endcase // case ( mem_quad )
|
|
|
|
|
|
@@ -574,7 +571,7 @@ module max80 (
|
|
.rdata ( fast_mem_rdata )
|
|
.rdata ( fast_mem_rdata )
|
|
);
|
|
);
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
// Input data MUX
|
|
// Input data MUX
|
|
wire [31:0] iodev_rdata;
|
|
wire [31:0] iodev_rdata;
|
|
|
|
|
|
@@ -599,14 +596,14 @@ module max80 (
|
|
led_q <= cpu_mem_wdata[2:0];
|
|
led_q <= cpu_mem_wdata[2:0];
|
|
|
|
|
|
assign led = led_q;
|
|
assign led = led_q;
|
|
-
|
|
|
|
|
|
+
|
|
//
|
|
//
|
|
// Serial ROM (also configuration ROM.) Fast hardwired data download
|
|
// Serial ROM (also configuration ROM.) Fast hardwired data download
|
|
// unit to SDRAM.
|
|
// unit to SDRAM.
|
|
//
|
|
//
|
|
wire rom_done;
|
|
wire rom_done;
|
|
- reg rom_done_q;
|
|
|
|
-
|
|
|
|
|
|
+ reg rom_done_q;
|
|
|
|
+
|
|
spirom ddu (
|
|
spirom ddu (
|
|
.rst_n ( rst_n ),
|
|
.rst_n ( rst_n ),
|
|
.rom_clk ( flash_clk ),
|
|
.rom_clk ( flash_clk ),
|
|
@@ -625,7 +622,7 @@ module max80 (
|
|
|
|
|
|
always @(posedge sys_clk)
|
|
always @(posedge sys_clk)
|
|
rom_done_q <= rom_done;
|
|
rom_done_q <= rom_done;
|
|
-
|
|
|
|
|
|
+
|
|
//
|
|
//
|
|
// Serial port. Direct to the CP2102N for reworked
|
|
// Serial port. Direct to the CP2102N for reworked
|
|
// boards or to GPIO for non-reworked boards, depending on
|
|
// boards or to GPIO for non-reworked boards, depending on
|
|
@@ -683,15 +680,39 @@ module max80 (
|
|
assign tty_cts = tty_dtr_q[0] ? 1'bz : tty_cts_out;
|
|
assign tty_cts = tty_dtr_q[0] ? 1'bz : tty_cts_out;
|
|
assign gpio[3] = tty_dtr_q[1] ? 1'bz : tty_cts_out;
|
|
assign gpio[3] = tty_dtr_q[1] ? 1'bz : tty_cts_out;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // SD card
|
|
|
|
+ wire [31:0] sdcard_rdata;
|
|
|
|
+
|
|
|
|
+ sdcard sdcard (
|
|
|
|
+ .rst_n ( rst_n ),
|
|
|
|
+ .clk ( sys_clk ),
|
|
|
|
+ .sd_cs_n ( sd_dat[3] ),
|
|
|
|
+ .sd_di ( sd_cmd ),
|
|
|
|
+ .sd_sclk ( sd_clk ),
|
|
|
|
+ .sd_do ( sd_dat[0] ),
|
|
|
|
+ .sd_cd_n ( 1'b0 ),
|
|
|
|
+ .sd_we_n ( 1'b0 ),
|
|
|
|
+
|
|
|
|
+ .wdata ( cpu_mem_wdata ),
|
|
|
|
+ .rdata ( sdcard_rdata ),
|
|
|
|
+ .valid ( iodev[4] ),
|
|
|
|
+ .wstrb ( cpu_mem_wstrb ),
|
|
|
|
+ .addr ( cpu_mem_addr[3:2] ),
|
|
|
|
+ .wait_n ( iodev_wait_n[4] )
|
|
|
|
+ );
|
|
|
|
+ assign sd_dat[2:1] = 2'bzz;
|
|
|
|
+
|
|
//
|
|
//
|
|
// I/O device input data MUX
|
|
// I/O device input data MUX
|
|
//
|
|
//
|
|
always @(*)
|
|
always @(*)
|
|
case ( cpu_mem_addr[9:6] )
|
|
case ( cpu_mem_addr[9:6] )
|
|
- 4'h0: iodev_rdata = { 29'b0, led_q };
|
|
|
|
- 4'h2: iodev_rdata = { 31'b0, rom_done_q };
|
|
|
|
- 4'h3: iodev_rdata = tty_rdata;
|
|
|
|
- default: iodev_rdata = 32'hffff_ffff;
|
|
|
|
|
|
+ 4'h0: iodev_rdata = { 29'b0, led_q };
|
|
|
|
+ 4'h2: iodev_rdata = { 31'b0, rom_done_q };
|
|
|
|
+ 4'h3: iodev_rdata = tty_rdata;
|
|
|
|
+ 4'h4: iodev_rdata = sdcard_rdata;
|
|
|
|
+ default: iodev_rdata = 32'h0;
|
|
endcase
|
|
endcase
|
|
-
|
|
|
|
|
|
+
|
|
endmodule
|
|
endmodule
|