| 
														
															@@ -13,124 +13,124 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     parameter logic [7:0] fpga_ver) 
														 | 
														
														 | 
														
															     parameter logic [7:0] fpga_ver) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    ( 
														 | 
														
														 | 
														
															    ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Clock oscillator 
														 | 
														
														 | 
														
															     // Clock oscillator 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  master_clk,	// 336 MHz from PLL2 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  slow_clk,	// ~12 MHz clock from PLL2 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  master_pll_locked, // PLL2 is locked, master_clk is good 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  reset_plls,	// Reset all PLLs including PLL2 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  master_clk,	// 336 MHz from PLL2 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  slow_clk,	// ~12 MHz clock from PLL2 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  master_pll_locked, // PLL2 is locked, master_clk is good 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  reset_plls,	// Reset all PLLs including PLL2 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  board_id, // This better match the firmware 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  board_id, // This better match the firmware 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // ABC-bus 
														 | 
														
														 | 
														
															     // ABC-bus 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_clk, // ABC-bus 3 MHz clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_clk, // ABC-bus 3 MHz clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [15:0]  abc_a, // ABC address bus 
														 | 
														
														 | 
														
															     inout [15:0]  abc_a, // ABC address bus 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [7:0]   abc_d, // ABC data bus 
														 | 
														
														 | 
														
															     inout [7:0]   abc_d, // ABC data bus 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  abc_d_oe, // Data bus output enable 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_rst_n, // ABC bus reset strobe 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_cs_n, // ABC card select strobe 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  abc_d_oe, // Data bus output enable 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_rst_n, // ABC bus reset strobe 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_cs_n, // ABC card select strobe 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [4:0]   abc_out_n, // OUT, C1-C4 strobe 
														 | 
														
														 | 
														
															     inout [4:0]   abc_out_n, // OUT, C1-C4 strobe 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [1:0]   abc_inp_n, // INP, STATUS strobe 
														 | 
														
														 | 
														
															     inout [1:0]   abc_inp_n, // INP, STATUS strobe 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xmemfl_n, // Memory read strobe 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xmemw800_n, // Memory write strobe (ABC800) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xmemw80_n, // Memory write strobe (ABC80) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xinpstb_n, // I/O read strobe (ABC800) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xoutpstb_n, // I/O write strobe (ABC80) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xmemfl_n, // Memory read strobe 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xmemw800_n, // Memory write strobe (ABC800) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xmemw80_n, // Memory write strobe (ABC80) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xinpstb_n, // I/O read strobe (ABC800) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xoutpstb_n, // I/O write strobe (ABC80) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // The following are inverted versus the bus IF 
														 | 
														
														 | 
														
															     // The following are inverted versus the bus IF 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // the corresponding MOSFETs are installed 
														 | 
														
														 | 
														
															     // the corresponding MOSFETs are installed 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_rdy_x, // RDY = WAIT# 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_resin_x, // System reset request 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_int80_x, // System INT request (ABC80) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_int800_x, // System INT request (ABC800) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_nmi_x, // System NMI request (ABC800) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  abc_xm_x, // System memory override (ABC800) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_rdy_x, // RDY = WAIT# 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_resin_x, // System reset request 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_int80_x, // System INT request (ABC80) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_int800_x, // System INT request (ABC800) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_nmi_x, // System NMI request (ABC800) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  abc_xm_x, // System memory override (ABC800) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Host/device control 
														 | 
														
														 | 
														
															     // Host/device control 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  abc_host, // 1 = host, 0 = target 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  abc_host, // 1 = host, 0 = target 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // ABC-bus extension header 
														 | 
														
														 | 
														
															     // ABC-bus extension header 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // (Note: cannot use an array here because HC and HH are 
														 | 
														
														 | 
														
															     // (Note: cannot use an array here because HC and HH are 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // input only.) 
														 | 
														
														 | 
														
															     // input only.) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_ha, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_hb, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  exth_hc, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_hd, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_he, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_hf, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  exth_hg, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  exth_hh, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_ha, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_hb, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  exth_hc, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_hd, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_he, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_hf, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  exth_hg, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  exth_hh, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // SDRAM bus 
														 | 
														
														 | 
														
															     // SDRAM bus 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sr_clk, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sr_clk, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output [1:0]  sr_ba, // Bank address 
														 | 
														
														 | 
														
															     output [1:0]  sr_ba, // Bank address 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output [12:0] sr_a, // Address within bank 
														 | 
														
														 | 
														
															     output [12:0] sr_a, // Address within bank 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [15:0]  sr_dq, // Also known as D or IO 
														 | 
														
														 | 
														
															     inout [15:0]  sr_dq, // Also known as D or IO 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output [1:0]  sr_dqm, // DQML and DQMH 
														 | 
														
														 | 
														
															     output [1:0]  sr_dqm, // DQML and DQMH 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sr_cs_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sr_we_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sr_cas_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sr_ras_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sr_cs_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sr_we_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sr_cas_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sr_ras_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // SD card 
														 | 
														
														 | 
														
															     // SD card 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  sd_cd_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sd_cs_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sd_clk, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sd_di, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  sd_do, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  sd_cd_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sd_cs_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sd_clk, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sd_di, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  sd_do, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Serial console (naming is FPGA as DCE) 
														 | 
														
														 | 
														
															     // Serial console (naming is FPGA as DCE) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  tty_txd, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  tty_rxd, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  tty_rts, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  tty_cts, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  tty_dtr, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  tty_txd, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  tty_rxd, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  tty_rts, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  tty_cts, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  tty_dtr, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // SPI flash memory (also configuration) 
														 | 
														
														 | 
														
															     // SPI flash memory (also configuration) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  flash_cs_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  flash_sck, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  flash_cs_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  flash_sck, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [1:0]   flash_io, 
														 | 
														
														 | 
														
															     inout [1:0]   flash_io, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // SPI bus (connected to ESP32 so can be bidirectional) 
														 | 
														
														 | 
														
															     // SPI bus (connected to ESP32 so can be bidirectional) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  spi_clk, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  spi_miso, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  spi_mosi, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  spi_cs_esp_n, // ESP32 IO10 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  spi_cs_flash_n, // ESP32 IO01 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  spi_clk, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  spi_miso, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  spi_mosi, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  spi_cs_esp_n, // ESP32 IO10 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  spi_cs_flash_n, // ESP32 IO01 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Other ESP32 connections 
														 | 
														
														 | 
														
															     // Other ESP32 connections 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  esp_io0, // ESP32 IO00 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  esp_int, // ESP32 IO09 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  esp_io0, // ESP32 IO00 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  esp_int, // ESP32 IO09 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // I2C bus (RTC and external) 
														 | 
														
														 | 
														
															     // I2C bus (RTC and external) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  i2c_scl, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  i2c_sda, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  rtc_32khz, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  rtc_int_n, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  i2c_scl, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  i2c_sda, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  rtc_32khz, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  rtc_int_n, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // LEDs 
														 | 
														
														 | 
														
															     // LEDs 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output [2:0]  led, 
														 | 
														
														 | 
														
															     output [2:0]  led, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // USB 
														 | 
														
														 | 
														
															     // USB 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  usb_dp, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  usb_dn, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  usb_pu, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  usb_rx, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    input 	  usb_rx_ok, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  usb_dp, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  usb_dn, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  usb_pu, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  usb_rx, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    input	  usb_rx_ok, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // HDMI 
														 | 
														
														 | 
														
															     // HDMI 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output [2:0]  hdmi_d, 
														 | 
														
														 | 
														
															     output [2:0]  hdmi_d, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  hdmi_clk, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  hdmi_scl, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  hdmi_sda, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    inout 	  hdmi_hpd, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  hdmi_clk, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  hdmi_scl, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  hdmi_sda, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    inout	  hdmi_hpd, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Unconnected pins with pullups, used for randomness 
														 | 
														
														 | 
														
															     // Unconnected pins with pullups, used for randomness 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     inout [2:0]   rngio, 
														 | 
														
														 | 
														
															     inout [2:0]   rngio, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // Various clocks available to the top level as well as internally 
														 | 
														
														 | 
														
															     // Various clocks available to the top level as well as internally 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sdram_clk, // 168 MHz SDRAM clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  sys_clk, //  84 MHz System clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  flash_clk, // 134 MHz Serial flash ROM clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  usb_clk, //  48 MHz USB clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  vid_clk, //  56 MHz Video pixel clock 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    output 	  vid_hdmiclk	// 280 MHz HDMI serializer clock = vid_clk x 5 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sdram_clk, // 168 MHz SDRAM clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  sys_clk, //  84 MHz System clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  flash_clk, // 134 MHz Serial flash ROM clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  usb_clk, //  48 MHz USB clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  vid_clk, //  56 MHz Video pixel clock 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    output	  vid_hdmiclk	// 280 MHz HDMI serializer clock = vid_clk x 5 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ); 
														 | 
														
														 | 
														
															     ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // ----------------------------------------------------------------------- 
														 | 
														
														 | 
														
															    // ----------------------------------------------------------------------- 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -138,10 +138,10 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // ----------------------------------------------------------------------- 
														 | 
														
														 | 
														
															    // ----------------------------------------------------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    reg			    rst_n        = 1'b0; // Internal system reset 
														 | 
														
														 | 
														
															    reg			    rst_n        = 1'b0; // Internal system reset 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    reg			    hard_rst_n   = 1'b0; // Strict POR reset only 
														 | 
														
														 | 
														
															    reg			    hard_rst_n   = 1'b0; // Strict POR reset only 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire 		    reconfig_rst;	 // Reconfigure FPGA 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire			    reconfig_rst;	 // Reconfigure FPGA 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    assign reset_plls = 1'b0; 
														 | 
														
														 | 
														
															    assign reset_plls = 1'b0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    tri1 [4:1]		    pll_locked; 
														 | 
														
														 | 
														
															    tri1 [4:1]		    pll_locked; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    assign   pll_locked[2] = master_pll_locked; 
														 | 
														
														 | 
														
															    assign   pll_locked[2] = master_pll_locked; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -219,7 +219,7 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    reg [3:1]  reset_cmd_q = 3'b0; 
														 | 
														
														 | 
														
															    reg [3:1]  reset_cmd_q = 3'b0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    assign reconfig_rst = reset_cmd_q[3]; 
														 | 
														
														 | 
														
															    assign reconfig_rst = reset_cmd_q[3]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    always @(negedge all_plls_locked or posedge sys_clk) 
														 | 
														
														 | 
														
															    always @(negedge all_plls_locked or posedge sys_clk) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      if (~all_plls_locked) 
														 | 
														
														 | 
														
															      if (~all_plls_locked) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															        begin 
														 | 
														
														 | 
														
															        begin 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -287,7 +287,7 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // Internal CPU bus 
														 | 
														
														 | 
														
															    // Internal CPU bus 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // 
														 | 
														
														 | 
														
															    // 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire			      cpu_mem_valid; 
														 | 
														
														 | 
														
															    wire			      cpu_mem_valid; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire 		      cpu_mem_ready; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire			      cpu_mem_ready; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire			      cpu_mem_instr; 
														 | 
														
														 | 
														
															    wire			      cpu_mem_instr; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire [ 3:0]		      cpu_mem_wstrb; 
														 | 
														
														 | 
														
															    wire [ 3:0]		      cpu_mem_wstrb; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire [31:0]                cpu_mem_addr; 
														 | 
														
														 | 
														
															    wire [31:0]                cpu_mem_addr; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -487,13 +487,13 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // Reading the register shows the current set of pending interrupts. 
														 | 
														
														 | 
														
															    // Reading the register shows the current set of pending interrupts. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    assign sysreg_rdata[4] = cpu_irq; 
														 | 
														
														 | 
														
															    assign sysreg_rdata[4] = cpu_irq; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // CPU permanently hung? 
														 | 
														
														 | 
														
															    // CPU permanently hung? 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire	       cpu_trap; 
														 | 
														
														 | 
														
															    wire	       cpu_trap; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // Request to halt the CPU on the next instruction boundary 
														 | 
														
														 | 
														
															    // Request to halt the CPU on the next instruction boundary 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire        cpu_halt; 
														 | 
														
														 | 
														
															    wire        cpu_halt; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    always @(negedge rst_n or posedge sys_clk) 
														 | 
														
														 | 
														
															    always @(negedge rst_n or posedge sys_clk) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      if (~rst_n) 
														 | 
														
														 | 
														
															      if (~rst_n) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															        begin 
														 | 
														
														 | 
														
															        begin 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -574,10 +574,10 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire [31:0] fast_mem_rdata; 
														 | 
														
														 | 
														
															    wire [31:0] fast_mem_rdata; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire [SRAM_BITS-1:2] vjtag_sram_addr; 
														 | 
														
														 | 
														
															    wire [SRAM_BITS-1:2] vjtag_sram_addr; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire 		vjtag_sram_read; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire 		vjtag_sram_write; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire [31:0] 		vjtag_sram_rdata; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   wire [31:0] 		vjtag_sram_wdata; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire			vjtag_sram_read; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire			vjtag_sram_write; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire [31:0]		vjtag_sram_rdata; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   wire [31:0]		vjtag_sram_wdata; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    fast_mem #(.words_lg2(SRAM_BITS-2), 
														 | 
														
														 | 
														
															    fast_mem #(.words_lg2(SRAM_BITS-2), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	      .data_file("mif/sram.mif")) 
														 | 
														
														 | 
														
															 	      .data_file("mif/sram.mif")) 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -756,21 +756,31 @@ module max80 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire        serial_tx_full; 
														 | 
														
														 | 
														
															    wire        serial_tx_full; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    wire        serial_rx_break; 
														 | 
														
														 | 
														
															    wire        serial_rx_break; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   serial serial_tty ( 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .rst_n    ( hard_rst_n ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .clk      ( sys_clk ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .tx_valid ( iodev_valid_tty & 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-				  cpu_mem_addr[6:2] == 5'b00000 & 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-				  cpu_mem_wstrb[0] ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .tx_data  ( cpu_mem_wdata[7:0] ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .tty_rx   ( tty_data_in ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .tty_tx   ( tty_data_out ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .tx_full  ( serial_tx_full ), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      .rx_break ( tty_rxd_break_rst ) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		      ); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   serial #(.ENABLE_RX_DATA    (1'b0), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .ENABLE_RX_BREAK   (1'b1), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .ENABLE_TX_DATA    (1'b1), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .ENABLE_TX_BREAK   (1'b0), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .BAUDRATE_SETTABLE (1'b0), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .BAUDRATE          (921600), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	    .TTY_CLK           (84000000)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .rst_n    ( hard_rst_n ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .clk      ( sys_clk ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // Snoops USB TTY channel 0 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tx_wstrb ( iodev_valid_tty & 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		cpu_mem_addr[6:2] == 5'b00000 & 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		cpu_mem_wstrb[0] ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tx_data  ( cpu_mem_wdata[7:0] ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tx_flush ( 1'b0 ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .rx_flush ( 1'b0 ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tty_rx   ( tty_data_in ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tty_tx   ( tty_data_out ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .tx_full  ( serial_tx_full ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    .rx_break ( tty_rxd_break_rst ) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // If DTR# is asserted, block on full serial Tx FIFO; this allows 
														 | 
														
														 | 
														
															    // If DTR# is asserted, block on full serial Tx FIFO; this allows 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    // us to not lose debugging messages. 
														 | 
														
														 | 
														
															    // us to not lose debugging messages. 
														 |