top_mmcme2_tb.v 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //------------------------------------------------------------------------------------------
  2. // ____ ____
  3. // / /\/ /
  4. // /___/ \ /
  5. // \ \ \/ � Copyright 2019 Xilinx, Inc. All rights reserved.
  6. // \ \ This file contains confidential and proprietary information of Xilinx, Inc.
  7. // / / and is protected under U.S. and international copyright and other
  8. // /___/ /\ intellectual property laws.
  9. // \ \ / \
  10. // \___\/\___\
  11. //
  12. //-------------------------------------------------------------------------------------------
  13. // Device: 7-Series
  14. // Author: Tatsukawa, Defossez
  15. // Entity Name: top_mmcme2_tb
  16. // Purpose: This is a basic demonstration that drives the MMCM_DRP
  17. // ports to trigger two reconfiguration events, one for
  18. // each state.
  19. // Tools: QuestaSim_10.7d or newer
  20. // Limitations:
  21. //
  22. // Vendor: Xilinx Inc.
  23. // Version: 0.01
  24. // Filename: top_mmcme2_tb.v
  25. // Date Created: 30-Jul-2014
  26. // Date Last Modified: 26-Jun-2019
  27. //-------------------------------------------------------------------------------------------
  28. // Disclaimer:
  29. // This disclaimer is not a license and does not grant any rights to the materials
  30. // distributed herewith. Except as otherwise provided in a valid license issued to you
  31. // by Xilinx, and to the maximum extent permitted by applicable law: (1) THESE MATERIALS
  32. // ARE MADE AVAILABLE "AS IS" AND WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL
  33. // WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED
  34. // TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR
  35. // PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including
  36. // negligence, or under any other theory of liability) for any loss or damage of any
  37. // kind or nature related to, arising under or in connection with these materials,
  38. // including for any direct, or any indirect, special, incidental, or consequential
  39. // loss or damage (including loss of data, profits, goodwill, or any type of loss or
  40. // damage suffered as a result of any action brought by a third party) even if such
  41. // damage or loss was reasonably foreseeable or Xilinx had been advised of the
  42. // possibility of the same.
  43. //
  44. // CRITICAL APPLICATIONS
  45. // Xilinx products are not designed or intended to be fail-safe, or for use in any
  46. // application requiring fail-safe performance, such as life-support or safety devices
  47. // or systems, Class III medical devices, nuclear facilities, applications related to
  48. // the deployment of airbags, or any other applications that could lead to death,
  49. // personal injury, or severe property or environmental damage (individually and
  50. // collectively, "Critical Applications"). Customer assumes the sole risk and
  51. // liability of any use of Xilinx products in Critical Applications, subject only to
  52. // applicable laws and regulations governing limitations on product liability.
  53. //
  54. // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE AT ALL TIMES.
  55. //
  56. // Contact: e-mail hotline@xilinx.com phone + 1 800 255 7778
  57. //-------------------------------------------------------------------------------------------
  58. // Revision History:
  59. // Rev: 30-Jul-20149 - Tatsukawa
  60. // Initial version of this design - source code.
  61. // Rev: 26-Jun-2019 - Defossez
  62. // Make sure the simulation works after modifications to the design.
  63. //-------------------------------------------------------------------------------------------
  64. //
  65. `timescale 1ps / 1ps
  66. //-------------------------------------------------------------------------------------------
  67. module top_tb ();
  68. reg SSTEP, RST, CLKin, STATE;
  69. wire SRDY, clk0out, clk1out, clk2out, clk3out, clk4out, clk5out, clk6out;
  70. //-------------------------------------------------------------------------------------------
  71. top_mmcme2 U1
  72. (
  73. .SSTEP (SSTEP),
  74. .STATE (STATE),
  75. .RST (RST),
  76. .CLKIN (CLKin),
  77. .SRDY (SRDY),
  78. .LOCKED_OUT (locked),
  79. .CLK0OUT (clk0out),
  80. .CLK1OUT (clk1out),
  81. .CLK2OUT (clk2out),
  82. .CLK3OUT (clk3out),
  83. .CLK4OUT (clk4out),
  84. .CLK5OUT (clk5out),
  85. .CLK6OUT (clk6out)
  86. );
  87. //-------------------------------------------------------------------------------------------
  88. localparam one_ns = 1000;
  89. localparam clock_period = 8.13;
  90. parameter [1:0] STARTUP = 0, STATE0 = 1, STATE1 = 2, UNDEFINED = 3;
  91. reg [1:0] SM = STARTUP ;
  92. always @ (posedge CLKin)
  93. begin
  94. if (RST)
  95. SM = STARTUP;
  96. else
  97. case (SM)
  98. STARTUP:
  99. begin
  100. SM = STATE0;
  101. SSTEP=1'b0;
  102. STATE=1'b0;
  103. end
  104. STATE0:
  105. begin
  106. if (locked == 1 )
  107. begin
  108. #(1 * clock_period * one_ns) SSTEP= 1'b1;
  109. #(1 * clock_period * one_ns) SSTEP=1'b0;
  110. #(2000 * clock_period * one_ns) SM = STATE1 ;
  111. STATE=1'b1;
  112. end
  113. end
  114. STATE1:
  115. begin
  116. if (locked == 1 )
  117. begin
  118. #(1 * clock_period * one_ns) SSTEP= 1'b1;
  119. #(1 * clock_period * one_ns) SSTEP=1'b0;
  120. #(100 * clock_period * one_ns) SM = STATE0;
  121. STATE=1'b0;
  122. end
  123. end
  124. UNDEFINED: SM= STARTUP;
  125. endcase
  126. end
  127. //
  128. initial
  129. begin
  130. CLKin = 0;
  131. RST = 1;
  132. #50000 RST = 0;
  133. end
  134. always
  135. # (clock_period * one_ns / 2) CLKin = ~CLKin;
  136. //
  137. //-------------------------------------------------------------------------------------------
  138. endmodule
  139. //