hub75_phy.v 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_N = 1, // # of PHY in //
  32. parameter integer PHY_AIR = 0, // PHY Address Inc/Reset
  33. // Auto-set
  34. parameter integer SDW = N_BANKS * N_CHANS,
  35. parameter integer LOG_N_ROWS = $clog2(N_ROWS)
  36. )(
  37. // Hub75 interface pads
  38. output wire [PHY_N-1:0] hub75_addr_inc,
  39. output wire [PHY_N-1:0] hub75_addr_rst,
  40. output wire [(PHY_N*LOG_N_ROWS)-1:0] hub75_addr,
  41. output wire [SDW-1 :0] hub75_data,
  42. output wire [PHY_N-1:0] hub75_clk,
  43. output wire [PHY_N-1:0] hub75_le,
  44. output wire [PHY_N-1:0] hub75_blank,
  45. // PHY interface signals
  46. input wire phy_addr_inc,
  47. input wire phy_addr_rst,
  48. input wire [LOG_N_ROWS-1:0] phy_addr,
  49. input wire [SDW-1:0] phy_data,
  50. input wire phy_clk,
  51. input wire phy_le,
  52. input wire phy_blank,
  53. // Clock / Reset
  54. input wire clk,
  55. input wire rst
  56. );
  57. // Signals
  58. reg phy_clk_f;
  59. // Address
  60. genvar i;
  61. generate
  62. if (PHY_AIR == 0) begin
  63. for (i=0; i<PHY_N; i=i+1)
  64. SB_IO #(
  65. .PIN_TYPE(6'b010100),
  66. .PULLUP(1'b0),
  67. .NEG_TRIGGER(1'b0),
  68. .IO_STANDARD("SB_LVCMOS")
  69. ) iob_addr_I[LOG_N_ROWS-1:0] (
  70. .PACKAGE_PIN(hub75_addr[i*LOG_N_ROWS+:LOG_N_ROWS]),
  71. .CLOCK_ENABLE(1'b1),
  72. .OUTPUT_CLK(clk),
  73. .D_OUT_0(phy_addr)
  74. );
  75. end else begin
  76. SB_IO #(
  77. .PIN_TYPE(6'b010100),
  78. .PULLUP(1'b0),
  79. .NEG_TRIGGER(1'b0),
  80. .IO_STANDARD("SB_LVCMOS")
  81. ) iob_addr_inc_I[PHY_N-1:0] (
  82. .PACKAGE_PIN(hub75_addr_inc),
  83. .CLOCK_ENABLE(1'b1),
  84. .OUTPUT_CLK(clk),
  85. .D_OUT_0(phy_addr_inc ^ PHY_AIR[1])
  86. );
  87. SB_IO #(
  88. .PIN_TYPE(6'b010100),
  89. .PULLUP(1'b0),
  90. .NEG_TRIGGER(1'b0),
  91. .IO_STANDARD("SB_LVCMOS")
  92. ) iob_addr_rst_I[PHY_N-1:0] (
  93. .PACKAGE_PIN(hub75_addr_rst),
  94. .CLOCK_ENABLE(1'b1),
  95. .OUTPUT_CLK(clk),
  96. .D_OUT_0(phy_addr_rst ^ PHY_AIR[2])
  97. );
  98. end
  99. endgenerate
  100. // Data lines
  101. SB_IO #(
  102. .PIN_TYPE(6'b010100),
  103. .PULLUP(1'b0),
  104. .NEG_TRIGGER(1'b0),
  105. .IO_STANDARD("SB_LVCMOS")
  106. ) iob_data_I[SDW-1:0] (
  107. .PACKAGE_PIN(hub75_data),
  108. .CLOCK_ENABLE(1'b1),
  109. .OUTPUT_CLK(clk),
  110. .D_OUT_0(phy_data)
  111. );
  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[PHY_N-1:0] (
  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[PHY_N-1:0] (
  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[PHY_N-1:0] (
  151. .PACKAGE_PIN(hub75_blank),
  152. .CLOCK_ENABLE(1'b1),
  153. .OUTPUT_CLK(clk),
  154. .D_OUT_0(phy_blank)
  155. );
  156. endmodule