1
0

FPGC.v 17 KB

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