Jump to content

Bit slicing in systemc


srahulkumar1989

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
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...