Просмотр исходного кода

Keep hit counters in the rotating axis word

codex 2 месяцев назад
Родитель
Сommit
417ce170d4
3 измененных файлов с 43 добавлено и 46 удалено
  1. 33 36
      src/motor/motor_axis_core.v
  2. 9 9
      tests/sim/motor_axis_bank_tb.v
  3. 1 1
      tests/sim/motor_axis_contract_tb.v

+ 33 - 36
src/motor/motor_axis_core.v

@@ -51,15 +51,15 @@ module motor_axis_core #(
  wire [31:0] r_position[0:AXIS_COUNT-1],r_total[0:AXIS_COUNT-1],r_last[0:AXIS_COUNT-1];
  wire [31:0] r_position[0:AXIS_COUNT-1],r_total[0:AXIS_COUNT-1],r_last[0:AXIS_COUNT-1];
  wire [31:0] r_lhits[0:AXIS_COUNT-1],r_uhits[0:AXIS_COUNT-1];
  wire [31:0] r_lhits[0:AXIS_COUNT-1],r_uhits[0:AXIS_COUNT-1];
  reg [31:0] r_wrap[0:AXIS_COUNT-1];
  reg [31:0] r_wrap[0:AXIS_COUNT-1];
- reg [63:0] hit_memory[0:AXIS_COUNT-1];
- reg [AXIS_COUNT-1:0] hit_valid;
- wire [63:0] selected_hits=hit_valid[scan_axis] ? hit_memory[scan_axis] : 64'd0;
+ wire [63:0] hit_memory[0:AXIS_COUNT-1];
+ wire [63:0] selected_hits=selected_state[321:258];
+ reg [63:0] w_hits;
  wire [15:0] r_tag[0:AXIS_COUNT-1],r_done_tag[0:AXIS_COUNT-1];
  wire [15:0] r_tag[0:AXIS_COUNT-1],r_done_tag[0:AXIS_COUNT-1];
 
 
- // Packed order: half, remaining, executed, position, total, last, tag, last tag, deadline.
+ // Packed order: half, remaining, executed, position, total, last, tag, last tag, deadline, lower/upper hits.
  // A common write word keeps per-axis write priority outside the storage bank.
  // A common write word keeps per-axis write priority outside the storage bank.
- wire [257:0] selected_state;
- wire [AXIS_COUNT*258-1:0] diagnostic_state;
+ wire [321:0] selected_state;
+ wire [AXIS_COUNT*322-1:0] diagnostic_state;
  wire [31:0] s_half_us=selected_state[31:0],s_remaining=selected_state[63:32];
  wire [31:0] s_half_us=selected_state[31:0],s_remaining=selected_state[63:32];
  wire [31:0] s_executed=selected_state[95:64],s_position=selected_state[127:96];
  wire [31:0] s_executed=selected_state[95:64],s_position=selected_state[127:96];
  wire [31:0] s_total=selected_state[159:128],s_last=selected_state[191:160];
  wire [31:0] s_total=selected_state[159:128],s_last=selected_state[191:160];
@@ -70,7 +70,7 @@ module motor_axis_core #(
  reg [15:0] w_tag,w_done_tag;
  reg [15:0] w_tag,w_done_tag;
  motor_axis_state_bank #(.AXIS_COUNT(AXIS_COUNT),.PARALLEL_TELEMETRY(PARALLEL_TELEMETRY)) u_state_bank(
  motor_axis_state_bank #(.AXIS_COUNT(AXIS_COUNT),.PARALLEL_TELEMETRY(PARALLEL_TELEMETRY)) u_state_bank(
   .clk(clk),.rst_n(rst_n),.axis(scan_axis),
   .clk(clk),.rst_n(rst_n),.axis(scan_axis),
-  .write_data({w_due,w_done_tag,w_tag,w_last,w_total,w_position,w_executed,w_remaining,w_half_us}),
+  .write_data({w_hits,w_due,w_done_tag,w_tag,w_last,w_total,w_position,w_executed,w_remaining,w_half_us}),
   .read_data(selected_state),.diagnostic_data(diagnostic_state));
   .read_data(selected_state),.diagnostic_data(diagnostic_state));
  reg [3:0] r_reason[0:AXIS_COUNT-1];
  reg [3:0] r_reason[0:AXIS_COUNT-1];
  reg [31:0] r_done_exec[0:AXIS_COUNT-1],r_done_pos[0:AXIS_COUNT-1],r_done_total[0:AXIS_COUNT-1],r_done_time[0:AXIS_COUNT-1];
  reg [31:0] r_done_exec[0:AXIS_COUNT-1],r_done_pos[0:AXIS_COUNT-1],r_done_total[0:AXIS_COUNT-1],r_done_time[0:AXIS_COUNT-1];
@@ -147,7 +147,8 @@ module motor_axis_core #(
  // Preserve the former nonblocking write priorities in one selected write word.
  // Preserve the former nonblocking write priorities in one selected write word.
  always @* begin
  always @* begin
   w_total=total_next;w_executed=exec_next;w_remaining=remaining_next;w_position=pos_next;
   w_total=total_next;w_executed=exec_next;w_remaining=remaining_next;w_position=pos_next;
-  w_last=s_last;w_half_us=s_half_us;w_tag=s_tag;w_done_tag=s_done_tag;w_due=s_due;
+  w_last=s_last;w_half_us=s_half_us;w_tag=s_tag;w_done_tag=s_done_tag;w_due=s_due;w_hits=selected_hits;
+  if(lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0)w_hits={upper_hit_sum[31:0],lower_hit_sum[31:0]};
   if(lower_pending[scan_axis]!=0)w_position=0;
   if(lower_pending[scan_axis]!=0)w_position=0;
   if(stop_pending[scan_axis]!=0 || selected_stop!=0)begin
   if(stop_pending[scan_axis]!=0 || selected_stop!=0)begin
    w_remaining=0;w_last=exec_next;w_done_tag=s_tag;
    w_remaining=0;w_last=exec_next;w_done_tag=s_tag;
@@ -165,7 +166,7 @@ module motor_axis_core #(
   end
   end
   if(pos_pending[scan_axis] || position_load[scan_axis])w_position=position_value[scan_axis*32+:32];
   if(pos_pending[scan_axis] || position_load[scan_axis])w_position=position_value[scan_axis*32+:32];
   if(clear_pending[scan_axis] || counters_clear[scan_axis])begin
   if(clear_pending[scan_axis] || counters_clear[scan_axis])begin
-   w_total=0;w_last=0;
+   w_total=0;w_last=0;w_hits=0;
    if(counters_clear[scan_axis]?pos_zero_with_counters[scan_axis]:zero_pending[scan_axis])w_position=0;
    if(counters_clear[scan_axis]?pos_zero_with_counters[scan_axis]:zero_pending[scan_axis])w_position=0;
   end
   end
  end
  end
@@ -173,11 +174,6 @@ module motor_axis_core #(
  // The production status and event interfaces have only one addressed
  // The production status and event interfaces have only one addressed
  // history read. Diagnostic parallel views are disabled before synthesis.
  // history read. Diagnostic parallel views are disabled before synthesis.
  always @(posedge clk)begin
  always @(posedge clk)begin
-  if(rst_n)begin
-   if(clear_pending[scan_axis] || counters_clear[scan_axis])hit_memory[scan_axis]<=0;
-   else if(lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0)
-    hit_memory[scan_axis]<={upper_hit_sum[31:0],lower_hit_sum[31:0]};
-  end
   // Production retains this record once in the engine event/status bank.
   // Production retains this record once in the engine event/status bank.
   // The local copy exists only for the independent diagnostic interface.
   // The local copy exists only for the independent diagnostic interface.
   if(PARALLEL_TELEMETRY && rst_n && (lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0))
   if(PARALLEL_TELEMETRY && rst_n && (lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0))
@@ -228,21 +224,22 @@ module motor_axis_core #(
    ({32{telemetry_word_addr[4:1]==`MR_AXIS_COUNTER_WRAP_FLAGS_OFFSET/4}} & r_wrap[scan_axis]) |
    ({32{telemetry_word_addr[4:1]==`MR_AXIS_COUNTER_WRAP_FLAGS_OFFSET/4}} & r_wrap[scan_axis]) |
    ({32{telemetry_word_addr[4:1]==`MR_AXIS_HALF_PERIOD_US_OFFSET/4}} & s_half_us);
    ({32{telemetry_word_addr[4:1]==`MR_AXIS_HALF_PERIOD_US_OFFSET/4}} & s_half_us);
  generate for(g=0;g<AXIS_COUNT;g=g+1) begin:outputs
  generate for(g=0;g<AXIS_COUNT;g=g+1) begin:outputs
-  assign r_half_us[g]=diagnostic_state[g*258+0+:32];
-  assign r_remaining[g]=diagnostic_state[g*258+32+:32];
-  assign r_executed[g]=diagnostic_state[g*258+64+:32];
-  assign r_position[g]=diagnostic_state[g*258+96+:32];
-  assign r_total[g]=diagnostic_state[g*258+128+:32];
-  assign r_last[g]=diagnostic_state[g*258+160+:32];
-  assign r_tag[g]=diagnostic_state[g*258+192+:16];
-  assign r_done_tag[g]=diagnostic_state[g*258+208+:16];
-  assign due[g]=diagnostic_state[g*258+224+:34];
+  assign r_half_us[g]=diagnostic_state[g*322+0+:32];
+  assign r_remaining[g]=diagnostic_state[g*322+32+:32];
+  assign r_executed[g]=diagnostic_state[g*322+64+:32];
+  assign r_position[g]=diagnostic_state[g*322+96+:32];
+  assign r_total[g]=diagnostic_state[g*322+128+:32];
+  assign r_last[g]=diagnostic_state[g*322+160+:32];
+  assign r_tag[g]=diagnostic_state[g*322+192+:16];
+  assign r_done_tag[g]=diagnostic_state[g*322+208+:16];
+  assign due[g]=diagnostic_state[g*322+224+:34];
+  assign hit_memory[g]=diagnostic_state[g*322+258+:64];
   localparam [7:0] EVENT_AXIS=g;
   localparam [7:0] EVENT_AXIS=g;
   // The last-limit record is already latched on the event pulse. Share it
   // The last-limit record is already latched on the event pulse. Share it
   // with the writer rather than maintaining a second 128-bit copy per axis.
   // with the writer rather than maintaining a second 128-bit copy per axis.
   if(PARALLEL_TELEMETRY)begin:parallel_event_view
   if(PARALLEL_TELEMETRY)begin:parallel_event_view
-   assign r_lhits[g]=hit_valid[g] ? hit_memory[g][31:0] : 32'd0;
-   assign r_uhits[g]=hit_valid[g] ? hit_memory[g][63:32] : 32'd0;
+   assign r_lhits[g]=hit_memory[g][31:0];
+   assign r_uhits[g]=hit_memory[g][63:32];
    assign r_limit_pos[g]=limit_history_valid[g] ? limit_history[g][31:0] : 32'd0;
    assign r_limit_pos[g]=limit_history_valid[g] ? limit_history[g][31:0] : 32'd0;
    assign r_limit_total[g]=limit_history_valid[g] ? limit_history[g][63:32] : 32'd0;
    assign r_limit_total[g]=limit_history_valid[g] ? limit_history[g][63:32] : 32'd0;
    assign r_limit_time[g]=limit_history_valid[g] ? limit_history[g][127:64] : 64'd0;
    assign r_limit_time[g]=limit_history_valid[g] ? limit_history[g][127:64] : 64'd0;
@@ -296,7 +293,7 @@ module motor_axis_core #(
  always @(posedge clk or negedge rst_n) begin
  always @(posedge clk or negedge rst_n) begin
   if(!rst_n) begin
   if(!rst_n) begin
    scan_axis<=0;seen<=0;scan_deadline_miss<=0;step_out<=0;dir_out<={AXIS_COUNT{DIR_LOWER_LEVEL}};done_pulse<=0;seg_consumed<=0;
    scan_axis<=0;seen<=0;scan_deadline_miss<=0;step_out<=0;dir_out<={AXIS_COUNT{DIR_LOWER_LEVEL}};done_pulse<=0;seg_consumed<=0;
-   limit_event_pulse<=0;limit_event_word<=0;limit_event_time_high<=0;done_event_word<=0;limit_event_drops<=0;pending_event_zero<=0;pending_limit_parity<=0;pending_stop_parity<=0;edge_time<=0;limit_history_valid<=0;hit_valid<=0;
+   limit_event_pulse<=0;limit_event_word<=0;limit_event_time_high<=0;done_event_word<=0;limit_event_drops<=0;pending_event_zero<=0;pending_limit_parity<=0;pending_stop_parity<=0;edge_time<=0;limit_history_valid<=0;
    r_dir_upper<=0;r_unlimited<=0;r_ref_seen<=0;r_llat<=0;r_ulat<=0;r_both<=0;
    r_dir_upper<=0;r_unlimited<=0;r_ref_seen<=0;r_llat<=0;r_ulat<=0;r_both<=0;
    scheduled_step<=0;edge_pending<=0;rise_pending<=0;load_pending<=0;start_pending<=0;
    scheduled_step<=0;edge_pending<=0;rise_pending<=0;load_pending<=0;start_pending<=0;
    pos_pending<=0;clear_pending<=0;latch_pending<=0;zero_pending<=0;lower_q<=0;upper_q<=0;
    pos_pending<=0;clear_pending<=0;latch_pending<=0;zero_pending<=0;lower_q<=0;upper_q<=0;
@@ -324,7 +321,7 @@ module motor_axis_core #(
     if(position_signed_overflow)r_wrap[scan_axis][4]<=1;
     if(position_signed_overflow)r_wrap[scan_axis][4]<=1;
    end
    end
    if(lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0) begin
    if(lower_pending[scan_axis]!=0 || upper_pending[scan_axis]!=0) begin
-    hit_valid[scan_axis]<=1;
+
     if(lower_hit_sum[32])r_wrap[scan_axis][2]<=1;
     if(lower_hit_sum[32])r_wrap[scan_axis][2]<=1;
     if(upper_hit_sum[32])r_wrap[scan_axis][3]<=1;
     if(upper_hit_sum[32])r_wrap[scan_axis][3]<=1;
     if(PARALLEL_TELEMETRY)limit_history_valid[scan_axis]<=1;
     if(PARALLEL_TELEMETRY)limit_history_valid[scan_axis]<=1;
@@ -377,7 +374,7 @@ module motor_axis_core #(
     end else if(deadline_next) scheduled_step[scan_axis]<=!step_out[scan_axis];
     end else if(deadline_next) scheduled_step[scan_axis]<=!step_out[scan_axis];
    end
    end
    if(pos_pending[scan_axis] || position_load[scan_axis]) begin pos_pending[scan_axis]<=0;end
    if(pos_pending[scan_axis] || position_load[scan_axis]) begin pos_pending[scan_axis]<=0;end
-   if(clear_pending[scan_axis] || counters_clear[scan_axis]) begin hit_valid[scan_axis]<=1;r_wrap[scan_axis]<=0;clear_pending[scan_axis]<=0;end
+   if(clear_pending[scan_axis] || counters_clear[scan_axis]) begin r_wrap[scan_axis]<=0;clear_pending[scan_axis]<=0;end
    if(latch_pending[scan_axis] || clear_limit_latch[scan_axis]) begin r_llat[scan_axis]<=0;r_ulat[scan_axis]<=0;r_both[scan_axis]<=0;latch_pending[scan_axis]<=0;end
    if(latch_pending[scan_axis] || clear_limit_latch[scan_axis]) begin r_llat[scan_axis]<=0;r_ulat[scan_axis]<=0;r_both[scan_axis]<=0;latch_pending[scan_axis]<=0;end
    // Fast per-axis path: only bits, small edge accumulators and metadata copies.
    // Fast per-axis path: only bits, small edge accumulators and metadata copies.
    for(i=0;i<AXIS_COUNT;i=i+1) begin
    for(i=0;i<AXIS_COUNT;i=i+1) begin
@@ -415,10 +412,10 @@ module motor_axis_state_bank #(
  parameter integer AXIS_COUNT=3,parameter integer PARALLEL_TELEMETRY=0,
  parameter integer AXIS_COUNT=3,parameter integer PARALLEL_TELEMETRY=0,
  parameter integer AW=(AXIS_COUNT<=1)?1:$clog2(AXIS_COUNT)
  parameter integer AW=(AXIS_COUNT<=1)?1:$clog2(AXIS_COUNT)
 )(input wire clk,rst_n,input wire [AW-1:0] axis,
 )(input wire clk,rst_n,input wire [AW-1:0] axis,
- input wire [257:0] write_data,output wire [257:0] read_data,
- output wire [AXIS_COUNT*258-1:0] diagnostic_data);
+ input wire [321:0] write_data,output wire [321:0] read_data,
+ output wire [AXIS_COUNT*322-1:0] diagnostic_data);
  reg [AXIS_COUNT-1:0] valid;
  reg [AXIS_COUNT-1:0] valid;
- wire [257:0] raw_data;
+ wire [321:0] raw_data;
  motor_axis_words #(.AXIS_COUNT(AXIS_COUNT)) u_words(
  motor_axis_words #(.AXIS_COUNT(AXIS_COUNT)) u_words(
   .clk(clk),.rst_n(rst_n),.write_data(write_data),.read_data(raw_data));
   .clk(clk),.rst_n(rst_n),.write_data(write_data),.read_data(raw_data));
  assign read_data=raw_data;
  assign read_data=raw_data;
@@ -427,10 +424,10 @@ module motor_axis_state_bank #(
  end
  end
  genvar i;
  genvar i;
  generate if(PARALLEL_TELEMETRY)begin:diagnostic
  generate if(PARALLEL_TELEMETRY)begin:diagnostic
-  reg [257:0] words [0:AXIS_COUNT-1];
+  reg [321:0] words [0:AXIS_COUNT-1];
   always @(posedge clk)if(rst_n)words[axis]<=write_data;
   always @(posedge clk)if(rst_n)words[axis]<=write_data;
   for(i=0;i<AXIS_COUNT;i=i+1)begin:outputs
   for(i=0;i<AXIS_COUNT;i=i+1)begin:outputs
-   assign diagnostic_data[i*258+:258]=valid[i] ? words[i] : 258'd1;
+   assign diagnostic_data[i*322+:322]=valid[i] ? words[i] : 322'd1;
   end
   end
  end else begin:no_diagnostic
  end else begin:no_diagnostic
   assign diagnostic_data=0;
   assign diagnostic_data=0;
@@ -442,11 +439,11 @@ endmodule
 // removes the wide dynamic read selector and per-axis write selection.
 // removes the wide dynamic read selector and per-axis write selection.
 module motor_axis_words #(parameter integer AXIS_COUNT=3)
 module motor_axis_words #(parameter integer AXIS_COUNT=3)
 (input wire clk,rst_n,
 (input wire clk,rst_n,
- input wire [257:0] write_data,output wire [257:0] read_data);
- reg [257:0] words [0:AXIS_COUNT-1];
+ input wire [321:0] write_data,output wire [321:0] read_data);
+ reg [321:0] words [0:AXIS_COUNT-1];
  integer i;
  integer i;
  always @(posedge clk or negedge rst_n)begin
  always @(posedge clk or negedge rst_n)begin
-  if(!rst_n)for(i=0;i<AXIS_COUNT;i=i+1)words[i]<=258'd1;
+  if(!rst_n)for(i=0;i<AXIS_COUNT;i=i+1)words[i]<=322'd1;
   else begin
   else begin
    for(i=0;i<AXIS_COUNT-1;i=i+1)words[i]<=words[i+1];
    for(i=0;i<AXIS_COUNT-1;i=i+1)words[i]<=words[i+1];
    words[AXIS_COUNT-1]<=write_data;
    words[AXIS_COUNT-1]<=write_data;

+ 9 - 9
tests/sim/motor_axis_bank_tb.v

@@ -4,36 +4,36 @@ module axis_bank_case #(parameter integer N=3)(output reg done=0);
  reg rst_n=0;
  reg rst_n=0;
  localparam AW=(N<=1)?1:$clog2(N);
  localparam AW=(N<=1)?1:$clog2(N);
  reg [AW-1:0] axis=0;
  reg [AW-1:0] axis=0;
- reg [257:0] data=0;
- wire [257:0] selected;
- wire [N*258-1:0] diagnostic;
- reg [257:0] reference[0:N-1];
+ reg [321:0] data=0;
+ wire [321:0] selected;
+ wire [N*322-1:0] diagnostic;
+ reg [321:0] reference[0:N-1];
  motor_axis_state_bank #(.AXIS_COUNT(N),.PARALLEL_TELEMETRY(1)) dut(
  motor_axis_state_bank #(.AXIS_COUNT(N),.PARALLEL_TELEMETRY(1)) dut(
   .clk(clk),.rst_n(rst_n),.axis(axis),.write_data(data),.read_data(selected),.diagnostic_data(diagnostic));
   .clk(clk),.rst_n(rst_n),.axis(axis),.write_data(data),.read_data(selected),.diagnostic_data(diagnostic));
  integer i,checks=0,cycle;
  integer i,checks=0,cycle;
  reg [31:0] random_state=32'h5EEDBEEF;
  reg [31:0] random_state=32'h5EEDBEEF;
- reg [287:0] random_word;
+ reg [351:0] random_word;
  always @(posedge clk)begin
  always @(posedge clk)begin
   if(!rst_n)begin
   if(!rst_n)begin
-   axis<=0;for(i=0;i<N;i=i+1)reference[i]<=258'd1;
+   axis<=0;for(i=0;i<N;i=i+1)reference[i]<=322'd1;
   end else begin
   end else begin
    if(selected!==reference[axis])$fatal(1,"%0d-axis rotating read is not logical axis %0d",N,axis);
    if(selected!==reference[axis])$fatal(1,"%0d-axis rotating read is not logical axis %0d",N,axis);
    reference[axis]<=data;axis<=axis==N-1 ? 0 : axis+1'b1;checks=checks+1;
    reference[axis]<=data;axis<=axis==N-1 ? 0 : axis+1'b1;checks=checks+1;
   end
   end
   #1;
   #1;
   if(selected!==reference[axis])$fatal(1,"%0d-axis post-clock rotation mismatch",N);
   if(selected!==reference[axis])$fatal(1,"%0d-axis post-clock rotation mismatch",N);
-  for(i=0;i<N;i=i+1)if(diagnostic[i*258+:258]!==reference[i])$fatal(1,"%0d-axis diagnostic ordering/reset mismatch",N);
+  for(i=0;i<N;i=i+1)if(diagnostic[i*322+:322]!==reference[i])$fatal(1,"%0d-axis diagnostic ordering/reset mismatch",N);
  end
  end
  initial begin
  initial begin
   repeat(3)@(negedge clk);
   repeat(3)@(negedge clk);
   for(cycle=0;cycle<1200;cycle=cycle+1)begin
   for(cycle=0;cycle<1200;cycle=cycle+1)begin
    //37 is coprime to3/12, exercising reset at every rotation position.
    //37 is coprime to3/12, exercising reset at every rotation position.
    rst_n=(cycle%37)!=0;
    rst_n=(cycle%37)!=0;
-   for(i=0;i<9;i=i+1)begin
+   for(i=0;i<11;i=i+1)begin
     random_state={random_state[30:0],random_state[31]^random_state[21]^random_state[1]^random_state[0]};
     random_state={random_state[30:0],random_state[31]^random_state[21]^random_state[1]^random_state[0]};
     random_word[i*32+:32]=random_state;
     random_word[i*32+:32]=random_state;
    end
    end
-   data=random_word[257:0];
+   data=random_word[321:0];
    @(negedge clk);
    @(negedge clk);
   end
   end
   if(checks<1000)$fatal(1,"rotation test was empty");
   if(checks<1000)$fatal(1,"rotation test was empty");

+ 1 - 1
tests/sim/motor_axis_contract_tb.v

@@ -131,7 +131,7 @@ module motor_axis_contract_tb;
         if(total!==0 || pos!==32'h80000000 || (telemetry[56*8 +:32]&32'h11)!==32'h11)
         if(total!==0 || pos!==32'h80000000 || (telemetry[56*8 +:32]&32'h11)!==32'h11)
             $fatal(1,"counter and signed coordinate wrap telemetry");
             $fatal(1,"counter and signed coordinate wrap telemetry");
         $display("CASE counter_wrap_telemetry PASS");
         $display("CASE counter_wrap_telemetry PASS");
-        reset();@(negedge clk);dut.hit_memory[0]=64'hFFFFFFFFFFFFFFFF;dut.hit_valid=1;
+        reset();@(negedge clk);dut.u_state_bank.u_words.words[0][321:258]=64'hFFFFFFFFFFFFFFFF;
         ll=1;ul=1;repeat(5)@(negedge clk);
         ll=1;ul=1;repeat(5)@(negedge clk);
         if(lh!=0 || uh!=0 || telemetry[56*8+2+:2]!=2'b11)$fatal(1,"32-bit hit counter wrap flags");
         if(lh!=0 || uh!=0 || telemetry[56*8+2+:2]!=2'b11)$fatal(1,"32-bit hit counter wrap flags");
         clear_counters=1;@(negedge clk);clear_counters=0;repeat(4)@(negedge clk);
         clear_counters=1;@(negedge clk);clear_counters=0;repeat(4)@(negedge clk);