multi_uart.v 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. module multi_uart #(parameter CNT = 5, DATA_WIDTH = 8, FIFO_DEPTH = 1) (
  2. input apb_clock,
  3. input apb_resetn,
  4. input apb_psel,
  5. input apb_penable,
  6. input apb_pwrite,
  7. input [11:0] apb_paddr,
  8. input [31:0] apb_pwdata,
  9. output [31:0] apb_prdata,
  10. output apb_pready,
  11. output [CNT-1:0] uart_txd,
  12. input [CNT-1:0] uart_rxd,
  13. input [CNT-1:0] tx_dma_clr,
  14. output [CNT-1:0] tx_dma_req,
  15. input [CNT-1:0] rx_dma_clr,
  16. output [CNT-1:0] rx_dma_req,
  17. output [CNT-1:0] interrupts,
  18. output [CNT-1:0] uart_tx_busy
  19. );
  20. wire uart_en;
  21. wire [15:0] ibrd;
  22. wire [5:0] fbrd;
  23. wire [CNT-1:0] clear_flags;
  24. wire [CNT-1:0] tx_write;
  25. wire [CNT-1:0] tx_full;
  26. wire [CNT-1:0] tx_empty;
  27. wire [CNT-1:0] tx_busy;
  28. wire [CNT-1:0] tx_complete;
  29. wire [CNT-1:0] tx_dma_en;
  30. wire [CNT-1:0] rx_read;
  31. wire [CNT-1:0] rx_full;
  32. wire [CNT-1:0] rx_empty;
  33. wire [CNT-1:0] rx_idle;
  34. wire [CNT-1:0] framing_error;
  35. wire [CNT-1:0] parity_error;
  36. wire [CNT-1:0] break_error;
  37. wire [CNT-1:0] overrun_error;
  38. wire [CNT-1:0] rx_dma_en;
  39. wire [DATA_WIDTH*CNT-1:0] rx_data;
  40. baud_gen u_baud(
  41. .clk (apb_clock ),
  42. .rstn (apb_resetn),
  43. .ibrd (ibrd ),
  44. .fbrd (fbrd ),
  45. .stop (!uart_en ),
  46. .baud16(baud16 )
  47. );
  48. uart_regs #(CNT, DATA_WIDTH) u_regs(
  49. .apb_clock (apb_clock ),
  50. .apb_resetn (apb_resetn ),
  51. .apb_psel (apb_psel ),
  52. .apb_penable(apb_penable),
  53. .apb_pwrite (apb_pwrite ),
  54. .apb_paddr (apb_paddr ),
  55. .apb_pwdata (apb_pwdata ),
  56. .apb_prdata (apb_prdata ),
  57. .apb_pready (apb_pready ),
  58. .uart_en (uart_en ),
  59. .ibrd (ibrd ),
  60. .fbrd (fbrd ),
  61. .tx_write (tx_write ),
  62. .rx_read (rx_read ),
  63. .rx_data (rx_data ),
  64. .tx_full (tx_full ),
  65. .tx_empty (tx_empty ),
  66. .tx_busy (tx_busy ),
  67. .tx_complete (tx_complete ),
  68. .rx_full (rx_full ),
  69. .rx_empty (rx_empty ),
  70. .rx_idle (rx_idle ),
  71. .framing_error(framing_error),
  72. .parity_error (parity_error ),
  73. .break_error (break_error ),
  74. .overrun_error(overrun_error),
  75. .clear_flags (clear_flags ),
  76. .lcr_sps (lcr_sps ),
  77. .lcr_stp2 (lcr_stp2 ),
  78. .lcr_eps (lcr_eps ),
  79. .lcr_pen (lcr_pen ),
  80. .rx_dma_en (rx_dma_en ),
  81. .tx_dma_en (tx_dma_en ),
  82. .interrupts (interrupts ),
  83. );
  84. uart_tx #(DATA_WIDTH, FIFO_DEPTH) u_tx[CNT-1:0](
  85. .clk (apb_clock ),
  86. .rstn (apb_resetn ),
  87. .baud16 (baud16 ),
  88. .tx_write (tx_write ),
  89. .tx_data (apb_pwdata[DATA_WIDTH-1:0]),
  90. .lcr_sps (lcr_sps ),
  91. .lcr_stp2 (lcr_stp2 ),
  92. .lcr_eps (lcr_eps ),
  93. .lcr_pen (lcr_pen ),
  94. .tx_clear (clear_flags ),
  95. .tx_full (tx_full ),
  96. .tx_empty (tx_empty ),
  97. .tx_busy (tx_busy ),
  98. .tx_complete(tx_complete ),
  99. .tx_dma_en (tx_dma_en ),
  100. .tx_dma_clr (tx_dma_clr ),
  101. .tx_dma_req (tx_dma_req ),
  102. .uart_txd (uart_txd )
  103. );
  104. uart_rx #(DATA_WIDTH, FIFO_DEPTH) u_rx[CNT-1:0](
  105. .clk (apb_clock ),
  106. .rstn (apb_resetn ),
  107. .baud16 (baud16 ),
  108. .lcr_sps (lcr_sps ),
  109. .lcr_stp2 (lcr_stp2 ),
  110. .lcr_eps (lcr_eps ),
  111. .lcr_pen (lcr_pen ),
  112. .rx_read (rx_read ),
  113. .rx_clear (clear_flags ),
  114. .rx_full (rx_full ),
  115. .rx_empty (rx_empty ),
  116. .rx_data (rx_data ),
  117. .rx_idle (rx_idle ),
  118. .framing_error(framing_error),
  119. .parity_error (parity_error ),
  120. .break_error (break_error ),
  121. .overrun_error(overrun_error),
  122. .rx_dma_en (rx_dma_en ),
  123. .rx_dma_clr (rx_dma_clr ),
  124. .rx_dma_req (rx_dma_req ),
  125. .uart_rxd (uart_rxd )
  126. );
  127. assign uart_tx_busy = tx_busy;
  128. endmodule