Integer to Binary and vice versa

Guest
hey all

if i have something like

module
....
input data;
...
data <= i; // "i" is the result of a for loop
...
Now i want to change data to binary !! how do i do that ?
 
First, there is no such thing as "integer to binary." They are two
different aspects of a number. I hope you are not that dumb.

You have to be clear about what you are asking. Are you asking how to
print out a binary number? Or are you asking how to convert a number to
a binary ASCII string? Binary or decimal are just things that we made up
in our minds, they are all just a way to represent a point in the
one-dimentional world of real numbers.

Secondly, if data is an input port, there's no point in assigning value
to it, period.

~jz

Karmel.Abdeljawad@gmail.com wrote:
hey all

if i have something like

module
...
input data;
..
data <= i; // "i" is the result of a for loop
..
Now i want to change data to binary !! how do i do that ?
 
yes I am asking how to convert a number to a binary ASCII string. and
data is an output port. sorry about that
 
On 27 Feb 2006 11:17:27 -0800, Karmel.Abdeljawad@gmail.com wrote:

yes I am asking how to convert a number to a binary ASCII string. and
data is an output port. sorry about that
ASCII '0' is 8'h30 & '1' is 8'h31. So you just have to look over the
bits you're interested and assign 8'h30 + bit value to the output
buffer.
 
Calling $swrite is an easier way to convert to ASCII.

But it seems unlikely that you would want to drive an ASCII string out
of a port.
 

Welcome to EDABoard.com

Sponsor

Back
Top