| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- `timescale 1ns/1ps
- module bmc_dimm_frame_parser_tb;
- reg clk;
- reg rst_n;
- reg raw_valid;
- reg [7:0] raw_integer_byte;
- reg [7:0] raw_fraction_byte;
- reg [4:0] raw_pair_index;
- reg [15:0] frame_seq;
- reg [15:0] sample_seq_base;
- reg [15:0] age_ms;
- reg frame_bad_length;
- reg sample_stale;
- reg sample_ready;
- wire raw_ready;
- wire dimm_valid;
- wire [2:0] source_id;
- wire [15:0] dimm_frame_seq;
- wire [15:0] dimm_sample_seq;
- wire [4:0] raw_pair_index_out;
- wire [4:0] dimm_id;
- wire [4:0] channel;
- wire [7:0] raw_integer_byte_out;
- wire [7:0] raw_fraction_byte_out;
- wire signed [17:0] temp_q;
- wire [15:0] temp_c_x100;
- wire missing;
- wire fault;
- wire stale;
- wire [15:0] age_ms_out;
- wire [7:0] raw_status;
- wire [7:0] parser_status;
- bmc_dimm_frame_parser dut (
- .clk(clk),
- .rst_n(rst_n),
- .raw_valid(raw_valid),
- .raw_ready(raw_ready),
- .raw_integer_byte(raw_integer_byte),
- .raw_fraction_byte(raw_fraction_byte),
- .raw_pair_index(raw_pair_index),
- .frame_seq(frame_seq),
- .sample_seq_base(sample_seq_base),
- .age_ms(age_ms),
- .frame_bad_length(frame_bad_length),
- .sample_stale(sample_stale),
- .sample_ready(sample_ready),
- .dimm_valid(dimm_valid),
- .source_id(source_id),
- .dimm_frame_seq(dimm_frame_seq),
- .dimm_sample_seq(dimm_sample_seq),
- .raw_pair_index_out(raw_pair_index_out),
- .dimm_id(dimm_id),
- .channel(channel),
- .raw_integer_byte_out(raw_integer_byte_out),
- .raw_fraction_byte_out(raw_fraction_byte_out),
- .temp_q(temp_q),
- .temp_c_x100(temp_c_x100),
- .missing(missing),
- .fault(fault),
- .stale(stale),
- .age_ms_out(age_ms_out),
- .raw_status(raw_status),
- .parser_status(parser_status)
- );
- initial begin
- clk = 1'b0;
- forever #5 clk = ~clk;
- end
- task send_pair;
- input [7:0] integer_byte;
- input [7:0] fraction_byte;
- input [4:0] index;
- begin
- @(negedge clk);
- raw_integer_byte = integer_byte;
- raw_fraction_byte = fraction_byte;
- raw_pair_index = index;
- raw_valid = 1'b1;
- @(posedge clk);
- #1;
- raw_valid = 1'b0;
- end
- endtask
- initial begin
- rst_n = 1'b0;
- raw_valid = 1'b0;
- raw_integer_byte = 8'd0;
- raw_fraction_byte = 8'd0;
- raw_pair_index = 5'd0;
- frame_seq = 16'd7;
- sample_seq_base = 16'd100;
- age_ms = 16'd0;
- frame_bad_length = 1'b0;
- sample_stale = 1'b0;
- sample_ready = 1'b1;
- repeat (4) @(negedge clk);
- rst_n = 1'b1;
- send_pair(8'h3c, 8'h4b, 5'd0);
- if (!dimm_valid || temp_c_x100 !== 16'd6075 || temp_q !== 18'sd61 ||
- dimm_sample_seq !== 16'd100 || source_id !== 3'd5 || fault) begin
- $display(
- "BMC parser normal temperature mismatch valid=%0d temp_c_x100=%0d temp_q=%0d sample_seq=%0d source=%0d fault=%0d",
- dimm_valid,
- temp_c_x100,
- temp_q,
- dimm_sample_seq,
- source_id,
- fault
- );
- $fatal;
- end
- send_pair(8'hff, 8'hff, 5'd6);
- if (!missing || fault || raw_status[0] !== 1'b1 || channel !== 5'd6) begin
- $display("BMC parser missing DIMM mismatch");
- $fatal;
- end
- sample_stale = 1'b1;
- age_ms = 16'd3500;
- send_pair(8'h40, 8'h32, 5'd1);
- if (!stale || raw_status[3] !== 1'b1 || age_ms_out !== 16'd3500) begin
- $display("BMC parser stale field mismatch");
- $fatal;
- end
- sample_stale = 1'b0;
- frame_bad_length = 1'b1;
- send_pair(8'h40, 8'h32, 5'd2);
- if (!fault || parser_status !== 8'd1 || raw_status[1] !== 1'b1) begin
- $display("BMC parser bad length mismatch");
- $fatal;
- end
- $display("PASS: bmc_dimm_frame_parser_tb");
- $finish;
- end
- endmodule
|