hdmi_phy_2x.v 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. SB_IO #(
  62. .PIN_TYPE (6'b0100_11),
  63. .PULLUP (1'b0),
  64. .NEG_TRIGGER (1'b0),
  65. .IO_STANDARD ("SB_LVCMOS")
  66. ) iob_hdmi_data_I[DW-1:0] (
  67. .PACKAGE_PIN (hdmi_data),
  68. .OUTPUT_CLK (clk_1x),
  69. .D_OUT_0 (in_data0),
  70. .D_OUT_1 (in_data1d)
  71. );
  72. // H-Sync / V-Sync / DE
  73. SB_IO #(
  74. .PIN_TYPE (6'b0101_11),
  75. .PULLUP (1'b0),
  76. .NEG_TRIGGER (1'b0),
  77. .IO_STANDARD ("SB_LVCMOS")
  78. ) iob_hdmi_ctrl_I (
  79. .PACKAGE_PIN ({hdmi_hsync, hdmi_vsync, hdmi_de}),
  80. .OUTPUT_CLK (clk_1x),
  81. .D_OUT_0 ({in_hsync, in_vsync, in_de})
  82. );
  83. // Clock
  84. SB_IO #(
  85. .PIN_TYPE (6'b0100_11),
  86. .PULLUP (1'b0),
  87. .NEG_TRIGGER (1'b0),
  88. .IO_STANDARD ("SB_LVCMOS")
  89. ) iob_hdmi_clk_I (
  90. .PACKAGE_PIN (hdmi_clk),
  91. .OUTPUT_CLK (clk_2x),
  92. .D_OUT_0 (1'b0),
  93. .D_OUT_1 (1'b1)
  94. );
  95. endmodule // hdmi_phy_2x