MOD operator
Author Message
MOD operator

Hi,

I am trying to use the mod operator in my VHDL code, but my synthesis tool
only supports X MOD Y; where Y is a power of 2; X an integer.

What would be the equivalency between X MOD 255 and X MOD 256 ?
I would also like to find the equivalency between X MOD (2**m - 1) and
X MOD (2**m); where m is an integer.

Any help will be highly appreciated.

Thanks,
Michele

Mon, 28 Feb 2000 03:00:00 GMT
MOD operator

X= aY + r = Xn-1... X1 X0

X/Y = a
X mod Y = r    si Y=2**m   r=Xm-1...X1 X0,
that's why it's so trivial do perform X mod 2**m

X= a (Y-1+1) + r = a (Y-1) + (a+r)

=> X mod Y-1 = (X/Y + X mod Y ) mod Y-1 = Xn-1 ... Xm + Xm-1... X0 mod (Y-1)
(if Y=2**m)

The advantage is that ^^ may be smaller than X. You can iterate the operation till
the result of the addition is less than Y-1. Note that it is easy to know the
maximum number of stages of addition you will need to perform the modulo.

Olivier

Mon, 28 Feb 2000 03:00:00 GMT
MOD operator

Quote:
>Hi,
>I am trying to use the mod operator in my VHDL code, but my synthesis tool
>only supports X MOD Y; where Y is a power of 2; X an integer.
>What would be the equivalency between X MOD 255 and X MOD 256 ?
>I would also like to find the equivalency between X MOD (2**m - 1) and
>X MOD (2**m); where m is an integer.
>Any help will be highly appreciated.
>Thanks,
>Michele

What synthesis tool are you using?  Possibly there is some
built-in function/component within a library for handling mod.

I had the same problem when I was trying to do multiply once, and the tool
required the second operand to be a power of 2.

-Bob

Wed, 01 Mar 2000 03:00:00 GMT
MOD operator

Quote:

>>I am trying to use the mod operator in my VHDL code, but my synthesis tool
>>only supports X MOD Y; where Y is a power of 2; X an integer.

>>What would be the equivalency between X MOD 255 and X MOD 256 ?
>>I would also like to find the equivalency between X MOD (2**m - 1) and
>>X MOD (2**m); where m is an integer.

There's not really any equivalency; knowing X mod 256 doesn't

However your problem is simpler if the range of X is restricted.
For example, If as I suspect you're doing Galois-field
operations, you might need to take X mod 255 where X is in
the range 0 through 509.  In that case

X mod 255  = X       (if X < 255)
X-255   (otherwise)

Hope this helps a bit --

Steve

Fri, 03 Mar 2000 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages