Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - cast from sc_ufixed to int in systemC

 
Thread Tools Search this Thread
Old 10-10-2003, 03:40 PM   #1
Default cast from sc_ufixed to int in systemC


Hi!

I'm working with systemC to realize a processor like structure.

I have a signed variable (RAM) declared after the systemC syntax
"sc_ufixed<32,32> RAM".

I also have an signed integer in my testbench, "int myIplImage.depth".

If I give this unsigned RAM the value of a signed variable
myIplImage.depth in my testbench,
::RAM[100] = myIplImage.depth;
the bit pattern is transferred.

But when I do it the other way around,
::myIplImage.depth = RAM[100];
to extract my results back to the testbench, the contest is messed up
since the RAM keeps a "bigger" value (since it's unsigned) then what
will fit into the signed variable "myIplImage.depth".

How can I transfer the unsigned value of my RAM back to the signed
variable in my testbench? (I like to do this in a bit wise matter,
just transfer the bit pattern.)

(PS. myIplImage.depth = (signed int)RAM[100] does not work...)

best regards,
Andreas Lundgren


Andreas
  Reply With Quote
Old 10-13-2003, 07:07 AM   #2
Eyck Jentzsch
 
Posts: n/a
Default Re: cast from sc_ufixed to int in systemC
Andreas wrote:
> Hi!
>
> I'm working with systemC to realize a processor like structure.
>
> I have a signed variable (RAM) declared after the systemC syntax
> "sc_ufixed<32,32> RAM".
>
> I also have an signed integer in my testbench, "int myIplImage.depth".
>
> If I give this unsigned RAM the value of a signed variable
> myIplImage.depth in my testbench,
> ::RAM[100] = myIplImage.depth;
> the bit pattern is transferred.
>
> But when I do it the other way around,
> ::myIplImage.depth = RAM[100];
> to extract my results back to the testbench, the contest is messed up
> since the RAM keeps a "bigger" value (since it's unsigned) then what
> will fit into the signed variable "myIplImage.depth".
>
> How can I transfer the unsigned value of my RAM back to the signed
> variable in my testbench? (I like to do this in a bit wise matter,
> just transfer the bit pattern.)
>
> (PS. myIplImage.depth = (signed int)RAM[100] does not work...)
>
> best regards,
> Andreas Lundgren

If I'm not totally wrong you declare a fixpoint variable with 32 bits
and access bit 100, this should result in garbage...
the following should work:
RAM=myIplImage.depth;
myIplImage.depth=RAM.to_int();
or:
myIplImage.depth=(int)RAM.double();
HTH

-Eyck



Eyck Jentzsch
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
wicked video with origonal broadway cast TheaterBoy DVD Video 0 10-21-2006 08:50 PM
Michael Biehn wasn't the first cast as 'Hicks' in Aliens......Who Was? SickBoy DVD Video 18 01-07-2004 10:40 PM
Cast Away DVD Allan H-E DVD Video 9 10-15-2003 04:03 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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