Explorar el Código

Qualify retained history after selecting the status word

codex hace 3 meses
padre
commit
8b20c3ec57
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      src/motor/motor_engine.v

+ 5 - 2
src/motor/motor_engine.v

@@ -319,7 +319,7 @@ module motor_engine #(
         .clk(clk),.rst_n(rst_n),.write_enable(|ax_limit_pulse),
         .clk(clk),.rst_n(rst_n),.write_enable(|ax_limit_pulse),
         .write_data({ax_limit_time_high,ax_limit_data}),
         .write_data({ax_limit_time_high,ax_limit_data}),
         .read_axis(history_scan_axis),.read_data(limit_read_record));
         .read_axis(history_scan_axis),.read_data(limit_read_record));
-    wire [159:0] status_limit_record=limit_history_valid[limit_read_axis] ? limit_read_record : 160'd0;
+    wire [159:0] status_limit_record=limit_read_record;
     reg [31:0] history_pair;
     reg [31:0] history_pair;
     wire history_selected=telemetry_word_addr>=`MR_AXIS_LAST_LIMIT_POSITION_OFFSET/2 &&
     wire history_selected=telemetry_word_addr>=`MR_AXIS_LAST_LIMIT_POSITION_OFFSET/2 &&
         telemetry_word_addr<(`MR_AXIS_LAST_LIMIT_TIME_HIGH_OFFSET+4)/2;
         telemetry_word_addr<(`MR_AXIS_LAST_LIMIT_TIME_HIGH_OFFSET+4)/2;
@@ -334,7 +334,10 @@ module motor_engine #(
             default:history_pair=0;
             default:history_pair=0;
         endcase
         endcase
     end
     end
-    wire [15:0] history_word=telemetry_word_addr[0] ? history_pair[31:16] : history_pair[15:0];
+    wire [15:0] history_word_unmasked=telemetry_word_addr[0] ? history_pair[31:16] : history_pair[15:0];
+    // Qualify only the requested word. The axis-owned stop reason below is
+    // independent of whether a physical limit history record exists yet.
+    wire [15:0] history_word=limit_history_valid[limit_read_axis] ? history_word_unmasked : 16'd0;
     // Stop reason remains axis-owned in the low byte of the event/reason word.
     // Stop reason remains axis-owned in the low byte of the event/reason word.
     wire [15:0] history_stop_word=telemetry_word_addr==`MR_AXIS_LAST_STOP_REASON_OFFSET/2 ? {12'd0,ax_last_reason[limit_read_axis]} : 16'd0;
     wire [15:0] history_stop_word=telemetry_word_addr==`MR_AXIS_LAST_STOP_REASON_OFFSET/2 ? {12'd0,ax_last_reason[limit_read_axis]} : 16'd0;
     assign telemetry_word_data=history_selected ? (history_word | history_stop_word) :
     assign telemetry_word_data=history_selected ? (history_word | history_stop_word) :