ice40_serdes_dff.v 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * ice40_serdes_dff.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2020 Sylvain Munaut <tnt@246tNt.com>
  7. * All rights reserved.
  8. *
  9. * BSD 3-clause, see LICENSE.bsd
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. * * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * * Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * * Neither the name of the <organization> nor the
  19. * names of its contributors may be used to endorse or promote products
  20. * derived from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  26. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. `default_nettype none
  34. module ice40_serdes_dff #(
  35. parameter integer NEG = 0,
  36. parameter integer ENA = 0,
  37. parameter integer RST = 0,
  38. parameter integer SERDES_GRP = -1,
  39. parameter BEL = ""
  40. )(
  41. input wire d,
  42. output wire q,
  43. input wire e,
  44. input wire r,
  45. input wire c
  46. );
  47. parameter TYPE = (RST ? 4 : 0) | (ENA ? 2 : 0) | (NEG ? 1 : 0);
  48. generate
  49. if (TYPE == 0) // Simple
  50. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  51. (* dont_touch *)
  52. SB_DFF dff_I (
  53. .D(d),
  54. .Q(q),
  55. .C(c)
  56. );
  57. else if (TYPE == 1) // NEG
  58. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  59. (* dont_touch *)
  60. SB_DFFN dff_I (
  61. .D(d),
  62. .Q(q),
  63. .C(c)
  64. );
  65. else if (TYPE == 2) // ENA
  66. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  67. (* dont_touch *)
  68. SB_DFFE dff_I (
  69. .D(d),
  70. .Q(q),
  71. .E(e),
  72. .C(c)
  73. );
  74. else if (TYPE == 3) // NEG ENA
  75. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  76. (* dont_touch *)
  77. SB_DFFNE dff_I (
  78. .D(d),
  79. .Q(q),
  80. .E(e),
  81. .C(c)
  82. );
  83. else if (TYPE == 4) // RST
  84. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  85. (* dont_touch *)
  86. SB_DFFR dff_I (
  87. .D(d),
  88. .Q(q),
  89. .R(r),
  90. .C(c)
  91. );
  92. else if (TYPE == 5) // NEG RST
  93. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  94. (* dont_touch *)
  95. SB_DFFNR dff_I (
  96. .D(d),
  97. .Q(q),
  98. .R(r),
  99. .C(c)
  100. );
  101. else if (TYPE == 6) // ENA RST
  102. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  103. (* dont_touch *)
  104. SB_DFFER dff_I (
  105. .D(d),
  106. .Q(q),
  107. .E(e),
  108. .R(r),
  109. .C(c)
  110. );
  111. else if (TYPE == 7) // NEG ENA RST
  112. (* BEL=BEL, SERDES_GRP=SERDES_GRP *)
  113. (* dont_touch *)
  114. SB_DFFNER dff_I (
  115. .D(d),
  116. .Q(q),
  117. .E(e),
  118. .R(r),
  119. .C(c)
  120. );
  121. endgenerate
  122. endmodule