Easy type conversion question for you guys

S

Shannon

I have:

Integer_variable: OUT INTEGER RANGE 0 TO 65535;

and

TYPE reg_type IS ARRAY (0 TO 12) OF STD_LOGIC_VECTOR(var1'RANGE);
SIGNAL regs : reg_type;

and what I want to accomplish is:

Integer_variable <= to_integer(unsigned(regs(6) & regs(5) & regs(4) &
regs(3)));

Is there a way to accomplish this with just type casting? I'd rather
not change the types assigned to 'Integer_variable and 'regs'.

TYIA
Shannon
 
M

Martin Thompson

Hi Shannon,

Sorry - no answers, only questions!
I have:

Integer_variable: OUT INTEGER RANGE 0 TO 65535;

and

TYPE reg_type IS ARRAY (0 TO 12) OF STD_LOGIC_VECTOR(var1'RANGE);

How wide are the vectors?
SIGNAL regs : reg_type;

and what I want to accomplish is:

Integer_variable <= to_integer(unsigned(regs(6) & regs(5) & regs(4) &
regs(3)));

Have you tried it? What doesn't work?
Is there a way to accomplish this with just type casting? I'd rather
not change the types assigned to 'Integer_variable and 'regs'.

I think what you've written ought to work...

Cheers,
Martin
 
S

Shannon

Hi Shannon,

Sorry - no answers, only questions!



How wide are the vectors?




Have you tried it? What doesn't work?


I think what you've written ought to work...

Cheers,
Martin

Sorry to bother anyone with this post. The above DOES work. I am too
embarrassed to explain why I was having problems.

Martin: Actually you bring up a very good point. I realized it after
I posted this message. My use of 'var1'RANGE' is nice and generic but
things will break if 'RANGE' is anything other than 8 bits. I'm not
sure how to fix this, but for now regs are 8bits and
'Integer_variable' is an integer. I put a note in my code and I'll
revisit this when I'm doing my clean-up pass.

Shannon
 
M

Mike Treseler

Shannon said:
Sorry to bother anyone with this post. The above DOES work. I am too
embarrassed to explain why I was having problems.

That's poster's remorse :)
Happens to me all the time.
There is something about clicking that send button
that provides instant enlightenment.

-- Mike Treseler
 

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,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top