Easy type conversion question for you guys

S

Shannon

Guest
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
 
Shannon <sgomes@sbcglobal.net> writes:

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

--
martin.j.thompson@trw.com
TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html
 
On Jul 4, 2:38 am, Martin Thompson <martin.j.thomp...@trw.com> wrote:
Shannon <sgo...@sbcglobal.net> writes:

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

--
martin.j.thomp...@trw.com
TRW Conekt - Consultancy in Engineering, Knowledge and Technologyhttp://www.conekt.net/electronics.html
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
 
Shannon wrote:

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
 

Welcome to EDABoard.com

Sponsor

Back
Top