FPGC.v 18 KB

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