e1_rx_liu.v 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * e1_rx_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_rx_liu (
  30. // Pads
  31. input wire pad_rx_data,
  32. input wire pad_rx_clk,
  33. // Output
  34. output reg out_data,
  35. output reg out_valid,
  36. // Common
  37. input wire clk,
  38. input wire rst
  39. );
  40. wire rx_data;
  41. wire rx_clk;
  42. reg rx_data_r;
  43. reg rx_clk_r;
  44. // IOBs (registered)
  45. SB_IO #(
  46. .PIN_TYPE(6'b0000_00),
  47. .PULLUP(1'b0),
  48. .NEG_TRIGGER(1'b0)
  49. ) rx_iobs_I[1:0] (
  50. .PACKAGE_PIN({pad_rx_data, pad_rx_clk}),
  51. .LATCH_INPUT_VALUE(1'b0),
  52. .CLOCK_ENABLE(1'b1),
  53. .INPUT_CLK(clk),
  54. .OUTPUT_CLK(1'b0),
  55. .OUTPUT_ENABLE(1'b0),
  56. .D_OUT_0(1'b0),
  57. .D_OUT_1(1'b0),
  58. .D_IN_0({rx_data, rx_clk}),
  59. .D_IN_1()
  60. );
  61. // First internal register
  62. always @(posedge clk)
  63. begin
  64. rx_data_r <= rx_data;
  65. rx_clk_r <= rx_clk;
  66. end
  67. // Second internal register + clk falling edge detect
  68. always @(posedge clk)
  69. begin
  70. out_data <= rx_data_r;
  71. out_valid <= rx_clk_r & ~rx_clk;
  72. end
  73. endmodule // e1_rx_liu