srahulkumar1989 0 Report post Posted October 17, 2013 Hello all, I have just started the practical implementations in systemC. Here i am trying to implement a paradigm of Bit slicing in systemC. Like: My input is a 8 bit unsignedint type which should be sliced and the output to be a 2 bit unsignedint type. Here i am trying to slice the bits with some conditions - bottom bit of slice - offset by 0 - Relative to LSB Overall - slicing from bit 0 to bit 5 of a 8 bit input. #include "systemc.h" SC_MODULE(slice){ sc_in<sc_uint< 8,8> > input; sc_out<sc_uint< 2,2> > output; void do_slice(){ // slice the inputs and write at the output port } SC_CTOR(slice) { SC_METHOD(do_slice); sensitive<< input; } }; Is there any methods availabe for slicing or Extracting bits in systemC? if yes, how to choose the exact particular bits need to be sliced It will be grateful if any help is provided to proceed with the solution. Thanks in advance Share this post Link to post Share on other sites
apfitch 201 Report post Posted October 17, 2013 You can use the range() method. However please note that the range() method belongs to the integer and vector classes, not to the ports. So for instance to pick out the bottom 5 bits you could use input.read().range(4,0) All the available methods are listed in the IEEE 1666-2011 standard, which you can download free via the accellera website. regards Alan P.S. for sc_uint there is only one template argument, so sc_uint<8>, not sc_uint<8,8>. 1 karandeep963 reacted to this Share this post Link to post Share on other sites
srahulkumar1989 0 Report post Posted October 17, 2013 Thanks Mr. Alan for the response. i have tried to know about range method by a simple code . variable.range(4,0) will reprensent the bottom 5 bits and discard the remaining 3 bits of a 8 bit input. variable.range(7,5) will discard the bottom 5 bits and represent the remaining 3 bits of a 8 bit input. please correct me if i am wrong. Share this post Link to post Share on other sites
apfitch 201 Report post Posted October 17, 2013 That's correct, Alan Share this post Link to post Share on other sites