Array file pointer in LZ4 compression

hy,
I am implementing RTL design of LZ4 compression.I take one input file like …
a1 a2 a3 a4 a1 a2 a3 a5 a6 a7 a1 a2 a3 a4 a6 a7 a8
now,a1 take as literal(uncompressed data) at location zero.then take second byte,so it is a2.compare a1 and a2.both are not equal.so a2 is write in output file.same happen in a3 and a4.
then a1 come and a1 matched with literal,then generate offset value=location 4-location 0.next byte back to back a2 is also matched with location 1,as per the compress rule both value will compressed.
suppose location4 match and location5 also match,so how store previous value in buffer and compare with upcoming byte ?

In reply to dipakchavada19:

A forum is probably not the right place to learn how to design digital hardware.

In reply to dave_59:

Thanks dave_59 for giving answer,but can I know which place to find this question solution.