bmc_ascii_snapshot_cocotb_top.v 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. `timescale 1ns/1ps
  2. module bmc_ascii_snapshot_cocotb_top (
  3. input wire tick_1s_test,
  4. input wire rx_valid,
  5. input wire [7:0] rx_data,
  6. input wire rx_framing_error,
  7. input wire snapshot_lock,
  8. input wire snapshot_lock_bank,
  9. input wire [4:0] rd_index,
  10. output wire sys_clk,
  11. output reg rst_n_mon = 1'b0,
  12. output wire snapshot_commit,
  13. output wire parser_error,
  14. output wire [15:0] epoch,
  15. output wire [15:0] age_seconds,
  16. output wire stale,
  17. output wire active_bank,
  18. output wire [23:0] active_valid_mask,
  19. output wire [15:0] rd_raw,
  20. output wire rd_valid,
  21. output reg [15:0] commit_count_mon = 0,
  22. output reg [15:0] error_count_mon = 0
  23. );
  24. reg clk = 1'b0;
  25. reg [3:0] reset_count = 0;
  26. always #20 clk = ~clk;
  27. assign sys_clk = clk;
  28. always @(posedge clk) begin
  29. if (reset_count < 8) begin
  30. reset_count <= reset_count + 1'b1;
  31. rst_n_mon <= 1'b0;
  32. end else begin
  33. rst_n_mon <= 1'b1;
  34. end
  35. end
  36. bmc_ascii_snapshot #(
  37. .STALE_SECONDS(2),
  38. .INTER_BYTE_TIMEOUT_CLKS(64)
  39. ) u_dut (
  40. .clk(clk),
  41. .rst_n(rst_n_mon),
  42. .tick_1s(tick_1s_test),
  43. .rx_valid(rx_valid),
  44. .rx_data(rx_data),
  45. .rx_framing_error(rx_framing_error),
  46. .snapshot_lock(snapshot_lock),
  47. .snapshot_lock_bank(snapshot_lock_bank),
  48. .snapshot_commit(snapshot_commit),
  49. .parser_error(parser_error),
  50. .epoch(epoch),
  51. .age_seconds(age_seconds),
  52. .stale(stale),
  53. .active_bank(active_bank),
  54. .active_valid_mask(active_valid_mask),
  55. .control_bank(active_bank),
  56. .control_index(rd_index),
  57. .control_raw(rd_raw),
  58. .control_valid(rd_valid),
  59. .snapshot_bank(active_bank),
  60. .snapshot_index(5'd0),
  61. .snapshot_raw(),
  62. .snapshot_valid()
  63. );
  64. always @(posedge clk) begin
  65. if (!rst_n_mon) begin
  66. commit_count_mon <= 0;
  67. error_count_mon <= 0;
  68. end else begin
  69. if (snapshot_commit)
  70. commit_count_mon <= commit_count_mon + 1'b1;
  71. if (parser_error)
  72. error_count_mon <= error_count_mon + 1'b1;
  73. end
  74. end
  75. endmodule