You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
1.9 KiB

  1. `timescale 1 ns/1 ns // time-unit = 1 ns, precision = 10 ps
  2. // simplified CC_PLL model
  3. module CC_PLL #(
  4. parameter REF_CLK = "", // e.g. "10.0"
  5. parameter OUT_CLK = "", // e.g. "50.0"
  6. parameter PERF_MD = "", // LOWPOWER, ECONOMY, SPEED
  7. parameter LOW_JITTER = 1,
  8. parameter CI_FILTER_CONST = 2,
  9. parameter CP_FILTER_CONST = 4
  10. )(
  11. input CLK_REF, CLK_FEEDBACK, USR_CLK_REF,
  12. input USR_LOCKED_STDY_RST, USR_SET_SEL,
  13. output USR_PLL_LOCKED_STDY, USR_PLL_LOCKED,
  14. output CLK270, CLK180, CLK90, CLK0, CLK_REF_OUT
  15. );
  16. reg r_pll_clk;
  17. reg r_user_pll_locked;
  18. // OUT_FREQ = 2 MHz
  19. integer clk_half_period = 250;
  20. initial begin
  21. r_pll_clk = 1'b0;
  22. r_user_pll_locked = 1'b1;
  23. end
  24. always #clk_half_period r_pll_clk = ~r_pll_clk;
  25. assign CLK0 = r_pll_clk;
  26. assign USR_PLL_LOCKED = r_user_pll_locked;
  27. endmodule
  28. // simplified CC_CFG_END model
  29. module CC_CFG_END (
  30. output CFG_END
  31. );
  32. assign CFG_END = 1'b1;
  33. endmodule
  34. module tb_blink;
  35. // DUT in/out
  36. reg clk = 1'b0;
  37. reg rst_n = 1'b1;
  38. wire [7:0] led_n;
  39. // Testbench variables
  40. reg [7:0] led_exp = 8'hfe;
  41. // Testbench 1/2 clock period
  42. localparam clk_half_period = 50;
  43. blink DUT (.clk_i(clk), .rst_n_i(rst_n), .led_n_o(led_n));
  44. // Set dumpfile
  45. initial begin
  46. $dumpfile ("tb_blink.fst");
  47. $dumpvars (0, tb_blink);
  48. end
  49. // Setup simulation
  50. initial begin
  51. #1 rst_n = 1'b0;
  52. #120 rst_n = 1'b1;
  53. end
  54. // Generate 10 mhz clock
  55. always #clk_half_period clk = !clk;
  56. // Checker
  57. initial begin
  58. @(posedge rst_n)
  59. for (integer i = 0; i < 7; i = i + 1) begin
  60. assert (led_n == led_exp)
  61. $display("LED : 0x%h", led_n);
  62. else
  63. $warning("LED error, got 0x%h, expected 0x%h", led_n, led_exp);
  64. #128_000;
  65. led_exp = {led_exp[6:0], led_exp[7]};
  66. end
  67. $display ("LED tests finished");
  68. $finish;
  69. end
  70. endmodule