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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×