hub75_phy.v 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * hub75_phy.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
  7. * Copyright (C) 2019 Piotr Esden-Tempski <piotr@esden.net>
  8. * All rights reserved.
  9. *
  10. * LGPL v3+, see LICENSE.lgpl3
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 3 of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public License
  23. * along with this program; if not, write to the Free Software Foundation,
  24. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. `default_nettype none
  27. module hub75_phy #(
  28. parameter integer N_BANKS = 2,
  29. parameter integer N_ROWS = 32,
  30. parameter integer N_CHANS = 3,
  31. parameter integer PHY_AIR = 0, // PHY Address Inc/Reset
  32. // Auto-set
  33. parameter integer LOG_N_ROWS = $clog2(N_ROWS)
  34. )(
  35. // Hub75 interface pads
  36. output wire hub75_addr_inc,
  37. output wire hub75_addr_rst,
  38. output wire [LOG_N_ROWS-1:0] hub75_addr,
  39. output wire [(N_BANKS*N_CHANS)-1:0] hub75_data,
  40. output wire hub75_clk,
  41. output wire hub75_le,
  42. output wire hub75_blank,
  43. // PHY interface signals
  44. input wire phy_addr_inc,
  45. input wire phy_addr_rst,
  46. input wire [LOG_N_ROWS-1:0] phy_addr,
  47. input wire [(N_BANKS*N_CHANS)-1:0] phy_data,
  48. input wire phy_clk,
  49. input wire phy_le,
  50. input wire phy_blank,
  51. // Clock / Reset
  52. input wire clk,
  53. input wire rst
  54. );
  55. genvar i;
  56. // Signals
  57. reg phy_clk_f;
  58. // Address
  59. generate
  60. if (PHY_AIR == 0) begin
  61. SB_IO #(
  62. .PIN_TYPE(6'b010100),
  63. .PULLUP(1'b0),
  64. .NEG_TRIGGER(1'b0),
  65. .IO_STANDARD("SB_LVCMOS")
  66. ) iob_addr_I[LOG_N_ROWS-1:0] (
  67. .PACKAGE_PIN(hub75_addr),
  68. .CLOCK_ENABLE(1'b1),
  69. .OUTPUT_CLK(clk),
  70. .D_OUT_0(phy_addr)
  71. );
  72. end else begin
  73. SB_IO #(
  74. .PIN_TYPE(6'b010100),
  75. .PULLUP(1'b0),
  76. .NEG_TRIGGER(1'b0),
  77. .IO_STANDARD("SB_LVCMOS")
  78. ) iob_addr_inc_I (
  79. .PACKAGE_PIN(hub75_addr_inc),
  80. .CLOCK_ENABLE(1'b1),
  81. .OUTPUT_CLK(clk),
  82. .D_OUT_0(phy_addr_inc ^ PHY_AIR[1])
  83. );
  84. SB_IO #(
  85. .PIN_TYPE(6'b010100),
  86. .PULLUP(1'b0),
  87. .NEG_TRIGGER(1'b0),
  88. .IO_STANDARD("SB_LVCMOS")
  89. ) iob_addr_rst_I (
  90. .PACKAGE_PIN(hub75_addr_rst),
  91. .CLOCK_ENABLE(1'b1),
  92. .OUTPUT_CLK(clk),
  93. .D_OUT_0(phy_addr_rst ^ PHY_AIR[2])
  94. );
  95. end
  96. endgenerate
  97. // Data lines
  98. generate
  99. for (i=0; i<(N_BANKS*N_CHANS); i=i+1)
  100. SB_IO #(
  101. .PIN_TYPE(6'b010100),
  102. .PULLUP(1'b0),
  103. .NEG_TRIGGER(1'b0),
  104. .IO_STANDARD("SB_LVCMOS")
  105. ) iob_data_I (
  106. .PACKAGE_PIN(hub75_data[i]),
  107. .CLOCK_ENABLE(1'b1),
  108. .OUTPUT_CLK(clk),
  109. .D_OUT_0(phy_data[i])
  110. );
  111. endgenerate
  112. // Falling edge clock, so we need one more delay so it's not too early !
  113. always @(posedge clk or posedge rst)
  114. if (rst) begin
  115. phy_clk_f <= 1'b0;
  116. end else begin
  117. phy_clk_f <= phy_clk;
  118. end
  119. // Clock DDR register
  120. SB_IO #(
  121. .PIN_TYPE(6'b010000),
  122. .PULLUP(1'b0),
  123. .NEG_TRIGGER(1'b0),
  124. .IO_STANDARD("SB_LVCMOS")
  125. ) iob_clk_I (
  126. .PACKAGE_PIN(hub75_clk),
  127. .CLOCK_ENABLE(1'b1),
  128. .OUTPUT_CLK(clk),
  129. .D_OUT_0(1'b0),
  130. .D_OUT_1(phy_clk_f)
  131. );
  132. // Latch
  133. SB_IO #(
  134. .PIN_TYPE(6'b010100),
  135. .PULLUP(1'b0),
  136. .NEG_TRIGGER(1'b0),
  137. .IO_STANDARD("SB_LVCMOS")
  138. ) iob_le_I (
  139. .PACKAGE_PIN(hub75_le),
  140. .CLOCK_ENABLE(1'b1),
  141. .OUTPUT_CLK(clk),
  142. .D_OUT_0(phy_le)
  143. );
  144. // Blanking
  145. SB_IO #(
  146. .PIN_TYPE(6'b010100),
  147. .PULLUP(1'b0),
  148. .NEG_TRIGGER(1'b0),
  149. .IO_STANDARD("SB_LVCMOS")
  150. ) iob_blank_I (
  151. .PACKAGE_PIN(hub75_blank),
  152. .CLOCK_ENABLE(1'b1),
  153. .OUTPUT_CLK(clk),
  154. .D_OUT_0(phy_blank)
  155. );
  156. endmodule