FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > VHDL

VHDL comp.lang.vhdl newsgroup / Usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-10-2003, 03:40 PM
Andreas
Guest
 
Posts: n/a
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
Reply With Quote
  #2 (permalink)  
Old 10-13-2003, 07:07 AM
Eyck Jentzsch
Guest
 
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

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SystemC and TLM [email protected] FPGA 1 05-17-2007 10:38 PM
I need systemc.h ahosyney FPGA 1 03-14-2005 09:40 AM
Quartus VHDL problem with aggregate and type cast rickman VHDL 3 07-15-2003 05:24 AM
Quartus VHDL problem with aggregate and type cast rickman FPGA 3 07-15-2003 05:24 AM


All times are GMT +1. The time now is 11:51 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved