|
@@ -43,7 +43,22 @@ module motor_history_shared_tb #(parameter integer AXIS_COUNT=3);
|
|
|
if(rst_n && (axis[0]!==axis[1] || word_data[0]!==word_data[1]))$fatal(1,"production/diagnostic status word differs");
|
|
if(rst_n && (axis[0]!==axis[1] || word_data[0]!==word_data[1]))$fatal(1,"production/diagnostic status word differs");
|
|
|
if(rst_n && word_data[0]!==record[1][axis[0]*512+word_address*16+:16])$fatal(1,"production word differs from full diagnostic record");
|
|
if(rst_n && word_data[0]!==record[1][axis[0]*512+word_address*16+:16])$fatal(1,"production word differs from full diagnostic record");
|
|
|
end
|
|
end
|
|
|
- always @(negedge clk)word_address<=word_address+1'b1;
|
|
|
|
|
|
|
+ // Follow the real snapshot consumer: every axis must be observed for
|
|
|
|
|
+ // each word before advancing, including while event reads share the port.
|
|
|
|
|
+ integer expected_axis=0,read_wait=0,complete_sweeps=0;
|
|
|
|
|
+ always @(negedge clk)begin
|
|
|
|
|
+ if(!rst_n)begin word_address<=0;expected_axis=0;read_wait=0;complete_sweeps=0;end
|
|
|
|
|
+ else if(axis[0]==expected_axis)begin
|
|
|
|
|
+ read_wait=0;
|
|
|
|
|
+ if(expected_axis==AXIS_COUNT-1)begin
|
|
|
|
|
+ expected_axis=0;word_address<=word_address+1'b1;
|
|
|
|
|
+ if(word_address==31)complete_sweeps=complete_sweeps+1;
|
|
|
|
|
+ end else expected_axis=expected_axis+1;
|
|
|
|
|
+ end else begin
|
|
|
|
|
+ read_wait=read_wait+1;
|
|
|
|
|
+ if(read_wait>4*AXIS_COUNT)$fatal(1,"event arbitration starved a snapshot axis");
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
reg [151:0]saved_history;
|
|
reg [151:0]saved_history;
|
|
|
task check_history;
|
|
task check_history;
|
|
|
reg [151:0]actual,independent;
|
|
reg [151:0]actual,independent;
|
|
@@ -72,7 +87,8 @@ module motor_history_shared_tb #(parameter integer AXIS_COUNT=3);
|
|
|
end
|
|
end
|
|
|
repeat(60)@(negedge clk);check_history;
|
|
repeat(60)@(negedge clk);check_history;
|
|
|
if(event_count[0]!=64 || overflow[0]<6 || overflow[0]!==overflow[1])$fatal(1,"ring overwrite scenario not reached");
|
|
if(event_count[0]!=64 || overflow[0]<6 || overflow[0]!==overflow[1])$fatal(1,"ring overwrite scenario not reached");
|
|
|
- if(g[0].dut.time_us[63:32]<expected_time[63:32])$fatal(1,"timestamp scenario invalid");
|
|
|
|
|
|
|
+ if(expected_time[63:32]!=1 || g[0].dut.time_us[63:32]!=2)$fatal(1,"64-bit timestamp crossing not exercised");
|
|
|
|
|
+ if(complete_sweeps<2)$fatal(1,"full axis/word matrix not exercised");
|
|
|
if(AXIS_COUNT==12)$display("motor_history_shared_12_tb PASS");
|
|
if(AXIS_COUNT==12)$display("motor_history_shared_12_tb PASS");
|
|
|
else $display("motor_history_shared_tb PASS");
|
|
else $display("motor_history_shared_tb PASS");
|
|
|
$finish;
|
|
$finish;
|