Jump to content
Dev

Bit slicing for fixed point types? in systemC

Recommended Posts

hello,

 

i have jus started working with the systemC implementations for high level synthesis

 

I need to implement the bit slicing paradigm in systemC which i tried with the variable.range() method and it works fine.

 

But when i used with the fixed point types as shown in the code below, it didnt not work.

 


define SC_INCLUDE_FX
#include "systemc.h"

SC_MODULE(slice){


sc_in<sc_fixed<42,12,SC_TRN,SC_SAT> > input
sc_out<sc_fixed<14,14,SC_TRN,SC_SAT> > output

void do_slice(){    //
output=input.read().range(42,28); //ERROR IN THIS LINE
}

SC_CTOR(slice){
    SC_METHOD(do_slice)
            sensitive<<input_re;
             dont_initialize();
}
};

then, i tried of casting the fixed to a float / double value and tried to use it with the range method which also didnt work.

 

So the range() method only works with sc_int and sc_uint?

 

Is there any other way to do bit slicing paradigms for fractional values in systemC?

 

please let me know.

 

Thanks in advance


 

Share this post


Link to post
Share on other sites

You can convert the range object to and from sc_int, e.g.

SC_MODULE(Slice){


    sc_in<sc_fixed<42,12> > input;
    sc_out<sc_fixed<14,14> > output;

    void do_slice(){    //
        sc_int<14> temp = sc_int<14>(input.read().range(41,28));
        output.write( sc_fixed<14,14>(temp) ); 
    }

    SC_CTOR(Slice){
        SC_METHOD(do_slice)
        sensitive<<input;
        dont_initialize();
    }
};

The allowed conversions are shown in IEEE 1666-2011.

 

regards

Alan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...