Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. //-------------------------------------------------------------------------
  2. // lab8.sv --
  3. // Christine Chen --
  4. // Fall 2014 --
  5. // --
  6. // Modified by Po-Han Huang --
  7. // 10/06/2017 --
  8. // --
  9. // Fall 2017 Distribution --
  10. // --
  11. // For use with ECE 385 Lab 8 --
  12. // UIUC ECE Department --
  13. //-------------------------------------------------------------------------
  14.  
  15.  
  16. module lab8( input CLOCK_50,
  17. input [3:0] KEY, //bit 0 is set up as Reset
  18. output logic [6:0] HEX0, HEX1,
  19. // VGA Interface
  20. output logic [7:0] VGA_R, //VGA Red
  21. VGA_G, //VGA Green
  22. VGA_B, //VGA Blue
  23. output logic VGA_CLK, //VGA Clock
  24. VGA_SYNC_N, //VGA Sync signal
  25. VGA_BLANK_N, //VGA Blank signal
  26. VGA_VS, //VGA virtical sync signal
  27. VGA_HS, //VGA horizontal sync signal
  28. // CY7C67200 Interface
  29. inout wire [15:0] OTG_DATA, //CY7C67200 Data bus 16 Bits
  30. output logic [1:0] OTG_ADDR, //CY7C67200 Address 2 Bits
  31. output logic OTG_CS_N, //CY7C67200 Chip Select
  32. OTG_RD_N, //CY7C67200 Write
  33. OTG_WR_N, //CY7C67200 Read
  34. OTG_RST_N, //CY7C67200 Reset
  35. input OTG_INT, //CY7C67200 Interrupt
  36. // SDRAM Interface for Nios II Software
  37. output logic [12:0] DRAM_ADDR, //SDRAM Address 13 Bits
  38. inout wire [31:0] DRAM_DQ, //SDRAM Data 32 Bits
  39. output logic [1:0] DRAM_BA, //SDRAM Bank Address 2 Bits
  40. output logic [3:0] DRAM_DQM, //SDRAM Data Mast 4 Bits
  41. output logic DRAM_RAS_N, //SDRAM Row Address Strobe
  42. DRAM_CAS_N, //SDRAM Column Address Strobe
  43. DRAM_CKE, //SDRAM Clock Enable
  44. DRAM_WE_N, //SDRAM Write Enable
  45. DRAM_CS_N, //SDRAM Chip Select
  46. DRAM_CLK, //SDRAM Clock
  47. output logic [3:0] LED //LEDs
  48. );
  49.  
  50. logic Reset_h, Clk, is_ball;
  51. logic [7:0] keycode;
  52. logic [9:0] DrawX, DrawY;
  53.  
  54. assign Clk = CLOCK_50;
  55. always_ff @ (posedge Clk) begin
  56. Reset_h <= ~(KEY[0]); // The push buttons are active low
  57. end
  58.  
  59. logic [1:0] hpi_addr;
  60. logic [15:0] hpi_data_in, hpi_data_out;
  61. logic hpi_r, hpi_w, hpi_cs, hpi_reset;
  62.  
  63. // Interface between NIOS II and EZ-OTG chip
  64. hpi_io_intf hpi_io_inst(
  65. .Clk(Clk),
  66. .Reset(Reset_h),
  67. // signals connected to NIOS II
  68. .from_sw_address(hpi_addr),
  69. .from_sw_data_in(hpi_data_in),
  70. .from_sw_data_out(hpi_data_out),
  71. .from_sw_r(hpi_r),
  72. .from_sw_w(hpi_w),
  73. .from_sw_cs(hpi_cs),
  74. .from_sw_reset(hpi_reset),
  75. // signals connected to EZ-OTG chip
  76. .OTG_DATA(OTG_DATA),
  77. .OTG_ADDR(OTG_ADDR),
  78. .OTG_RD_N(OTG_RD_N),
  79. .OTG_WR_N(OTG_WR_N),
  80. .OTG_CS_N(OTG_CS_N),
  81. .OTG_RST_N(OTG_RST_N)
  82. );
  83.  
  84. // You need to make sure that the port names here match the ports in Qsys-generated codes.
  85. lab8_soc nios_system(
  86. .clk_clk(Clk),
  87. .reset_reset_n(1'b1), // Never reset NIOS
  88. .sdram_wire_addr(DRAM_ADDR),
  89. .sdram_wire_ba(DRAM_BA),
  90. .sdram_wire_cas_n(DRAM_CAS_N),
  91. .sdram_wire_cke(DRAM_CKE),
  92. .sdram_wire_cs_n(DRAM_CS_N),
  93. .sdram_wire_dq(DRAM_DQ),
  94. .sdram_wire_dqm(DRAM_DQM),
  95. .sdram_wire_ras_n(DRAM_RAS_N),
  96. .sdram_wire_we_n(DRAM_WE_N),
  97. .sdram_clk_clk(DRAM_CLK),
  98. .keycode_export(keycode),
  99. .otg_hpi_address_export(hpi_addr),
  100. .otg_hpi_data_in_port(hpi_data_in),
  101. .otg_hpi_data_out_port(hpi_data_out),
  102. .otg_hpi_cs_export(hpi_cs),
  103. .otg_hpi_r_export(hpi_r),
  104. .otg_hpi_w_export(hpi_w),
  105. .otg_hpi_reset_export(hpi_reset)
  106.  
  107. );
  108.  
  109. // Use PLL to generate the 25MHZ VGA_CLK.
  110. // You will have to generate it on your own in simulation.
  111. vga_clk vga_clk_instance(.inclk0(Clk), .c0(VGA_CLK));
  112.  
  113. // TODO: Fill in the connections for the rest of the modules
  114. VGA_controller vga_controller_instance(
  115. .*,
  116. .Clk(CLOCK_50),
  117. .Reset(Reset_h)
  118. );
  119.  
  120. // Which signal should be frame_clk?
  121. ball ball_instance(
  122. .*,
  123. .Clk(CLOCK_50),
  124. .Reset(Reset_h),
  125. .frame_clk(VGA_VS)
  126. );
  127.  
  128. color_mapper color_instance(
  129. .*
  130. );
  131.  
  132. // Display keycode on hex display
  133. HexDriver hex_inst_0 (keycode[3:0], HEX0);
  134. HexDriver hex_inst_1 (keycode[7:4], HEX1);
  135.  
  136. /**************************************************************************************
  137. ATTENTION! Please answer the following quesiton in your lab report! Points will be allocated for the answers!
  138. Hidden Question #1/2:
  139. What are the advantages and/or disadvantages of using a USB interface over PS/2 interface to
  140. connect to the keyboard? List any two. Give an answer in your Post-Lab.
  141. **************************************************************************************/
  142. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement