1
0

FPGC.v 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. /*
  2. * Top level design of the FPGC
  3. */
  4. module FPGC(
  5. input clock, //50MHz
  6. input nreset, nBtnl, nBtnr,
  7. //HDMI
  8. output [3:0] TMDS_p,
  9. output [3:0] TMDS_n,
  10. //NTSC composite video signal
  11. output [7:0] composite,
  12. //SDRAM
  13. output SDRAM_CLK,
  14. output SDRAM_CSn,
  15. output SDRAM_WEn,
  16. output SDRAM_CASn,
  17. output SDRAM_RASn,
  18. output SDRAM_CKE,
  19. output [12:0] SDRAM_A,
  20. output [1:0] SDRAM_BA,
  21. output [3:0] SDRAM_DQM,
  22. inout [31:0] SDRAM_DQ,
  23. //SPI0 flash
  24. output SPI0_clk,
  25. output SPI0_cs,
  26. inout SPI0_data,
  27. inout SPI0_q,
  28. inout SPI0_wp,
  29. inout SPI0_hold,
  30. //SPI1 CH376 bottom
  31. output SPI1_clk,
  32. output SPI1_cs,
  33. output SPI1_mosi,
  34. input SPI1_miso,
  35. input SPI1_nint,
  36. output SPI1_rst,
  37. //SPI2 CH376 top
  38. output SPI2_clk,
  39. output SPI2_cs,
  40. output SPI2_mosi,
  41. input SPI2_miso,
  42. input SPI2_nint,
  43. output SPI2_rst,
  44. //SPI3 W5500
  45. output SPI3_clk,
  46. output SPI3_cs,
  47. output SPI3_mosi,
  48. input SPI3_miso,
  49. input SPI3_int,
  50. output SPI3_nrst,
  51. //SPI4 GP
  52. output SPI4_clk,
  53. output SPI4_cs,
  54. output SPI4_mosi,
  55. input SPI4_miso,
  56. input SPI4_gp,
  57. //UART0
  58. input UART0_in,
  59. output UART0_out,
  60. input UART0_dtr,
  61. //UART1 (currently unused because no UART midi synth anymore)
  62. //input UART1_in,
  63. //output UART1_out,
  64. //UART2
  65. input UART2_in,
  66. output UART2_out,
  67. //PS/2
  68. input PS2_clk, PS2_data,
  69. //Led for debugging
  70. output led,
  71. //GPIO
  72. input [3:0] GPI,
  73. output [3:0] GPO,
  74. //DIP switch
  75. input [3:0] DIPS,
  76. //I2S audio
  77. output I2S_SDIN, I2S_SCLK, I2S_LRCLK, I2S_MCLK,
  78. //Status leds
  79. output led_Booted, led_Eth, led_Flash, led_USB0, led_USB1, led_PS2, led_HDMI, led_QSPI, led_GPU, led_I2S
  80. );
  81. // TMP FIXES FOR NEW PCB
  82. assign I2S_SDIN = 1'b0;
  83. assign I2S_SCLK = 1'b0;
  84. assign I2S_LRCLK = 1'b0;
  85. assign I2S_MCLK = 1'b0;
  86. //-------------------CLK-------------------------
  87. // Clock generator PLL
  88. wire clkPixel; // Pixel clock (25MHz)
  89. wire clkTMDShalf; // TMDS clock (pre-DDR), 5x pixel clock (125MHz)
  90. wire clk_SDRAM; // SDRAM clock (100MHz)
  91. wire clk; // System clock (50MHz)
  92. //clock_pll_v clkPll(
  93. //.refclk (clock),
  94. //.outclk_0 (clkPixel),
  95. //.outclk_1 (clkTMDShalf),
  96. //.outclk_2 (clk_SDRAM),
  97. //.outclk_3 (SDRAM_CLK),
  98. //.outclk_4 (clk)
  99. //);
  100. /*
  101. clock_pll clkPll(
  102. .inclk0 (clock),
  103. .areset (1'b0),
  104. .c0 (clk_SDRAM),
  105. .c1 (SDRAM_CLK),
  106. .c2 (clk),
  107. .c3 (clkPixel),
  108. .c4 (clkTMDShalf)
  109. );
  110. */
  111. mainpll mainClkPll(
  112. .refclk (clock),
  113. .rst (1'b0),
  114. .outclk_0 (clk_SDRAM),
  115. .outclk_1 (SDRAM_CLK),
  116. .outclk_2 (clk),
  117. .outclk_3 (clkPixel),
  118. .outclk_4 (clkTMDShalf)
  119. );
  120. wire clk14; //14.31818MHz (50*63/220)
  121. wire clk114; //14.31818 * 8 MHz = 114.5454MHz (50*(63*2)/55)
  122. //NTSC_pll ntscPll(
  123. //.refclk (clock),
  124. //.outclk_0 (clk14),
  125. //.outclk_1 (clk114),
  126. //.outclk_2 (clkPixel), // 25.2MHz dirty fix to allow ALTCLKBUF
  127. //.outclk_3 (clkTMDShalf)
  128. //);
  129. /*
  130. NTSC_pll ntscPll(
  131. .inclk0 (clk),
  132. .areset (1'b0),
  133. //.c0 (clk14),
  134. //.c1 (clk114),
  135. .c2 (clkPixel), // 25.2MHz dirty fix to allow ALTCLKBUF
  136. .c3 (clkTMDShalf)
  137. );
  138. */
  139. wire clkMuxOut;
  140. //wire selectOutput; // 1 -> HDMI, 0 -> Composite
  141. /*
  142. clkMux clkmux(
  143. .inclk0x(clock),
  144. .inclk1x(clock),
  145. .inclk2x(clk14),
  146. .inclk3x(clkPixel),
  147. .clkselect({1'b1, selectOutput}),
  148. .outclk(clkMuxOut)
  149. );
  150. */
  151. assign clkMuxOut = clkPixel;
  152. //--------------------Reset&Stabilizers-----------------------
  153. // Reset signals
  154. wire nreset_stable, UART0_dtr_stable;
  155. wire nreset_unstable;
  156. assign nreset_unstable = nreset & nBtnl & nBtnr;
  157. // Dip switch
  158. wire boot_mode_stable;
  159. // GPU: High when frame just rendered (needs to be stabilized)
  160. wire frameDrawn, frameDrawn_stable;
  161. // Stabilized SPI interrupt signals
  162. wire SPI1_nint_stable, SPI2_nint_stable, SPI3_int_stable, SPI4_gp_stable;
  163. MultiStabilizer multistabilizer(
  164. .clk (clk),
  165. .u0 (nreset_unstable),
  166. .s0 (nreset_stable),
  167. .u1 (UART0_dtr),
  168. .s1 (UART0_dtr_stable),
  169. .u2 (SPI1_nint),
  170. .s2 (SPI1_nint_stable),
  171. .u3 (SPI2_nint),
  172. .s3 (SPI2_nint_stable),
  173. .u4 (SPI3_int),
  174. .s4 (SPI3_int_stable),
  175. .u5 (SPI4_gp),
  176. .s5 (SPI4_gp_stable),
  177. .u6 (frameDrawn),
  178. .s6 (frameDrawn_stable),
  179. .u7 (DIPS[0]),
  180. .s7 (boot_mode_stable)
  181. //.u8 (DIPS[1]),
  182. //.s8 (selectOutput)
  183. );
  184. //assign selectOutput = 1'b0;
  185. // Debug: indicator for opened Serial port
  186. assign led = UART0_dtr_stable;
  187. // DTR to reset pulse
  188. wire dtrRst;
  189. DtrReset dtrReset(
  190. .clk (clk),
  191. .dtr (UART0_dtr_stable),
  192. .dtrRst (dtrRst)
  193. );
  194. wire reset = (~nreset_stable) || dtrRst; // Global reset
  195. // External reset outputs
  196. assign SPI1_rst = reset;
  197. assign SPI2_rst = reset;
  198. assign SPI3_nrst = ~reset;
  199. //---------------------------VRAM32---------------------------------
  200. // VRAM32 I/O
  201. wire vram32_gpu_clk;
  202. wire [13:0] vram32_gpu_addr;
  203. wire [31:0] vram32_gpu_d;
  204. wire vram32_gpu_we;
  205. wire [31:0] vram32_gpu_q;
  206. wire vram32_cpu_clk;
  207. wire [13:0] vram32_cpu_addr;
  208. wire [31:0] vram32_cpu_d;
  209. wire vram32_cpu_we;
  210. wire [31:0] vram32_cpu_q;
  211. // FSX will not write to VRAM
  212. assign vram32_gpu_we = 1'b0;
  213. assign vram32_gpu_d = 32'd0;
  214. VRAM #(
  215. .WIDTH(32),
  216. .WORDS(1056),
  217. .ADDR_BITS(14),
  218. .LIST("memory/vram32.list")
  219. ) vram32(
  220. // CPU port
  221. .cpu_clk (clk),
  222. .cpu_d (vram32_cpu_d),
  223. .cpu_addr (vram32_cpu_addr),
  224. .cpu_we (vram32_cpu_we),
  225. .cpu_q (vram32_cpu_q),
  226. // GPU port
  227. .gpu_clk (clkMuxOut),
  228. .gpu_d (vram32_gpu_d),
  229. .gpu_addr (vram32_gpu_addr),
  230. .gpu_we (vram32_gpu_we),
  231. .gpu_q (vram32_gpu_q)
  232. );
  233. //---------------------------VRAM322--------------------------------
  234. // VRAM322 I/O
  235. wire vram322_gpu_clk;
  236. wire [13:0] vram322_gpu_addr;
  237. wire [31:0] vram322_gpu_d;
  238. wire vram322_gpu_we;
  239. wire [31:0] vram322_gpu_q;
  240. // FSX will not write to VRAM
  241. assign vram322_gpu_we = 1'b0;
  242. assign vram322_gpu_d = 32'd0;
  243. VRAM #(
  244. .WIDTH(32),
  245. .WORDS(1056),
  246. .ADDR_BITS(14),
  247. .LIST("memory/vram32.list")
  248. ) vram322(
  249. // CPU port
  250. .cpu_clk (clk),
  251. .cpu_d (vram32_cpu_d),
  252. .cpu_addr (vram32_cpu_addr),
  253. .cpu_we (vram32_cpu_we),
  254. .cpu_q (),
  255. // GPU port
  256. .gpu_clk (clkMuxOut),
  257. .gpu_d (vram322_gpu_d),
  258. .gpu_addr (vram322_gpu_addr),
  259. .gpu_we (vram322_gpu_we),
  260. .gpu_q (vram322_gpu_q)
  261. );
  262. //--------------------------VRAM8--------------------------------
  263. //VRAM8 I/O
  264. wire vram8_gpu_clk;
  265. wire [13:0] vram8_gpu_addr;
  266. wire [7:0] vram8_gpu_d;
  267. wire vram8_gpu_we;
  268. wire [7:0] vram8_gpu_q;
  269. wire vram8_cpu_clk;
  270. wire [13:0] vram8_cpu_addr;
  271. wire [7:0] vram8_cpu_d;
  272. wire vram8_cpu_we;
  273. wire [7:0] vram8_cpu_q;
  274. // FSX will not write to VRAM
  275. assign vram8_gpu_we = 1'b0;
  276. assign vram8_gpu_d = 8'd0;
  277. VRAM #(
  278. .WIDTH(8),
  279. .WORDS(8194),
  280. .ADDR_BITS(14),
  281. .LIST("memory/vram8.list")
  282. ) vram8(
  283. // CPU port
  284. .cpu_clk (clk),
  285. .cpu_d (vram8_cpu_d),
  286. .cpu_addr (vram8_cpu_addr),
  287. .cpu_we (vram8_cpu_we),
  288. .cpu_q (vram8_cpu_q),
  289. // GPU port
  290. .gpu_clk (clkMuxOut),
  291. .gpu_d (vram8_gpu_d),
  292. .gpu_addr (vram8_gpu_addr),
  293. .gpu_we (vram8_gpu_we),
  294. .gpu_q (vram8_gpu_q)
  295. );
  296. //--------------------------VRAMSPR--------------------------------
  297. //VRAMSPR I/O
  298. wire vramSPR_gpu_clk;
  299. wire [13:0] vramSPR_gpu_addr;
  300. wire [8:0] vramSPR_gpu_d;
  301. wire vramSPR_gpu_we;
  302. wire [8:0] vramSPR_gpu_q;
  303. wire vramSPR_cpu_clk;
  304. wire [13:0] vramSPR_cpu_addr;
  305. wire [8:0] vramSPR_cpu_d;
  306. wire vramSPR_cpu_we;
  307. wire [8:0] vramSPR_cpu_q;
  308. // FSX will not write to VRAM
  309. assign vramSPR_gpu_we = 1'b0;
  310. assign vramSPR_gpu_d = 9'd0;
  311. VRAM #(
  312. .WIDTH(9),
  313. .WORDS(256),
  314. .ADDR_BITS(14),
  315. .LIST("memory/vramSPR.list")
  316. ) vramSPR(
  317. // CPU port
  318. .cpu_clk (clk),
  319. .cpu_d (vramSPR_cpu_d),
  320. .cpu_addr (vramSPR_cpu_addr),
  321. .cpu_we (vramSPR_cpu_we),
  322. .cpu_q (vramSPR_cpu_q),
  323. // GPU port
  324. .gpu_clk (clkMuxOut),
  325. .gpu_d (vramSPR_gpu_d),
  326. .gpu_addr (vramSPR_gpu_addr),
  327. .gpu_we (vramSPR_gpu_we),
  328. .gpu_q (vramSPR_gpu_q)
  329. );
  330. //--------------------------VRAMPX--------------------------------
  331. //VRAMPX I/O
  332. wire vramPX_gpu_clk;
  333. wire [16:0] vramPX_gpu_addr;
  334. wire [7:0] vramPX_gpu_d;
  335. wire vramPX_gpu_we;
  336. wire [7:0] vramPX_gpu_q;
  337. wire vramPX_cpu_clk;
  338. wire [16:0] vramPX_cpu_addr;
  339. wire [7:0] vramPX_cpu_d;
  340. wire vramPX_cpu_we;
  341. wire [7:0] vramPX_cpu_q;
  342. // FSX will not write to VRAM
  343. assign vramPX_gpu_we = 1'b0;
  344. assign vramPX_gpu_d = 8'd0;
  345. VRAM #(
  346. .WIDTH(8),
  347. .WORDS(76800),
  348. .ADDR_BITS(17),
  349. .LIST("memory/vramPX.list")
  350. ) vramPX(
  351. // CPU port
  352. .cpu_clk (clk),
  353. .cpu_d (vramPX_cpu_d),
  354. .cpu_addr (vramPX_cpu_addr),
  355. .cpu_we (vramPX_cpu_we),
  356. .cpu_q (vramPX_cpu_q),
  357. // GPU port
  358. .gpu_clk (clkMuxOut),
  359. .gpu_d (vramPX_gpu_d),
  360. .gpu_addr (vramPX_gpu_addr),
  361. .gpu_we (vramPX_gpu_we),
  362. .gpu_q (vramPX_gpu_q)
  363. );
  364. //-------------------ROM-------------------------
  365. // ROM I/O
  366. wire [8:0] rom_addr;
  367. wire [31:0] rom_q;
  368. ROM rom(
  369. .clk (clk),
  370. .reset (reset),
  371. .address (rom_addr),
  372. .q (rom_q)
  373. );
  374. //----------------SDRAM Controller------------------
  375. // inputs
  376. wire [23:0] sdc_addr; // address to write or to start reading from
  377. wire [31:0] sdc_data; // data to write
  378. wire sdc_we; // write enable
  379. wire sdc_start; // start trigger
  380. // outputs
  381. wire [31:0] sdc_q; // memory output
  382. wire sdc_done; // output ready
  383. SDRAMcontroller sdramcontroller(
  384. // clock/reset inputs
  385. .clk (clk_SDRAM),
  386. .reset (reset),
  387. // interface inputs
  388. .sdc_addr (sdc_addr),
  389. .sdc_data (sdc_data),
  390. .sdc_we (sdc_we),
  391. .sdc_start (sdc_start),
  392. // interface outputs
  393. .sdc_q (sdc_q),
  394. .sdc_done (sdc_done),
  395. // SDRAM signals
  396. .SDRAM_CKE (SDRAM_CKE),
  397. .SDRAM_CSn (SDRAM_CSn),
  398. .SDRAM_WEn (SDRAM_WEn),
  399. .SDRAM_CASn (SDRAM_CASn),
  400. .SDRAM_RASn (SDRAM_RASn),
  401. .SDRAM_A (SDRAM_A),
  402. .SDRAM_BA (SDRAM_BA),
  403. .SDRAM_DQM (SDRAM_DQM),
  404. .SDRAM_DQ (SDRAM_DQ)
  405. );
  406. //-----------------------FSX-------------------------
  407. // FSX I/O
  408. //wire [7:0] composite; // NTSC composite video signal
  409. FSX fsx(
  410. // Clocks
  411. .clkPixel (clkPixel),
  412. .clkTMDShalf (clkTMDShalf),
  413. //.clk14 (clk14),
  414. //.clk114 (clk114),
  415. .clkMuxOut (clkMuxOut),
  416. // HDMI
  417. .TMDS_p (TMDS_p),
  418. .TMDS_n (TMDS_n),
  419. // NTSC composite
  420. //.composite (composite),
  421. // Select output method
  422. //.selectOutput (selectOutput),
  423. // VRAM32
  424. .vram32_addr (vram32_gpu_addr),
  425. .vram32_q (vram32_gpu_q),
  426. // VRAM32
  427. .vram322_addr (vram322_gpu_addr),
  428. .vram322_q (vram322_gpu_q),
  429. // VRAM8
  430. .vram8_addr (vram8_gpu_addr),
  431. .vram8_q (vram8_gpu_q),
  432. // VRAMSPR
  433. .vramSPR_addr (vramSPR_gpu_addr),
  434. .vramSPR_q (vramSPR_gpu_q),
  435. //VRAMPX
  436. .vramPX_addr (vramPX_gpu_addr),
  437. .vramPX_q (vramPX_gpu_q),
  438. // Interrupt signal
  439. .frameDrawn (frameDrawn)
  440. );
  441. //----------------Memory Unit--------------------
  442. // Memory Unit I/O
  443. // Bus
  444. wire [26:0] bus_addr;
  445. wire [31:0] bus_data;
  446. wire bus_we;
  447. wire bus_start;
  448. wire [31:0] bus_q;
  449. wire bus_done;
  450. // Interrupt signals
  451. wire OST1_int, OST2_int, OST3_int;
  452. wire UART0_rx_int, UART2_rx_int;
  453. wire PS2_int;
  454. wire SPI0_QSPI;
  455. MemoryUnit mu(
  456. // Clocks
  457. .clk (clk),
  458. .reset (reset),
  459. // Bus
  460. .bus_addr (bus_addr),
  461. .bus_data (bus_data),
  462. .bus_we (bus_we),
  463. .bus_start (bus_start),
  464. .bus_q (bus_q),
  465. .bus_done (bus_done),
  466. /********
  467. * MEMORY
  468. ********/
  469. // SPI Flash / SPI0
  470. .SPIflash_data (SPI0_data),
  471. .SPIflash_q (SPI0_q),
  472. .SPIflash_wp (SPI0_wp),
  473. .SPIflash_hold (SPI0_hold),
  474. .SPIflash_cs (SPI0_cs),
  475. .SPIflash_clk (SPI0_clk),
  476. // VRAM32 cpu port
  477. .VRAM32_cpu_d (vram32_cpu_d),
  478. .VRAM32_cpu_addr (vram32_cpu_addr),
  479. .VRAM32_cpu_we (vram32_cpu_we),
  480. .VRAM32_cpu_q (vram32_cpu_q),
  481. // VRAM8 cpu port
  482. .VRAM8_cpu_d (vram8_cpu_d),
  483. .VRAM8_cpu_addr (vram8_cpu_addr),
  484. .VRAM8_cpu_we (vram8_cpu_we),
  485. .VRAM8_cpu_q (vram8_cpu_q),
  486. // VRAMspr cpu port
  487. .VRAMspr_cpu_d (vramSPR_cpu_d),
  488. .VRAMspr_cpu_addr (vramSPR_cpu_addr),
  489. .VRAMspr_cpu_we (vramSPR_cpu_we),
  490. .VRAMspr_cpu_q (vramSPR_cpu_q),
  491. // VRAMpx cpu port
  492. .VRAMpx_cpu_d (vramPX_cpu_d),
  493. .VRAMpx_cpu_addr (vramPX_cpu_addr),
  494. .VRAMpx_cpu_we (vramPX_cpu_we),
  495. .VRAMpx_cpu_q (vramPX_cpu_q),
  496. // ROM
  497. .ROM_addr (rom_addr),
  498. .ROM_q (rom_q),
  499. /********
  500. * I/O
  501. ********/
  502. // UART0 (Main USB)
  503. .UART0_in (UART0_in),
  504. .UART0_out (UART0_out),
  505. .UART0_rx_interrupt (UART0_rx_int),
  506. // UART1 (APU)
  507. /*
  508. .UART1_in (),
  509. .UART1_out (),
  510. .UART1_rx_interrupt (),
  511. */
  512. // UART2 (GP)
  513. .UART2_in (UART2_in),
  514. .UART2_out (UART2_out),
  515. .UART2_rx_interrupt (UART2_rx_int),
  516. //SPI0 (Flash)
  517. //declared under MEMORY
  518. .SPI0_QSPI (SPI0_QSPI),
  519. // SPI1 (USB0/CH376T, bottom)
  520. .SPI1_clk (SPI1_clk),
  521. .SPI1_cs (SPI1_cs),
  522. .SPI1_mosi (SPI1_mosi),
  523. .SPI1_miso (SPI1_miso),
  524. .SPI1_nint (SPI1_nint_stable),
  525. // SPI2 (USB1/CH376T, top)
  526. .SPI2_clk (SPI2_clk),
  527. .SPI2_cs (SPI2_cs),
  528. .SPI2_mosi (SPI2_mosi),
  529. .SPI2_miso (SPI2_miso),
  530. .SPI2_nint (SPI2_nint_stable),
  531. // SPI3 (W5500)
  532. .SPI3_clk (SPI3_clk),
  533. .SPI3_cs (SPI3_cs),
  534. .SPI3_mosi (SPI3_mosi),
  535. .SPI3_miso (SPI3_miso),
  536. .SPI3_int (SPI3_int_stable),
  537. // SPI4 (EXT/GP)
  538. .SPI4_clk (SPI4_clk),
  539. .SPI4_cs (SPI4_cs),
  540. .SPI4_mosi (SPI4_mosi),
  541. .SPI4_miso (SPI4_miso),
  542. .SPI4_GP (SPI4_gp_stable),
  543. // GPIO (Separated GPI and GPO until GPIO module is implemented)
  544. .GPI (GPI[3:0]),
  545. .GPO (GPO[3:0]),
  546. // OStimers
  547. .OST1_int (OST1_int),
  548. .OST2_int (OST2_int),
  549. .OST3_int (OST3_int),
  550. // SNESpad
  551. /*
  552. .SNES_clk (),
  553. .SNES_latch (),
  554. .SNES_data (),
  555. */
  556. // PS/2
  557. .PS2_clk (PS2_clk),
  558. .PS2_data (PS2_data),
  559. .PS2_int (PS2_int), //Scan code ready signal
  560. // Boot mode
  561. .boot_mode (boot_mode_stable)
  562. );
  563. //------------L2 Cache--------------
  564. //CPU bus
  565. wire [23:0] l2_addr; // address to write or to start reading from
  566. wire [31:0] l2_data; // data to write
  567. wire l2_we; // write enable
  568. wire l2_start; // start trigger
  569. wire [31:0] l2_q; // memory output
  570. wire l2_done; // output ready
  571. L2cache l2cache(
  572. .clk (clk_SDRAM),
  573. .reset (reset),
  574. // CPU bus
  575. .l2_addr (l2_addr),
  576. .l2_data (l2_data),
  577. .l2_we (l2_we),
  578. .l2_start (l2_start),
  579. .l2_q (l2_q),
  580. .l2_done (l2_done),
  581. // sdram bus
  582. .sdc_addr (sdc_addr),
  583. .sdc_data (sdc_data),
  584. .sdc_we (sdc_we),
  585. .sdc_start (sdc_start),
  586. .sdc_q (sdc_q),
  587. .sdc_done (sdc_done)
  588. );
  589. //---------------CPU----------------
  590. // CPU I/O
  591. wire [26:0] PC;
  592. CPU cpu(
  593. // Clock/reset
  594. .clk (clk),
  595. .reset (reset),
  596. .int1 (OST1_int), //OStimer1
  597. .int2 (OST2_int), //OStimer2
  598. .int3 (UART0_rx_int), //UART0 rx (MAIN)
  599. .int4 (frameDrawn_stable), //GPU Frame Drawn
  600. .int5 (OST3_int), //OStimer3
  601. .int6 (PS2_int), //PS/2 scancode ready
  602. .int7 (1'b0), //UART1 rx (APU)
  603. .int8 (UART2_rx_int), //UART2 rx (EXT)
  604. // Bus
  605. .bus_addr (bus_addr),
  606. .bus_data (bus_data),
  607. .bus_we (bus_we),
  608. .bus_start (bus_start),
  609. .bus_q (bus_q),
  610. .bus_done (bus_done),
  611. .PC (PC),
  612. // sdram bus
  613. .sdc_addr (l2_addr),
  614. .sdc_data (l2_data),
  615. .sdc_we (l2_we),
  616. .sdc_start (l2_start),
  617. .sdc_q (l2_q),
  618. .sdc_done (l2_done)
  619. );
  620. //-----------STATUS LEDS-----------
  621. assign led_Booted = (PC >= 27'hC02522 | reset);
  622. assign led_HDMI = 1'b0; //(~selectOutput | reset);
  623. assign led_QSPI = (~SPI0_QSPI | reset);
  624. LEDvisualizer #(.MIN_CLK(100000))
  625. LEDvisUSB0
  626. (
  627. .clk(clk),
  628. .reset(reset),
  629. .activity(~SPI1_cs),
  630. .LED(led_USB0)
  631. );
  632. LEDvisualizer #(.MIN_CLK(100000))
  633. LEDvisUSB1
  634. (
  635. .clk(clk),
  636. .reset(reset),
  637. .activity(~SPI2_cs),
  638. .LED(led_USB1)
  639. );
  640. LEDvisualizer #(.MIN_CLK(100000))
  641. LEDvisEth
  642. (
  643. .clk(clk),
  644. .reset(reset),
  645. .activity(~SPI3_cs),
  646. .LED(led_Eth)
  647. );
  648. LEDvisualizer #(.MIN_CLK(100000))
  649. LEDvisPS2
  650. (
  651. .clk(clk),
  652. .reset(reset),
  653. .activity(PS2_int),
  654. .LED(led_PS2)
  655. );
  656. LEDvisualizer #(.MIN_CLK(100000))
  657. LEDvisFlash
  658. (
  659. .clk(clk),
  660. .reset(reset),
  661. .activity(~SPI0_cs),
  662. .LED(led_Flash)
  663. );
  664. LEDvisualizer #(.MIN_CLK(100000))
  665. LEDvisGPU
  666. (
  667. .clk(clk),
  668. .reset(reset),
  669. .activity(vram32_cpu_we|vram8_cpu_we|vramSPR_cpu_we|vramPX_cpu_we),
  670. .LED(led_GPU)
  671. );
  672. LEDvisualizer #(.MIN_CLK(100000))
  673. LEDvisI2S
  674. (
  675. .clk(clk),
  676. .reset(reset),
  677. .activity(I2S_SDIN),
  678. .LED(led_I2S)
  679. );
  680. endmodule