Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Easy type conversion question for you guys

Reply
Thread Tools

Easy type conversion question for you guys

 
 
Shannon
Guest
Posts: n/a
 
      07-03-2007
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

 
Reply With Quote
 
 
 
 
Martin Thompson
Guest
Posts: n/a
 
      07-04-2007
Shannon <> 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

--

TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html
 
Reply With Quote
 
 
 
 
Shannon
Guest
Posts: n/a
 
      07-05-2007
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

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      07-05-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if you guys go non-hybrid blu-ray or hd-dvd.... you guys may be looking at laserdisc/sacd type sales. Doc Martian DVD Video 2 03-23-2006 06:01 PM
!!!5 VERY EASY STEPS TO GET PRIZES ONLINE FREE NO CC TRUELYINTERNATIONAL PLZZZ HELP ME GET MORE U GUYS IF U READ THIS. testonamo Computer Support 1 01-30-2005 06:50 PM
Hey guys...take a look at what these guys are doing... christo@studiochristopher.com Digital Photography 1 12-23-2004 12:40 AM
I know you guys try and answer every question so.... Nikki Bass Computer Support 2 11-06-2004 01:55 AM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. luna ASP .Net 1 02-13-2004 01:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57