Mod (%) Function in VHDL

K

Kwaj

Hi,

I am trying to implement an interleaver for an error-control design I am
working on. The interleaver employs the mod function and as such I am
wondering whether VHDL already has this function available?

I have been unable to find it thus far but was hoping that I didn't need to
write the function myself.

- Kwaj
 
A

Allan Herriman

Hi,

I am trying to implement an interleaver for an error-control design I am
working on. The interleaver employs the mod function and as such I am
wondering whether VHDL already has this function available?

I have been unable to find it thus far but was hoping that I didn't need to
write the function myself.

VHDL has mod and rem. They return the same thing if both arguments
are positive.

How hard did you look?

Regards,
Allan.
 
J

Jim Lewis

Look in your book at REM and MOD.

Hi,

I am trying to implement an interleaver for an error-control design I am
working on. The interleaver employs the mod function and as such I am
wondering whether VHDL already has this function available?

I have been unable to find it thus far but was hoping that I didn't need to
write the function myself.

- Kwaj

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
A

Allan Herriman

VHDL has mod and rem. They return the same thing if both arguments
are positive.

BTW, they produce different results for negative inputs:

5 mod 3 = 2
(-5) mod 3 = 1
5 mod (-3) = -1
(-5) mod (-3) = -2

whereas

5 rem 3 = 2
(-5) rem 3 = -2
5 rem (-3) = 2
(-5) rem (-3) = -2


Since '%' is in the subject...
IIRC, the C language doesn't actually define what % does with negative
arguments, and it's likely that the compiler will just use the
underlying machine mod operation (if one exists), so results may vary
from architecture to architecture (in keeping with the C spirit).


Regards,
Allan
 
K

Kwaj

cheers Allan. I honestly had not come across it in my reference. I guess
that leads me to another question - what's a concise reference for VHDL?
i.e. a book or URL which a lot of you guys use to look up commands?
 
A

Allan Herriman

One good place for VHDL Syntax is
http://www.amontec.com/fix/vhdl_memo/index.html

or follow some of the other links from

http://tech-www.informatik.uni-hamburg.de/vhdl/

I find the best concise syntax description is the set of Qualis Quick
Reference Cards. They don't describe semantics, but often a reminder
of the syntax is all that's required.

VHDL (you'll need both):
http://www.eda.org/rassp/vhdl/guidelines/vhdlqrc.pdf
http://www.eda.org/rassp/vhdl/guidelines/1164qrc.pdf

Verilog:
http://www.eda.org/rassp/vhdl/guidelines/vlogqrc.pdf

BTW, Qualis seems to have been swallowed by Synopsys.

Regards,
Allan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top