From array to integer: could I have problems?

K

Konx

Guest
Hello everyone.

I was searching in the group to check if someone have had the same
problem, and I've found this:

http://groups.google.it/group/comp.lang.verilog/browse_frm/thread/f230e591b38315f8#

Now, I understand that I can just assign the incoming "array [31:0]"
to "int a" without problem.

But in my case the input array is a 16-bit array.

Can I write inside my code something like:

input [15:0] window_size;
int a = window_size;

Could I have any problem, if I do in this way? or it is the "compiler"
that take care of filling the remaining 16 bit of the integer? (I'm
working on a 32-bit machine).

Thanks for help

Francesco.
 
On Feb 12, 4:33 am, Konx <cesco...@gmail.com> wrote:
Hello everyone.

I was searching in the group to check if someone have had the same
problem, and I've found this:

http://groups.google.it/group/comp.lang.verilog/browse_frm/thread/f23...

Now, I understand that I can just assign the incoming "array [31:0]"
to "int a" without problem.

But in my case the input array is a 16-bit array.

Can I write inside my code something like:

input [15:0] window_size;
int a = window_size;

Could I have any problem, if I do in this way? or it is the "compiler"
that take care of filling the remaining 16 bit of the integer? (I'm
working on a 32-bit machine).

Thanks for help

Francesco.
The only problem I see is that an integer is signed and
an array is unsigned unless otherwise defined. So if you
needed to sign extend window_size this will not happen
as written, because as defined window_size is unsigned.
So in this case the integer would always be positive
(zero-extended).

Regards,
Gabor
 
On 12 Feb, 15:23, gabor <ga...@alacron.com> wrote:

The only problem I see is that an integer is signed and
an array is unsigned unless otherwise defined.  So if you
needed to sign extend window_size this will not happen
as written, because as defined window_size is unsigned.
So in this case the integer would always be positive
(zero-extended).
Thanks for both answers! In this particular case, I need only positive
numbers, so it is ok!

Thanks again

Francesco.
 

Welcome to EDABoard.com

Sponsor

Back
Top