hdmi_phy_2x.v 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * hdmi_phy_2x.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * HDMI PHY using DDR output to push 2 pixels at once allowing FPGA code
  7. * to run at half the pixel clock.
  8. *
  9. * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
  10. * All rights reserved.
  11. *
  12. * BSD 3-clause, see LICENSE.bsd
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. * * Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. * * Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. * * Neither the name of the <organization> nor the
  22. * names of its contributors may be used to endorse or promote products
  23. * derived from this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  26. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  29. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  32. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  34. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. `default_nettype none
  37. module hdmi_phy_2x #(
  38. parameter integer DW = 4
  39. )(
  40. // HDMI pads
  41. output wire [DW-1:0] hdmi_data,
  42. output wire hdmi_hsync,
  43. output wire hdmi_vsync,
  44. output wire hdmi_de,
  45. output wire hdmi_clk,
  46. // Input from fabric
  47. input wire [DW-1:0] in_data0,
  48. input wire [DW-1:0] in_data1,
  49. input wire in_hsync,
  50. input wire in_vsync,
  51. input wire in_de,
  52. // Clocks
  53. input wire clk_1x,
  54. input wire clk_2x
  55. );
  56. reg [DW-1:0] in_data1d;
  57. // Delay second pixel (falling edge one)
  58. always @(posedge clk_1x)
  59. in_data1d <= in_data1;
  60. // Data bits
  61. genvar i;
  62. generate
  63. for (i=0; i<DW; i=i+1)
  64. begin : bit
  65. SB_IO #(
  66. .PIN_TYPE(6'b010000),
  67. .PULLUP(1'b0),
  68. .NEG_TRIGGER(1'b0),
  69. .IO_STANDARD("SB_LVCMOS")
  70. ) iob_hdmi_data_I (
  71. .PACKAGE_PIN(hdmi_data[i]),
  72. .CLOCK_ENABLE(1'b1),
  73. .OUTPUT_CLK(clk_1x),
  74. .D_OUT_0(in_data0[i]),
  75. .D_OUT_1(in_data1d[i])
  76. );
  77. end
  78. endgenerate
  79. // H-Sync
  80. SB_IO #(
  81. .PIN_TYPE(6'b010100),
  82. .PULLUP(1'b0),
  83. .NEG_TRIGGER(1'b0),
  84. .IO_STANDARD("SB_LVCMOS")
  85. ) iob_hdmi_hsync_I (
  86. .PACKAGE_PIN(hdmi_hsync),
  87. .CLOCK_ENABLE(1'b1),
  88. .OUTPUT_CLK(clk_1x),
  89. .D_OUT_0(in_hsync)
  90. );
  91. // V-Sync
  92. SB_IO #(
  93. .PIN_TYPE(6'b010100),
  94. .PULLUP(1'b0),
  95. .NEG_TRIGGER(1'b0),
  96. .IO_STANDARD("SB_LVCMOS")
  97. ) iob_hdmi_vsync_I (
  98. .PACKAGE_PIN(hdmi_vsync),
  99. .CLOCK_ENABLE(1'b1),
  100. .OUTPUT_CLK(clk_1x),
  101. .D_OUT_0(in_vsync)
  102. );
  103. // DE
  104. SB_IO #(
  105. .PIN_TYPE(6'b010100),
  106. .PULLUP(1'b0),
  107. .NEG_TRIGGER(1'b0),
  108. .IO_STANDARD("SB_LVCMOS")
  109. ) iob_hdmi_de_I (
  110. .PACKAGE_PIN(hdmi_de),
  111. .CLOCK_ENABLE(1'b1),
  112. .OUTPUT_CLK(clk_1x),
  113. .D_OUT_0(in_de)
  114. );
  115. // Clock
  116. SB_IO #(
  117. .PIN_TYPE(6'b010000),
  118. .PULLUP(1'b0),
  119. .NEG_TRIGGER(1'b0),
  120. .IO_STANDARD("SB_LVCMOS")
  121. ) iob_hdmi_clk_I (
  122. .PACKAGE_PIN(hdmi_clk),
  123. .CLOCK_ENABLE(1'b1),
  124. .OUTPUT_CLK(clk_2x),
  125. .D_OUT_0(1'b0),
  126. .D_OUT_1(1'b1)
  127. );
  128. endmodule // hdmi_phy_2x