imagine that I have a certain buffer of bytes and a write pointer for this buffer, like:
reg[N-1:0][7:0]mybuffer;
reg[$clog2(N+1)-1:0] wptr;
where wptr
points to the next position in the buffer where I want to store incoming data.
Now, imagine that my input data is also a block of bytes, like:
reg[M-1:0][7:0] indata;
with M
< N
.
If I code something like:
mybuffer[wptr +: M] = indata;
everything works, with the noticeable exception of when wptr > N-M
, which in my application will never happen.
However, this doesn't seem a very clean way to approach the problem, and cause warnings with linting tools. Extending the buffer doesn't seem a nice approach either.
What is a clean and correct way to implement something like this?
Thanks.