In reply to markylew:
Why insist on using the modulo operator? For most synthesis tools, this operator use is limited to constants of a power of two anyway - meaning the synthesis tool translates a modulus operations to “just look at this subset of bits”. i.e.
foo % 4096
Means to the synthesis tool - “Just look at foo[ 11 : 0 ]”. It’s easier, IMHO to just code it that way explicitly (or use a mask operation).
Most of the ways I’ve coded up a 4KB boundary check (for FPGA synthesis) is similar to what I wrote. It’s clear, concise, and synthesizable. Could someone code up a more clever, optimal version? Perhaps, but its such a tiny part of most designs, that this is usually a don’t care.
Clarity first should be the goal. Optimization is a secondary or even tertiary goal.
Rereading S.P.'s equation now I think it’s in error (or I’m not understanding the point being made)
Start_Address % 4096 == (Start_address + (burst_size * burst_length)) % 4096
In low level terms this is doing the OPPOSITE of what I wrote - this equations boils down to:
wire SP_assert_check = start_ar_addr[ 11 : 0] == end_ar_addr[ 11: 0 ];
Which doesn’t check the right thing.
Regards,
Mark