Chargement…
Chargement…
G_MODULUS is positive and no greater than 255. Unsigned inputs satisfy 0 <= x,y < m. For addition, calculate x+y and subtract m once if needed. For subtraction, use x-y when x>=y, otherwise x+m-y.
The circuit is combinational. i_sub='0' selects addition and i_sub='1' subtraction. o_result is unsigned 8-bit and always remains below m when preconditions hold.
The testbench sets m=251 and checks sum reduction, wrapped subtraction, maximum values, and zero.