Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > cast from sc_ufixed to int in systemC

Reply
Thread Tools

cast from sc_ufixed to int in systemC

 
 
Andreas
Guest
Posts: n/a
 
      10-10-2003
Hi!

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

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
 
 
 
 
Mark A. Odell
Guest
Posts: n/a
 
      10-10-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Andreas) wrote in
news:(E-Mail Removed) om:

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


So why post to a different language's newsgroup? We don't answer C++
questions here either.

> 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".


Since this isn't C, how are we suppose to help? The above line would be
syntax error. I think you need to search for a newsgroup or forum that
discusses SystemC, a different language from ISO C.

--
- Mark ->
--
 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      10-11-2003
Andreas wrote:
>
> Hi!
>
> I'm working with systemC to realize a processor like structure in HDL.
>
> 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...)


*(unsigned*)(&myIplImage.depth) = RAM[100];

--
pete
 
Reply With Quote
 
Andreas
Guest
Posts: n/a
 
      10-13-2003
> Andreas wrote:
> >
> > Hi!
> >
> > I'm working with systemC to realize a processor like structure in HDL.
> >
> > 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...)

>
> *(unsigned*)(&myIplImage.depth) = RAM[100];


Thank you very much! It works just fine!
/Andreas Lundgren
 
Reply With Quote
 
Andreas
Guest
Posts: n/a
 
      10-13-2003
> (E-Mail Removed) (Andreas) wrote in
> news:(E-Mail Removed) om:
>
> > I'm working with systemC to realize a processor like structure in HDL.

>
> So why post to a different language's newsgroup? We don't answer C++
> questions here either.
>
> > 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".

>
> Since this isn't C, how are we suppose to help? The above line would be
> syntax error. I think you need to search for a newsgroup or forum that
> discusses SystemC, a different language from ISO C.


Just because you don't know the answer to the questions doesn't mean
that everybody else is that ignorant. SystemC is just an extension of
C, and it wasn't a specific question on the systemC library.
/Andreas
 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      10-13-2003
Andreas wrote:


> Just because you don't know the answer to the questions doesn't mean
> that everybody else is that ignorant. SystemC is just an extension of
> C, and it wasn't a specific question on the systemC library.


Just because you are an ignorant fool does not make SystemC a C implementation.


--
Martin Ambuhl

 
Reply With Quote
 
Mark A. Odell
Guest
Posts: n/a
 
      10-14-2003
(E-Mail Removed) (Andreas) wrote in
news:(E-Mail Removed) om:

nce this isn't C, how are we suppose to help? The above line would be
>> syntax error. I think you need to search for a newsgroup or forum that
>> discusses SystemC, a different language from ISO C.

>
> Just because you don't know the answer to the questions doesn't mean
> that everybody else is that ignorant. SystemC is just an extension of
> C, and it wasn't a specific question on the systemC library.


No, we don't talk about things that aren't topical *here* - even if we all
know the answer to your question.

--
- Mark ->
--
 
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
cast from int** to int* Praveen Raj C Programming 42 07-09-2009 07:14 AM
Alternative for int ** to const int ** cast? Randall Parker C++ 4 05-19-2006 06:56 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
cast from sc_ufixed to int in systemC Andreas VHDL 1 10-13-2003 06:07 AM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments