cast from sc_ufixed to int in systemC

A

Andreas

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
 
M

Mark A. Odell

(e-mail address removed) (Andreas) wrote in

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

pete

Andreas said:
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];
 
A

Andreas

Andreas said:
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
 
A

Andreas

(e-mail address removed) (Andreas) wrote in
So why post to a different language's newsgroup? We don't answer C++
questions here either.


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
 
M

Martin Ambuhl

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

Mark A. Odell

(e-mail address removed) (Andreas) wrote in


nce this isn't C, how are we suppose to help? The above line would be
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top