max80.sv 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. //
  2. // Top level module for the FPGA on the MAX80 board by
  3. // Per Mårtensson and H. Peter Anvin
  4. //
  5. // This is for MAX80 as slave on the ABC-bus.
  6. //
  7. // Sharing JTAG pins (via JTAGEN)
  8. `undef SHARED_JTAG
  9. module max80 (
  10. // Clock oscillator
  11. input clock_48, // 48 MHz
  12. // ABC-bus
  13. input abc_clk, // ABC-bus 3 MHz clock
  14. input [15:0] abc_a, // ABC address bus
  15. inout [7:0] abc_d, // ABC data bus
  16. output abc_d_oe, // Data bus output enable
  17. input abc_rst_n, // ABC bus reset strobe
  18. input abc_cs_n, // ABC card select strobe
  19. input [4:0] abc_out_n, // OUT, C1-C4 strobe
  20. input [1:0] abc_inp_n, // INP, STATUS strobe
  21. input abc_xmemfl_n, // Memory read strobe
  22. input abc_xmemw800_n, // Memory write strobe (ABC800)
  23. input abc_xmemw80_n, // Memory write strobe (ABC80)
  24. input abc_xinpstb_n, // I/O read strobe (ABC800)
  25. input abc_xoutpstb_n, // I/O write strobe (ABC80)
  26. // The following are inverted versus the bus IF
  27. // the corresponding MOSFETs are installed
  28. output abc_rdy_x, // RDY = WAIT#
  29. output abc_resin_x, // System reset request
  30. output abc_int80_x, // System INT request (ABC80)
  31. output abc_int800_x, // System INT request (ABC800)
  32. output abc_nmi_x, // System NMI request (ABC800)
  33. output abc_xm_x, // System memory override (ABC800)
  34. // Master/slave control
  35. output abc_master, // 1 = master, 0 = slave
  36. output abc_a_oe,
  37. // Bus isolation
  38. output abc_d_ce_n,
  39. // ABC-bus extension header
  40. // (Note: cannot use an array here because HC and HH are
  41. // input only.)
  42. inout exth_ha,
  43. inout exth_hb,
  44. input exth_hc,
  45. inout exth_hd,
  46. inout exth_he,
  47. inout exth_hf,
  48. inout exth_hg,
  49. input exth_hh,
  50. // SDRAM bus
  51. output sr_clk,
  52. output sr_cke,
  53. output [1:0] sr_ba, // Bank address
  54. output [12:0] sr_a, // Address within bank
  55. inout [15:0] sr_dq, // Also known as D or IO
  56. output [1:0] sr_dqm, // DQML and DQMH
  57. output sr_cs_n,
  58. output sr_we_n,
  59. output sr_cas_n,
  60. output sr_ras_n,
  61. // SD card
  62. output sd_clk,
  63. output sd_cmd,
  64. inout [3:0] sd_dat,
  65. // USB serial (naming is FPGA as DCE)
  66. input tty_txd,
  67. output tty_rxd,
  68. input tty_rts,
  69. output tty_cts,
  70. input tty_dtr,
  71. // SPI flash memory (also configuration)
  72. output flash_cs_n,
  73. output flash_clk,
  74. output flash_mosi,
  75. input flash_miso,
  76. // SPI bus (connected to ESP32 so can be bidirectional)
  77. inout spi_clk,
  78. inout spi_miso,
  79. inout spi_mosi,
  80. inout spi_cs_esp_n, // ESP32 IO10
  81. inout spi_cs_flash_n, // ESP32 IO01
  82. // Other ESP32 connections
  83. inout esp_io0, // ESP32 IO00
  84. inout esp_int, // ESP32 IO09
  85. // I2C bus (RTC and external)
  86. inout i2c_scl,
  87. inout i2c_sda,
  88. input rtc_32khz,
  89. input rtc_int_n,
  90. // LED (2 = D23/G, 1 = D22/R, 0 = D17/B)
  91. output [2:0] led,
  92. // GPIO pins
  93. inout [5:0] gpio,
  94. // HDMI
  95. output [2:0] hdmi_d,
  96. output hdmi_clk,
  97. inout hdmi_scl,
  98. inout hdmi_sda,
  99. inout hdmi_hpd
  100. );
  101. // Set if MOSFETs Q1-Q6 are installed rather than the corresponding
  102. // resistors.
  103. parameter [6:1] mosfet_installed = 6'b000_000;
  104. // PLL and reset
  105. parameter reset_pow2 = 12; // Assert internal reset for 4096 cycles after PLL lock
  106. reg [reset_pow2-1:0] rst_ctr = 1'b0;
  107. reg rst_n = 1'b0; // Internal reset
  108. wire [1:0] pll_locked;
  109. // Clocks
  110. wire sdram_clk;
  111. wire sys_clk; // System clock
  112. wire vid_clk; // Video pixel clock
  113. wire vid_hdmiclk; // D:o in the HDMI clock domain
  114. wire tty_clk = vid_clk; // 48 MHz
  115. pll pll (
  116. .areset ( 1'b0 ),
  117. .inclk0 ( clock_48 ),
  118. .c0 ( sdram_clk ), // SDRAM clock (168 MHz)
  119. .c1 ( sys_clk ), // System clock (84 MHz)
  120. .c2 ( vid_clk ), // Video pixel clock (48 MHz)
  121. .locked ( pll_locked[0] ),
  122. .phasestep ( 1'b0 ),
  123. .phasecounterselect ( 3'b0 ),
  124. .phaseupdown ( 1'b1 ),
  125. .scanclk ( 1'b0 ),
  126. .phasedone ( )
  127. );
  128. wire all_plls_locked = &pll_locked;
  129. always @(negedge all_plls_locked or posedge sys_clk)
  130. if (~&all_plls_locked)
  131. begin
  132. rst_ctr <= 1'b0;
  133. rst_n <= 1'b0;
  134. end
  135. else if (~rst_n)
  136. begin
  137. { rst_n, rst_ctr } <= rst_ctr + 1'b1;
  138. end
  139. // Unused device stubs - remove when used
  140. // Reset in the video clock domain
  141. reg vid_rst_n;
  142. always @(negedge all_plls_locked or posedge vid_clk)
  143. if (~all_plls_locked)
  144. vid_rst_n <= 1'b0;
  145. else
  146. vid_rst_n <= rst_n;
  147. // HDMI - generate random data to give Quartus something to do
  148. reg [23:0] dummydata = 30'hc8_fb87;
  149. always @(posedge vid_clk)
  150. dummydata <= { dummydata[22:0], dummydata[23] };
  151. wire [7:0] hdmi_data[3];
  152. wire [9:0] hdmi_tmds[3];
  153. wire [29:0] hdmi_to_tx;
  154. assign hdmi_data[0] = dummydata[7:0];
  155. assign hdmi_data[1] = dummydata[15:8];
  156. assign hdmi_data[2] = dummydata[23:16];
  157. generate
  158. genvar i;
  159. for (i = 0; i < 3; i = i + 1)
  160. begin : hdmitmds
  161. tmdsenc enc (
  162. .rst_n ( vid_rst_n ),
  163. .clk ( vid_clk ),
  164. .den ( 1'b1 ),
  165. .d ( hdmi_data[i] ),
  166. .c ( 2'b00 ),
  167. .q ( hdmi_tmds[i] )
  168. );
  169. end
  170. endgenerate
  171. assign hdmi_scl = 1'bz;
  172. assign hdmi_sck = 1'bz;
  173. assign hdmi_hpd = 1'bz;
  174. //
  175. // The ALTLVDS_TX megafunctions is MSB-first and in time-major order.
  176. // However, TMDS is LSB-first, and we have three TMDS words that
  177. // concatenate in word(channel)-major order.
  178. //
  179. transpose #(.words(3), .bits(10), .reverse_b(1),
  180. .reg_d(0), .reg_q(0)) hdmitranspose
  181. (
  182. .clk ( vid_clk ),
  183. .d ( { hdmi_tmds[2], hdmi_tmds[1], hdmi_tmds[0] } ),
  184. .q ( hdmi_to_tx )
  185. );
  186. hdmitx hdmitx (
  187. .pll_areset ( ~pll_locked[0] ),
  188. .tx_in ( hdmi_to_tx ),
  189. .tx_inclock ( vid_clk ),
  190. .tx_coreclock ( vid_hdmiclk ), // Pixel clock in HDMI domain
  191. .tx_locked ( pll_locked[1] ),
  192. .tx_out ( hdmi_d ),
  193. .tx_outclock ( hdmi_clk )
  194. );
  195. // ABC bus
  196. // On ABC800, only one of XINPSTB# or XOUTPSTB# will be active;
  197. // on ABC80 they will either be 00 or ZZ; in the latter case pulled
  198. // low by external resistors.
  199. wire abc800 = abc_xinpstb_n | abc_xoutpstb_n;
  200. wire abc80 = ~abc800;
  201. // Memory read/write strobes
  202. wire abc_xmemrd = ~abc_xmemfl_n; // For consistency
  203. wire abc_xmemwr = abc800 ? ~abc_xmemw800_n : ~abc_xmemw80_n;
  204. // I/O read/write strobes
  205. wire abc_iord = (abc800 & ~abc_xinpstb_n) | ~(|abc_inp_n);
  206. wire abc_iowr = (abc800 & ~abc_xoutpstb_n) | ~(|abc_out_n);
  207. reg [7:0] abc_do;
  208. reg [7:0] abc_di;
  209. assign abc_d_oe = abc_xmemrd;
  210. assign abc_d = abc_d_oe ? abc_do : 8'hzz;
  211. // Open drain signals with optional MOSFETs
  212. wire abc_wait;
  213. wire abc_resin;
  214. wire abc_int;
  215. wire abc_nmi;
  216. wire abc_xm;
  217. function reg opt_mosfet(input signal, input mosfet);
  218. if (mosfet)
  219. opt_mosfet = signal;
  220. else
  221. opt_mosfet = signal ? 1'b0 : 1'bz;
  222. endfunction // opt_mosfet
  223. assign abc_int80_x = opt_mosfet(abc_int & abc80, mosfet_installed[1]);
  224. assign abc_rdy_x = opt_mosfet(abc_wait, mosfet_installed[2]);
  225. assign abc_nmi_x = opt_mosfet(abc_nmi, mosfet_installed[3]);
  226. assign abc_resin_x = opt_mosfet(abc_resin, mosfet_installed[4]);
  227. assign abc_int800_x = opt_mosfet(abc_int & abc800, mosfet_installed[5]);
  228. assign abc_xm_x = opt_mosfet(abc_xm, mosfet_installed[6]);
  229. // ABC-bus extension header (exth_c and exth_h are input only)
  230. // The naming of pins is kind of nonsensical:
  231. //
  232. // +3V3 - 1 2 - +3V3
  233. // HA - 3 4 - HE
  234. // HB - 5 6 - HG
  235. // HC - 7 8 - HH
  236. // HD - 9 10 - HF
  237. // GND - 11 12 - GND
  238. //
  239. // This layout allows the header to be connected on either side
  240. // of the board. This logic assigns the following names to the pins;
  241. // if the ext_reversed is set to 1 then the left and right sides
  242. // are flipped.
  243. //
  244. // +3V3 - 1 2 - +3V3
  245. // exth[0] - 3 4 - exth[1]
  246. // exth[2] - 5 6 - exth[3]
  247. // exth[6] - 7 8 - exth[7]
  248. // exth[4] - 9 10 - exth[5]
  249. // GND - 11 12 - GND
  250. wire exth_reversed = 1'b0;
  251. wire [7:0] exth_d; // Input data
  252. wire [5:0] exth_q; // Output data
  253. wire [5:0] exth_oe; // Output enable
  254. assign exth_d[0] = exth_reversed ? exth_he : exth_ha;
  255. assign exth_d[1] = exth_reversed ? exth_ha : exth_he;
  256. assign exth_d[2] = exth_reversed ? exth_hg : exth_hb;
  257. assign exth_d[3] = exth_reversed ? exth_hb : exth_hg;
  258. assign exth_d[4] = exth_reversed ? exth_hf : exth_hd;
  259. assign exth_d[5] = exth_reversed ? exth_hd : exth_hf;
  260. assign exth_d[6] = exth_reversed ? exth_hh : exth_hc;
  261. assign exth_d[7] = exth_reversed ? exth_hc : exth_hh;
  262. wire [2:0] erx = { 2'b00, exth_reversed };
  263. assign exth_ha = exth_oe[3'd0 ^ erx] ? exth_q[3'd0 ^ erx] : 1'bz;
  264. assign exth_he = exth_oe[3'd1 ^ erx] ? exth_q[3'd1 ^ erx] : 1'bz;
  265. assign exth_hb = exth_oe[3'd2 ^ erx] ? exth_q[3'd2 ^ erx] : 1'bz;
  266. assign exth_hg = exth_oe[3'd3 ^ erx] ? exth_q[3'd3 ^ erx] : 1'bz;
  267. assign exth_hd = exth_oe[3'd4 ^ erx] ? exth_q[3'd4 ^ erx] : 1'bz;
  268. assign exth_hf = exth_oe[3'd5 ^ erx] ? exth_q[3'd5 ^ erx] : 1'bz;
  269. assign exth_q = 6'b0;
  270. assign exth_oe = 6'b0;
  271. // SDRAM controller
  272. reg abc_rrq;
  273. reg abc_wrq;
  274. reg abc_xmemrd_q;
  275. reg abc_xmemwr_q;
  276. reg abc_xmem_done;
  277. reg [9:0] abc_mempg;
  278. wire abc_rack;
  279. wire abc_wack;
  280. wire abc_rvalid;
  281. wire [7:0] abc_sr_rd;
  282. always @(posedge sdram_clk or negedge rst_n)
  283. if (~rst_n)
  284. begin
  285. abc_rrq <= 1'b0;
  286. abc_wrq <= 1'b0;
  287. abc_xmemrd_q <= 1'b0;
  288. abc_xmemwr_q <= 1'b0;
  289. abc_xmem_done <= 1'b0;
  290. abc_mempg <= 0;
  291. end
  292. else
  293. begin
  294. abc_di <= abc_d;
  295. abc_xmemrd_q <= abc_xmemrd;
  296. abc_xmemwr_q <= abc_xmemwr;
  297. abc_xmem_done <= (abc_xmemrd_q & (abc_xmem_done | abc_rack))
  298. | (abc_xmemwr_q & (abc_xmem_done | abc_wack));
  299. abc_rrq <= abc_xmemrd_q & ~(abc_xmem_done | abc_rack);
  300. abc_wrq <= abc_xmemwr_q & ~(abc_xmem_done | abc_wack);
  301. if (abc_rack & abc_rvalid)
  302. abc_do <= abc_sr_rd;
  303. // HACK FOR TESTING ONLY
  304. if (abc_iowr)
  305. abc_mempg <= { abc_a[1:0], abc_di };
  306. end // else: !if(~rst_n)
  307. sdram sdram (
  308. .rst_n ( rst_n ),
  309. .clk ( sdram_clk ), // Input clock
  310. .sr_clk ( sr_clk ), // Output clock buffer
  311. .sr_cke ( sr_cke ),
  312. .sr_cs_n ( sr_cs_n ),
  313. .sr_ras_n ( sr_ras_n ),
  314. .sr_cas_n ( sr_cas_n ),
  315. .sr_we_n ( sr_we_n ),
  316. .sr_dqm ( sr_dqm ),
  317. .sr_ba ( sr_ba ),
  318. .sr_a ( sr_a ),
  319. .sr_dq ( sr_dq ),
  320. .a0 ( { abc_mempg, abc_a } ),
  321. .rd0 ( abc_sr_rd ),
  322. .rrq0 ( abc_rrq ),
  323. .rack0 ( abc_rack ),
  324. .rvalid0 ( abc_rvalid ),
  325. .wd0 ( abc_d ),
  326. .wrq0 ( abc_wrq ),
  327. .wack0 ( abc_wack ),
  328. .a1 ( 24'hxxxxxx ),
  329. .be1 ( 8'b0000_0000 ),
  330. .rd1 ( ),
  331. .rrq1 ( 1'b0 ),
  332. .rack1 ( ),
  333. .rvalid1 ( ),
  334. .wd1 ( 32'hxxxx_xxxx ),
  335. .wrq1 ( 1'b0 ),
  336. .wack1 ( )
  337. );
  338. // SD card
  339. assign sd_clk = 1'b1;
  340. assign sd_cmd = 1'b1;
  341. assign sd_dat = 4'hz;
  342. // SPI bus (free for ESP32)
  343. assign spi_clk = 1'bz;
  344. assign spi_miso = 1'bz;
  345. assign spi_mosi = 1'bz;
  346. assign spi_cs_esp_n = 1'bz;
  347. assign spi_cs_flash_n = 1'bz;
  348. // ESP32
  349. assign esp_io0 = 1'bz;
  350. assign esp_int = 1'bz;
  351. // I2C
  352. assign i2c_scl = 1'bz;
  353. assign i2c_sda = 1'bz;
  354. // GPIO
  355. assign gpio = 6'bzzzzzz;
  356. // Embedded RISC-V CPU
  357. parameter cpu_fast_mem_bits = 11; /* 2^[this] * 4 bytes */
  358. wire cpu_mem_valid;
  359. wire cpu_mem_instr;
  360. wire [ 3:0] cpu_mem_wstrb;
  361. wire [31:0] cpu_mem_addr;
  362. wire [31:0] cpu_mem_wdata;
  363. reg [31:0] cpu_mem_rdata;
  364. wire cpu_mem_read = cpu_mem_valid & ~|cpu_mem_wstrb;
  365. wire cpu_la_read;
  366. wire cpu_la_write;
  367. wire [31:0] cpu_la_addr;
  368. wire [31:0] cpu_la_wdata;
  369. wire [ 3:0] cpu_la_wstrb;
  370. picorv32 #(
  371. .ENABLE_COUNTERS ( 1 ),
  372. .ENABLE_COUNTERS64 ( 1 ),
  373. .ENABLE_REGS_16_31 ( 1 ),
  374. .ENABLE_REGS_DUALPORT ( 1 ),
  375. .LATCHED_MEM_RDATA ( 1 ),
  376. .BARREL_SHIFTER ( 1 ),
  377. .TWO_CYCLE_COMPARE ( 0 ),
  378. .TWO_CYCLE_ALU ( 0 ),
  379. .COMPRESSED_ISA ( 1 ),
  380. .CATCH_MISALIGN ( 1 ),
  381. .CATCH_ILLINSN ( 1 ),
  382. .ENABLE_FAST_MUL ( 1 ),
  383. .ENABLE_DIV ( 1 ),
  384. .ENABLE_IRQ ( 1 ),
  385. .ENABLE_IRQ_QREGS ( 1 ),
  386. .ENABLE_IRQ_TIMER ( 1 ),
  387. .REGS_INIT_ZERO ( 1 ),
  388. .STACKADDR ( 32'h4 << cpu_fast_mem_bits )
  389. )
  390. cpu (
  391. .clk ( sys_clk ),
  392. .resetn ( rst_n ),
  393. .trap ( ),
  394. .mem_instr ( cpu_mem_instr ),
  395. .mem_ready ( cpu_mem_ready ),
  396. .mem_valid ( cpu_mem_valid ),
  397. .mem_wstrb ( cpu_mem_wstrb ),
  398. .mem_addr ( cpu_mem_addr ),
  399. .mem_wdata ( cpu_mem_wdata ),
  400. .mem_rdata ( cpu_mem_rdata ),
  401. .mem_la_read ( cpu_la_read ),
  402. .mem_la_write ( cpu_la_write ),
  403. .mem_la_wdata ( cpu_la_wdata ),
  404. .mem_la_addr ( cpu_la_addr ),
  405. .mem_la_wstrb ( cpu_la_wstrb ),
  406. .irq ( 0 ),
  407. .eoi ( )
  408. );
  409. // cpu_mem_ready is always true for fast memory
  410. assign cpu_mem_ready = cpu_mem_valid;
  411. // Memory valid flag by quadrant
  412. wire [3:0] mem_quad = cpu_mem_valid << cpu_mem_addr[31:30];
  413. //
  414. // Fast memory. This runs on the SDRAM clock, i.e. 2x the speed
  415. // of the CPU. The .bits parameter gives the number of dwords
  416. // as a power of 2, i.e. 11 = 2^11 * 4 = 8K.
  417. //
  418. wire [31:0] fast_mem_rdata;
  419. fast_mem // #(.bits(cpu_fast_mem_bits), .mif("../fw/boot"))
  420. fast_mem(
  421. .rst_n ( rst_n ),
  422. .clk ( sys_clk ),
  423. .read ( cpu_la_read & cpu_la_addr[31:30] == 2'b00 ),
  424. .write ( cpu_la_write & cpu_la_addr[31:30] == 2'b00 ),
  425. .wstrb ( cpu_la_wstrb ),
  426. .addr ( cpu_la_addr[12:2] ),
  427. .wdata ( cpu_la_wdata ),
  428. .rdata ( fast_mem_rdata )
  429. );
  430. always @(*)
  431. case (cpu_mem_addr[31:30])
  432. 2'b00: cpu_mem_rdata = fast_mem_rdata;
  433. default: cpu_mem_rdata = 32'hxxxx_xxxx;
  434. endcase // case (cpu_mem_addr[31:30])
  435. // Decode for small devices; use address space within range of
  436. // negative offsets from the zero register [-1K,0)
  437. wire [15:0] iodev = mem_quad[3] << cpu_mem_addr[9:6];
  438. // LED indication from the CPU
  439. reg [2:0] led_q;
  440. always @(negedge rst_n or posedge sys_clk)
  441. if (~rst_n)
  442. led_q <= 3'b000;
  443. else
  444. if ( iodev[0] & cpu_mem_wstrb[0] )
  445. led_q <= cpu_mem_wdata[2:0];
  446. assign led = led_q;
  447. //
  448. // Serial port. Direct to the CP2102N for reworked
  449. // boards or to GPIO for non-reworked boards, depending on
  450. // whether DTR# is asserted on either.
  451. //
  452. // The GPIO numbering matches the order of pins for FT[2]232H.
  453. // gpio[0] - TxD
  454. // gpio[1] - RxD
  455. // gpio[2] - RTS#
  456. // gpio[3] - CTS#
  457. // gpio[4] - DTR#
  458. //
  459. wire tty_data_out; // Output data
  460. wire tty_data_in; // Input data
  461. wire tty_cts_out; // Assert CTS# externally
  462. wire tty_rts_in; // RTS# received from outside
  463. assign tty_cts_out = 1'b0; // Assert CTS#
  464. tty tty (
  465. .rst_n ( rst_n ),
  466. .sys_clk ( sys_clk ),
  467. .tty_clk ( tty_clk ),
  468. .valid ( iodev[1] ),
  469. .wstrb ( cpu_mem_wstrb ),
  470. .wdata ( cpu_mem_wdata ),
  471. .addr ( cpu_mem_addr[2] ),
  472. .tty_txd ( tty_data_out ) // DTE -> DCE
  473. );
  474. reg [1:0] tty_dtr_q;
  475. always @(posedge tty_clk)
  476. begin
  477. tty_dtr_q[0] <= tty_dtr;
  478. tty_dtr_q[1] <= gpio[4];
  479. end
  480. //
  481. // Route data to the two output ports
  482. //
  483. // tty_rxd because pins are DCE named
  484. assign tty_data_in = (tty_txd | tty_dtr_q[0]) &
  485. (gpio[0] | tty_dtr_q[1]);
  486. assign tty_rxd = tty_dtr_q[0] ? 1'bz : tty_data_out;
  487. assign gpio[1] = tty_dtr_q[1] ? 1'bz : tty_data_out;
  488. assign tty_rts_in = (tty_rts | tty_dtr_q[0]) &
  489. (gpio[2] | tty_dtr_q[1]);
  490. assign tty_cts = tty_dtr_q[0] ? 1'bz : tty_cts_out;
  491. assign gpio[3] = tty_dtr_q[1] ? 1'bz : tty_cts_out;
  492. endmodule