ice40_serdes_dff.v 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 SERDES_ATTR = "",
  40. parameter BEL = ""
  41. )(
  42. input wire d,
  43. output wire q,
  44. input wire e,
  45. input wire r,
  46. input wire c
  47. );
  48. parameter TYPE = (RST ? 4 : 0) | (ENA ? 2 : 0) | (NEG ? 1 : 0);
  49. generate
  50. if (TYPE == 0) // Simple
  51. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  52. (* dont_touch, keep *)
  53. SB_DFF dff_I (
  54. .D(d),
  55. .Q(q),
  56. .C(c)
  57. );
  58. else if (TYPE == 1) // NEG
  59. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  60. (* dont_touch, keep *)
  61. SB_DFFN dff_I (
  62. .D(d),
  63. .Q(q),
  64. .C(c)
  65. );
  66. else if (TYPE == 2) // ENA
  67. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  68. (* dont_touch, keep *)
  69. SB_DFFE dff_I (
  70. .D(d),
  71. .Q(q),
  72. .E(e),
  73. .C(c)
  74. );
  75. else if (TYPE == 3) // NEG ENA
  76. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  77. (* dont_touch, keep *)
  78. SB_DFFNE dff_I (
  79. .D(d),
  80. .Q(q),
  81. .E(e),
  82. .C(c)
  83. );
  84. else if (TYPE == 4) // RST
  85. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  86. (* dont_touch, keep *)
  87. SB_DFFR dff_I (
  88. .D(d),
  89. .Q(q),
  90. .R(r),
  91. .C(c)
  92. );
  93. else if (TYPE == 5) // NEG RST
  94. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  95. (* dont_touch, keep *)
  96. SB_DFFNR dff_I (
  97. .D(d),
  98. .Q(q),
  99. .R(r),
  100. .C(c)
  101. );
  102. else if (TYPE == 6) // ENA RST
  103. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  104. (* dont_touch, keep *)
  105. SB_DFFER dff_I (
  106. .D(d),
  107. .Q(q),
  108. .E(e),
  109. .R(r),
  110. .C(c)
  111. );
  112. else if (TYPE == 7) // NEG ENA RST
  113. (* BEL=BEL, SERDES_GRP=SERDES_GRP, SERDES_ATTR=SERDES_ATTR *)
  114. (* dont_touch, keep *)
  115. SB_DFFNER dff_I (
  116. .D(d),
  117. .Q(q),
  118. .E(e),
  119. .R(r),
  120. .C(c)
  121. );
  122. endgenerate
  123. endmodule