Use a counter instead of a shift register + comparator.
Attach a file by drag & drop or click to upload