Skip to content

Commit

Permalink
Mapped QSPI outputs to match the pinout of QSPI-PMOD by mole99
Browse files Browse the repository at this point in the history
  • Loading branch information
rejunity committed Oct 31, 2024
1 parent c56f656 commit c4251c1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 27 deletions.
36 changes: 18 additions & 18 deletions fpga/icebreaker.v
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ module top (


`ifdef QSPI_ROM
assign FLASH_SCK = pmod2_out[4];
assign FLASH_SSB = pmod2_out[5];
assign FLASH_SCK = pmod2_out[3];
assign FLASH_SSB = pmod2_out[0];

// FLASH_IO1..IO3 are bidirectional pins
// iCE40 IO are documented in Lattice iCE40 Family Handbook
Expand All @@ -200,47 +200,47 @@ module top (
.PULLUP(1'b0)
) io0 (
.PACKAGE_PIN(FLASH_IO0),
.OUTPUT_ENABLE(pmod2_oe[0]),
.D_OUT_0(pmod2_out[0]),
.D_IN_0(pmod2_in[0])
.OUTPUT_ENABLE(pmod2_oe[1]),
.D_OUT_0(pmod2_out[1]),
.D_IN_0(pmod2_in[1])
);

SB_IO #(
.PIN_TYPE(6'b1010_01), // Tri-state buffer with bidirectional control, not registered
.PULLUP(1'b0)
) io1 (
.PACKAGE_PIN(FLASH_IO1),
.OUTPUT_ENABLE(pmod2_oe[1]),
.D_OUT_0(pmod2_out[1]),
.D_IN_0(pmod2_in[1])
.OUTPUT_ENABLE(pmod2_oe[2]),
.D_OUT_0(pmod2_out[2]),
.D_IN_0(pmod2_in[2])
);

SB_IO #(
.PIN_TYPE(6'b1010_01), // Tri-state buffer with bidirectional control, not registered
.PULLUP(1'b0)
) io2 (
.PACKAGE_PIN(FLASH_IO2),
.OUTPUT_ENABLE(pmod2_oe[2]),
.D_OUT_0(pmod2_out[2]),
.D_IN_0(pmod2_in[2])
.OUTPUT_ENABLE(pmod2_oe[4]),
.D_OUT_0(pmod2_out[4]),
.D_IN_0(pmod2_in[4])
);

SB_IO #(
.PIN_TYPE(6'b1010_01), // Tri-state buffer with bidirectional control, not registered
.PULLUP(1'b0)
) io3 (
.PACKAGE_PIN(FLASH_IO3),
.OUTPUT_ENABLE(pmod2_oe[3]),
.D_OUT_0(pmod2_out[3]),
.D_IN_0(pmod2_in[3])
.OUTPUT_ENABLE(pmod2_oe[5]),
.D_OUT_0(pmod2_out[5]),
.D_IN_0(pmod2_in[5])
);

`elsif QSPI_ROM_EMU
qspi_rom_emu qspi_rom(
.clk (pmod2_out[4]),
.select (pmod2_out[5]),
.cmd_addr_in(pmod2_out[3:0]),
.data_out (pmod2_in [3:0]));
.clk (pmod2_out[3]),
.select (pmod2_out[0]),
.cmd_addr_in({pmod2_out[5:4], pmod2_out[2:1]}),
.data_out ({pmod2_in [5:4], pmod2_in [2:1]}));

`else
assign pmod2_in = 8'b0000_0000;
Expand Down
28 changes: 23 additions & 5 deletions src/tt_um_rejunity_atari2600.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,32 @@ module tt_um_rejunity_atari2600 (
assign uo_out = {hsync, B[0], G[0], R[0], vsync, B[1], G[1], R[1]};
`endif

// Audio PMOD + ROM SPI
// ROM QSPI + Audio PMODs
// QSPI PMod: https://github.com/mole99/qspi-pmod
// - PMOD1 uio[0] CS0 (@TODO: validate this one is Flash)
// - PMOD2 uio[1] SD0/MOSI
// - PMOD3 uio[2] SD1/MISO
// - PMOD4 uio[3] SCK
// - PMOD5 uio[4] SD2
// - PMOD6 uio[5] SD3
// - PMOD7 uio[6] CS1
// - PMOD8 uio[7] CS2
// Audio PMOD: https://github.com/MichaelBell/tt-audio-pmod
// - PMOD8 uio[7] PWM Audio
// 1 bidirectional pin is unused (tia_vsync for diagostics in Verilator)
// TODO: output video_active for DVI instead
// @TODO: output video_active for DVI instead
// @TODO: validate with Digilent SDCard PMOD as well
// - PMOD1 uio[0] ~CS/DAT3
// - PMOD2 uio[1] MOSI
// - PMOD3 uio[2] MISO
// - PMOD4 uio[3] SCK
// - PMOD5 uio[4] DAT1
// - PMOD6 uio[5] DAT2
`ifdef QSPI_ROM
assign uio_out = {audio_pwm, tia_vsync, spi_select, spi_clk_out, spi_data_out};
assign uio_oe = { 1'b1, 1'b1, 1'b1, 1'b1, spi_data_oe};
assign uio_out = {audio_pwm, tia_vsync, spi_data_out[3:2], spi_clk_out, spi_data_out[1:0], spi_select};
assign uio_oe = { 1'b1, 1'b1, spi_data_oe[3:2], 1'b1, spi_data_oe[1:0], 1'b1};
wire [3:0] switches = 4'b1111;
assign spi_data_in = uio_in[3:0];
assign spi_data_in = {uio_in[5:4], uio_in[2:1]};
`else
assign uio_out = {audio_pwm, tia_vsync, 6'b000000};
assign uio_oe = { 1'b1, 1'b1, 6'b000000};
Expand Down
8 changes: 4 additions & 4 deletions verilator/top.v
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ module top (

`ifdef QSPI_ROM
qspi_rom_emu qspi_rom(
.clk (pmod2_out[4]),
.select (pmod2_out[5]),
.cmd_addr_in(pmod2_out[3:0]),
.data_out (pmod2_in [3:0]));
.clk (pmod2_out[3]),
.select (pmod2_out[0]),
.cmd_addr_in({pmod2_out[5:4], pmod2_out[2:1]}),
.data_out ({pmod2_in [5:4], pmod2_in [2:1]}));
assign tia_vblank = 0; // not enough pins
`else
assign pmod2_in = {4'b0000, sw4, sw3, sw2, sw1};
Expand Down

0 comments on commit c4251c1

Please sign in to comment.