e1_tx_liu.v 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * e1_tx_liu.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * E1 RX interface to external LIU
  7. *
  8. *
  9. * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
  10. * All rights reserved.
  11. *
  12. * LGPL v3+, see LICENSE.lgpl3
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU Lesser General Public
  16. * License as published by the Free Software Foundation; either
  17. * version 3 of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public License
  25. * along with this program; if not, write to the Free Software Foundation,
  26. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  27. */
  28. `default_nettype none
  29. module e1_tx_liu (
  30. // Pads
  31. input wire pad_tx_data,
  32. input wire pad_tx_clk,
  33. // Intput
  34. input wire in_data,
  35. input wire in_valid,
  36. // Common
  37. input wire clk,
  38. input wire rst
  39. );
  40. // Signals
  41. reg [5:0] cnt_cur;
  42. reg [5:0] cnt_nxt;
  43. reg tx_data;
  44. wire tx_clk;
  45. // Counters
  46. always @(posedge clk)
  47. if (in_valid)
  48. cnt_nxt <= 0;
  49. else
  50. cnt_nxt <= cnt_nxt + 1;
  51. always @(posedge clk)
  52. if (in_valid)
  53. cnt_cur <= { 1'b1, cnt_nxt[5:1] };
  54. else
  55. cnt_cur <= cnt_cur - 1;
  56. // TX
  57. always @(posedge clk)
  58. if (in_valid)
  59. tx_data <= in_data;
  60. assign tx_clk = cnt_cur[5];
  61. // IOBs (registered)
  62. SB_IO #(
  63. .PIN_TYPE(6'b0101_00),
  64. .PULLUP(1'b0),
  65. .NEG_TRIGGER(1'b0)
  66. ) tx_data_iob_I (
  67. .PACKAGE_PIN(pad_tx_data),
  68. .LATCH_INPUT_VALUE(1'b0),
  69. .CLOCK_ENABLE(1'b1),
  70. .INPUT_CLK(1'b0),
  71. .OUTPUT_CLK(clk),
  72. .OUTPUT_ENABLE(1'b1),
  73. .D_OUT_0(tx_data),
  74. .D_OUT_1(1'b0),
  75. .D_IN_0(),
  76. .D_IN_1()
  77. );
  78. SB_IO #(
  79. .PIN_TYPE(6'b0101_00),
  80. .PULLUP(1'b0),
  81. .NEG_TRIGGER(1'b0)
  82. ) tx_clk_iob_I (
  83. .PACKAGE_PIN(pad_tx_clk),
  84. .LATCH_INPUT_VALUE(1'b0),
  85. .CLOCK_ENABLE(1'b1),
  86. .INPUT_CLK(1'b0),
  87. .OUTPUT_CLK(clk),
  88. .OUTPUT_ENABLE(1'b1),
  89. .D_OUT_0(tx_clk),
  90. .D_OUT_1(1'b0),
  91. .D_IN_0(),
  92. .D_IN_1()
  93. );
  94. endmodule // e1_tx_liu