cast from sc_ufixed to int in systemC

Discussion in 'VHDL' started by Andreas, Oct 10, 2003.

  1. Andreas

    Andreas Guest

    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, Oct 10, 2003
    #1
    1. Advertising

  2. 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, Oct 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,222
    Martien Verbruggen
    Jun 27, 2003
  2. Andreas

    cast from sc_ufixed to int in systemC

    Andreas, Oct 10, 2003, in forum: C Programming
    Replies:
    6
    Views:
    423
    Mark A. Odell
    Oct 14, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,649
    Old Wolf
    Jan 20, 2004
  4. Randall Parker
    Replies:
    4
    Views:
    485
    Jack Saalweachter
    May 19, 2006
  5. Praveen Raj

    cast from int** to int*

    Praveen Raj, Jul 3, 2009, in forum: C Programming
    Replies:
    42
    Views:
    1,346
    Keith Thompson
    Jul 9, 2009
Loading...

Share This Page