hub75_blanking.v 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * hub75_blanking.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
  7. * All rights reserved.
  8. *
  9. * LGPL v3+, see LICENSE.lgpl3
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 3 of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with this program; if not, write to the Free Software Foundation,
  23. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  24. */
  25. `default_nettype none
  26. module hub75_blanking #(
  27. parameter integer N_PLANES = 8
  28. )(
  29. // PHY
  30. output wire phy_blank,
  31. // Control
  32. input wire [N_PLANES-1:0] ctrl_plane,
  33. input wire ctrl_go,
  34. output wire ctrl_rdy,
  35. // Config
  36. input wire [7:0] cfg_bcm_bit_len,
  37. // Clock / Reset
  38. input wire clk,
  39. input wire rst
  40. );
  41. // Signals
  42. // -------
  43. wire active;
  44. wire plane_cnt_ce;
  45. reg [N_PLANES:0] plane_cnt;
  46. reg [7:0] bit_cnt;
  47. wire bit_cnt_trig;
  48. // Control
  49. // -------
  50. // Active
  51. assign active = plane_cnt[N_PLANES];
  52. // Plane length counter
  53. always @(posedge clk or posedge rst)
  54. if (rst)
  55. plane_cnt <= 0;
  56. else if (plane_cnt_ce)
  57. plane_cnt <= (ctrl_go ? { 1'b1, ctrl_plane } : plane_cnt) - 1;
  58. assign plane_cnt_ce = (bit_cnt_trig & active) | ctrl_go;
  59. // Base len bit counter
  60. always @(posedge clk)
  61. if (~active | bit_cnt_trig)
  62. bit_cnt <= cfg_bcm_bit_len;
  63. else
  64. bit_cnt <= bit_cnt - 1;
  65. assign bit_cnt_trig = bit_cnt[7];
  66. // Ready
  67. assign ctrl_rdy = ~active;
  68. // PHY
  69. // ---
  70. assign phy_blank = ~active;
  71. endmodule // hub75_blanking