(*R_Trigs*)
FBI_pulse_re (CLK := conv_pulse, Q => pulse_re);
FBI_Gate_re (CLK := entrance_pe_blocked, Q => gate_re);
FBI_sim_pulse_re (CLK := sim_pulse, Q => sim_pulse_re);
(*Increment a sequence number and load it into the tracking array at position 0 when the gate is blocked*)
IF gate_re AND conveyor_running THEN
seq_num:= seq_num + 1;
IF (seq_num > 100) OR (seq_num <=0) THEN
seq_num:=1;
END_IF;
shift_table[0]:= seq_num;
END_IF;
IF ( NOT entrance_pe_blocked AND conveyor_running) THEN
shift_table[0]:= 0;
END_IF;
(* This logic shifts the tracking table "shift_table" every time we see a pulse*)
IF ((pulse_re AND NOT sim_pulse_enable) OR (sim_pulse_re AND sim_pulse_enable)) AND conveyor_running THEN
pointer1:= 1999;
WHILE (pointer1 >= 1) DO
shift_table[(pointer1)] :=shift_table[(pointer1-1)];
pointer1:= (pointer1 -1);
END_WHILE;
END_IF;