hub75_phy.v 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. // Auto-set
  32. parameter integer LOG_N_ROWS = $clog2(N_ROWS)
  33. )(
  34. // Hub75 interface pads
  35. output wire [LOG_N_ROWS-1:0] hub75_addr,
  36. output wire [(N_BANKS*N_CHANS)-1:0] hub75_data,
  37. output wire hub75_clk,
  38. output wire hub75_le,
  39. output wire hub75_blank,
  40. // PHY interface signals
  41. input wire [LOG_N_ROWS-1:0] phy_addr,
  42. input wire [(N_BANKS*N_CHANS)-1:0] phy_data,
  43. input wire phy_clk,
  44. input wire phy_le,
  45. input wire phy_blank,
  46. // Clock / Reset
  47. input wire clk,
  48. input wire rst
  49. );
  50. genvar i;
  51. // Signals
  52. reg phy_clk_f;
  53. // Address
  54. generate
  55. for (i=0; i<LOG_N_ROWS; i=i+1)
  56. SB_IO #(
  57. .PIN_TYPE(6'b010100),
  58. .PULLUP(1'b0),
  59. .NEG_TRIGGER(1'b0),
  60. .IO_STANDARD("SB_LVCMOS")
  61. ) iob_addr_I (
  62. .PACKAGE_PIN(hub75_addr[i]),
  63. .CLOCK_ENABLE(1'b1),
  64. .OUTPUT_CLK(clk),
  65. .D_OUT_0(phy_addr[i])
  66. );
  67. endgenerate
  68. // Data lines
  69. generate
  70. for (i=0; i<(N_BANKS*N_CHANS); i=i+1)
  71. SB_IO #(
  72. .PIN_TYPE(6'b010100),
  73. .PULLUP(1'b0),
  74. .NEG_TRIGGER(1'b0),
  75. .IO_STANDARD("SB_LVCMOS")
  76. ) iob_data_I (
  77. .PACKAGE_PIN(hub75_data[i]),
  78. .CLOCK_ENABLE(1'b1),
  79. .OUTPUT_CLK(clk),
  80. .D_OUT_0(phy_data[i])
  81. );
  82. endgenerate
  83. // Falling edge clock, so we need one more delay so it's not too early !
  84. always @(posedge clk or posedge rst)
  85. if (rst) begin
  86. phy_clk_f <= 1'b0;
  87. end else begin
  88. phy_clk_f <= phy_clk;
  89. end
  90. // Clock DDR register
  91. SB_IO #(
  92. .PIN_TYPE(6'b010000),
  93. .PULLUP(1'b0),
  94. .NEG_TRIGGER(1'b0),
  95. .IO_STANDARD("SB_LVCMOS")
  96. ) iob_clk_I (
  97. .PACKAGE_PIN(hub75_clk),
  98. .CLOCK_ENABLE(1'b1),
  99. .OUTPUT_CLK(clk),
  100. .D_OUT_0(1'b0),
  101. .D_OUT_1(phy_clk_f)
  102. );
  103. // Latch
  104. SB_IO #(
  105. .PIN_TYPE(6'b010100),
  106. .PULLUP(1'b0),
  107. .NEG_TRIGGER(1'b0),
  108. .IO_STANDARD("SB_LVCMOS")
  109. ) iob_le_I (
  110. .PACKAGE_PIN(hub75_le),
  111. .CLOCK_ENABLE(1'b1),
  112. .OUTPUT_CLK(clk),
  113. .D_OUT_0(phy_le)
  114. );
  115. // Blanking
  116. SB_IO #(
  117. .PIN_TYPE(6'b010100),
  118. .PULLUP(1'b0),
  119. .NEG_TRIGGER(1'b0),
  120. .IO_STANDARD("SB_LVCMOS")
  121. ) iob_blank_I (
  122. .PACKAGE_PIN(hub75_blank),
  123. .CLOCK_ENABLE(1'b1),
  124. .OUTPUT_CLK(clk),
  125. .D_OUT_0(phy_blank)
  126. );
  127. endmodule