2
0

v1.sv 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //
  2. // Top level module for the FPGA on the MAX80 board by
  3. // Per Mårtensson and H. Peter Anvin
  4. //
  5. // MAX80 v1
  6. //
  7. module v1
  8. (
  9. // Clock oscillator
  10. input clock_48, // 48 MHz
  11. input board_id, // This better match the firmware
  12. // ABC-bus
  13. input abc_clk, // ABC-bus 3 MHz clock
  14. input [15:0] abc_a, // ABC address bus
  15. inout [7:0] abc_d, // ABC data bus
  16. output abc_d_oe, // Data bus output enable
  17. input abc_rst_n, // ABC bus reset strobe
  18. input abc_cs_n, // ABC card select strobe
  19. input [4:0] abc_out_n, // OUT, C1-C4 strobe
  20. input [1:0] abc_inp_n, // INP, STATUS strobe
  21. input abc_xmemfl_n, // Memory read strobe
  22. input abc_xmemw800_n, // Memory write strobe (ABC800)
  23. input abc_xmemw80_n, // Memory write strobe (ABC80)
  24. input abc_xinpstb_n, // I/O read strobe (ABC800)
  25. input abc_xoutpstb_n, // I/O write strobe (ABC80)
  26. // The following are inverted versus the bus IF
  27. // the corresponding MOSFETs are installed
  28. output abc_rdy_x, // RDY = WAIT#
  29. output abc_resin_x, // System reset request
  30. output abc_int80_x, // System INT request (ABC80)
  31. output abc_int800_x, // System INT request (ABC800)
  32. output abc_nmi_x, // System NMI request (ABC800)
  33. output abc_xm_x, // System memory override (ABC800)
  34. // Host/device control
  35. output abc_host, // 1 = host, 0 = target
  36. output abc_a_oe,
  37. // Bus isolation
  38. output abc_d_ce_n,
  39. // ABC-bus extension header
  40. // (Note: cannot use an array here because HC and HH are
  41. // input only.)
  42. inout exth_ha,
  43. inout exth_hb,
  44. input exth_hc,
  45. inout exth_hd,
  46. inout exth_he,
  47. inout exth_hf,
  48. inout exth_hg,
  49. input exth_hh,
  50. // SDRAM bus
  51. output sr_clk,
  52. output sr_cke,
  53. output [1:0] sr_ba, // Bank address
  54. output [12:0] sr_a, // Address within bank
  55. inout [15:0] sr_dq, // Also known as D or IO
  56. output [1:0] sr_dqm, // DQML and DQMH
  57. output sr_cs_n,
  58. output sr_we_n,
  59. output sr_cas_n,
  60. output sr_ras_n,
  61. // SD card
  62. output sd_clk,
  63. output sd_cmd,
  64. inout [3:0] sd_dat,
  65. // Serial console (naming is FPGA as DCE)
  66. input tty_txd,
  67. output tty_rxd,
  68. input tty_rts,
  69. output tty_cts,
  70. input tty_dtr,
  71. // SPI flash memory (also configuration)
  72. output flash_cs_n,
  73. output flash_sck,
  74. inout [1:0] flash_io,
  75. // SPI bus (connected to ESP32 so can be bidirectional)
  76. inout spi_clk, // ESP32 IO12
  77. inout [1:0] spi_io, // ESP32 IO13,IO11
  78. inout spi_cs_esp_n, // ESP32 IO10
  79. inout spi_cs_flash_n, // ESP32 IO01
  80. // Other ESP32 connections
  81. inout esp_io0, // ESP32 IO00
  82. inout esp_int, // ESP32 IO09
  83. // I2C bus (RTC and external)
  84. inout i2c_scl,
  85. inout i2c_sda,
  86. input rtc_32khz,
  87. input rtc_int_n,
  88. // LED (2 = D23/G, 1 = D22/R, 0 = D17/B)
  89. output [2:0] led,
  90. // GPIO
  91. inout [5:0] gpio,
  92. // HDMI
  93. output [2:0] hdmi_d,
  94. output hdmi_clk,
  95. inout hdmi_scl,
  96. inout hdmi_sda,
  97. inout hdmi_hpd,
  98. // Unconnected pins with pullups, used for randomness
  99. inout [2:0] rngio
  100. );
  101. // ABC data bus isolation not supported or needed
  102. assign abc_d_ce_n = 1'b0;
  103. // This signal duplicates abc_host
  104. assign abc_a_oe = abc_host;
  105. // Permanently unused
  106. assign sd_dat[2:1] = 2'bzz;
  107. assign gpio[0] = 1'bz;
  108. assign gpio[2] = 1'bz;
  109. assign gpio[4] = 1'bz;
  110. // Always active
  111. assign sr_cke = 1'b1;
  112. // Master PLL: 48 -> 336 MHz
  113. wire reset_plls;
  114. wire master_pll_locked;
  115. wire master_clk; // 336 MHz
  116. wire slow_clk; // 12 MHz
  117. pll2_48 pll2 (
  118. .areset ( reset_plls ),
  119. .locked ( master_pll_locked ),
  120. .inclk0 ( clock_48 ),
  121. .c0 ( master_clk ),
  122. .c1 ( slow_clk )
  123. );
  124. max80 #(.x_mosfet(6'b111111),
  125. .fpga_ver(8'd1))
  126. max80 (
  127. .master_clk ( master_clk ),
  128. .slow_clk ( slow_clk ),
  129. .master_pll_locked ( master_pll_locked ),
  130. .reset_plls ( reset_plls ),
  131. .board_id ( board_id ),
  132. .abc_clk ( abc_clk ),
  133. .abc_a ( abc_a ),
  134. .abc_d ( abc_d ),
  135. .abc_d_oe ( abc_d_oe ),
  136. .abc_rst_n ( abc_rst_n ),
  137. .abc_cs_n ( abc_cs_n ),
  138. .abc_out_n ( abc_out_n ),
  139. .abc_inp_n ( abc_inp_n ),
  140. .abc_xmemfl_n ( abc_xmemfl_n ),
  141. .abc_xmemw800_n ( abc_xmemw800_n ),
  142. .abc_xmemw80_n ( abc_xmemw80_n ),
  143. .abc_xinpstb_n ( abc_xinpstb_n ),
  144. .abc_xoutpstb_n ( abc_xoutpstb_n ),
  145. .abc_rdy_x ( abc_rdy_x ),
  146. .abc_resin_x ( abc_resin_x ),
  147. .abc_int80_x ( abc_int80_x ),
  148. .abc_int800_x ( abc_int800_x ),
  149. .abc_nmi_x ( abc_nmi_x ),
  150. .abc_xm_x ( abc_xm_x ),
  151. .abc_host ( abc_host ),
  152. .exth_ha ( exth_ha ),
  153. .exth_hb ( exth_hb ),
  154. .exth_hc ( exth_hc ),
  155. .exth_hd ( exth_hd ),
  156. .exth_he ( exth_he ),
  157. .exth_hf ( exth_hf ),
  158. .exth_hg ( exth_hg ),
  159. .exth_hh ( exth_hh ),
  160. .sr_clk ( sr_clk ),
  161. .sr_ba ( sr_ba ),
  162. .sr_a ( sr_a ),
  163. .sr_dq ( sr_dq ),
  164. .sr_dqm ( sr_dqm ),
  165. .sr_cs_n ( sr_cs_n ),
  166. .sr_we_n ( sr_we_n ),
  167. .sr_cas_n ( sr_cas_n ),
  168. .sr_ras_n ( sr_ras_n ),
  169. .sd_cd_n ( 1'b0 ), // Card detect
  170. .sd_cs_n ( sd_dat[3] ),
  171. .sd_clk ( sd_clk ),
  172. .sd_di ( sd_cmd ),
  173. .sd_do ( sd_dat[0] ),
  174. .tty_txd ( tty_txd ),
  175. .tty_rxd ( tty_rxd ),
  176. .tty_rts ( tty_rts ),
  177. .tty_cts ( tty_cts ),
  178. .tty_dtr ( tty_dtr ),
  179. .flash_cs_n ( flash_cs_n ),
  180. .flash_sck ( flash_sck ),
  181. .flash_io ( flash_io ),
  182. .spi_clk ( spi_clk ),
  183. .spi_io ( spi_io ),
  184. .spi_cs_esp_n ( spi_cs_esp_n ),
  185. .spi_cs_flash_n ( spi_cs_flash_n ),
  186. .esp_io0 ( esp_io0 ),
  187. .esp_int ( esp_int ),
  188. .i2c_scl ( i2c_scl ),
  189. .i2c_sda ( i2c_sda ),
  190. .rtc_32khz ( rtc_32khz ),
  191. .rtc_int_n ( rtc_int_n ),
  192. .led ( led ),
  193. .usb_dp ( gpio[3] ),
  194. .usb_dn ( gpio[5] ),
  195. .usb_rx ( 1'bx ),
  196. .usb_rx_ok ( 1'b0 ),
  197. .usb_pu ( gpio[1] ),
  198. .hdmi_d ( hdmi_d ),
  199. .hdmi_clk ( hdmi_clk ),
  200. .hdmi_scl ( hdmi_scl ),
  201. .hdmi_sda ( hdmi_sda ),
  202. .hdmi_hpd ( hdmi_hpd ),
  203. .rngio ( rngio )
  204. );
  205. endmodule // v1