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.

102 lines
2.2 KiB

  1. `timescale 1 ns/10 ps // time-unit = 1 ns, precision = 10 ps
  2. `define USE_RAM
  3. // simplified CC_PLL model
  4. module CC_PLL #(
  5. parameter REF_CLK = "", // e.g. "10.0"
  6. parameter OUT_CLK = "", // e.g. "50.0"
  7. parameter PERF_MD = "", // LOWPOWER, ECONOMY, SPEED
  8. parameter LOW_JITTER = 1,
  9. parameter CI_FILTER_CONST = 2,
  10. parameter CP_FILTER_CONST = 4
  11. )(
  12. input CLK_REF, CLK_FEEDBACK, USR_CLK_REF,
  13. input USR_LOCKED_STDY_RST, USR_SET_SEL,
  14. output USR_PLL_LOCKED_STDY, USR_PLL_LOCKED,
  15. output CLK270, CLK180, CLK90, CLK0, CLK_REF_OUT
  16. );
  17. reg r_pll_clk;
  18. reg r_user_pll_locked;
  19. // OUT_FREQ = 10 MHz
  20. localparam clk_half_period = 50;
  21. initial begin
  22. r_pll_clk = 1'b0;
  23. r_user_pll_locked = 1'b1;
  24. end
  25. always #clk_half_period r_pll_clk = ~r_pll_clk;
  26. assign CLK0 = r_pll_clk;
  27. assign USR_PLL_LOCKED = r_user_pll_locked;
  28. endmodule
  29. // simplified CC_CFG_END model
  30. module CC_CFG_END (
  31. output CFG_END
  32. );
  33. assign CFG_END = 1'b1;
  34. endmodule
  35. module tb_neorv32_aes;
  36. // DUT in/out
  37. reg clk = 1'b0;
  38. reg rst_n = 1'b1;
  39. wire [7:0] led;
  40. wire [63:0] debug;
  41. reg uart_rx;
  42. wire uart_tx;
  43. // Testbench variables
  44. // Testbench 1/2 clock period
  45. localparam clk_half_period = 50;
  46. // UART period calculation (9600 baud)
  47. localparam uart_bit_period = 1000000000 / 9600;
  48. localparam uart_bit_half_period = uart_bit_period/2;
  49. neorv32_aes UUT (.clk_i(clk), .rst_n_i(rst_n), .led_n_o(led), .debug_o(debug));
  50. // neorv32_aes UUT (.clk_i(clk), .rst_n_i(rst_n), .led_n_o(led), .uart_tx_o(uart_tx), .uart_rx_i(uart_rx));
  51. // set dumpfile
  52. initial begin
  53. $dumpfile ("tb_neorv32_aes.fst");
  54. $dumpvars (0, tb_neorv32_aes);
  55. end
  56. // Setup simulation
  57. initial begin
  58. uart_rx = 1'b1;
  59. #1 rst_n = 1'b0;
  60. #120 rst_n = 1'b1;
  61. end
  62. // Generate 10 mhz clock
  63. always #clk_half_period clk = !clk;
  64. // Stimuli generator
  65. initial
  66. forever @(posedge rst_n) begin
  67. // Simulate for 100 us
  68. #500_000
  69. // @(negedge led[0]);
  70. // #100
  71. $display ("NEORV32 test finished");
  72. $finish;
  73. end
  74. // Monitor
  75. initial begin
  76. $monitor("monitor time=%t ns, rst_n=%b, led=%b, imem.addr=%d, dmem.addr=%h", $time, rst_n, led, debug[31:2], debug[63:32]);
  77. end
  78. endmodule