Jump to content
Sign in to follow this  
Rashmi11

syntax for copying the bit vector , systemC 2.3.1 version

Recommended Posts

Hi All ,

I am trying to copy a particular bit  from one bit vector to other . I tried several ways of assigning the values but could not get it right. Also ,I want to assign a variable 'i' to a constant value in the loop . Below is the code . I have highlighted the lines where I am getting error. I would really appreciate if anyone could help in this . Thank you. 

 

#include "systemc.h"
SC_MODULE(S_R){
sc_in <bool> clk;
sc_in < sc_bv<8> > din;
sc_in <bool> rst;
sc_out< sc_bv<8> > dout;
sc_in<bool> load;
 
sc_bv<8> dinp;
sc_int<1> i ;
 
 
void shift()
{
if(rst)
{
dout=0;
}
else if(load)
{
dinp=din;
i.write('0');
dout[0].write(dinp[7]);
cout<<sc_time_stamp()<<"\tDESIGN1 --> input data:"<<dinp<<"\toutput data:"<<dout<<"\n";
}
else
{
dinp=dinp<<1;
dout.write(dinp[7]);
i=i+1;
cout<<sc_time_stamp()<<"\tDESIGN --> input data:"<<dinp<<"\toutput data:"<<dout<<"\n";
 
}
 
}
 
 
SC_CTOR(S_R)
{
SC_METHOD(shift);
sensitive<<clk.pos();
 
}
 
};
 

Share this post


Link to post
Share on other sites

Hi, the trick to understanding this is to notice the difference between

 

sc_in < bool > dout [8]; // an array of 8 boolean ports

 

and

 

sc_in<sc_bv<8> > dout; // a single port containing an 8 bit vector.

 

So you need to get at the 8 bit value within dout.

 

The easiest way round it is probably

 

sc_bv<8> dout_temp = dout.read();

dout_temp[0] = dinp.read()[7];

dout.write(dout_temp);

 

For the use of sc_int<1>, sc_int is not a signal, therefore does not have a write() method.

 

Just do

i = 0;

 

 

Generally if you're going to do code like you've shown above, I would recommend using temporary variables, then assigning the variables to the ports - or even easier, just use VHDL or Verilog :-)

 

regards

Alan

Share this post


Link to post
Share on other sites

 

Hi All ,

I am trying to copy a particular bit  from one bit vector to other . I tried several ways of assigning the values but could not get it right. Also ,I want to assign a variable 'i' to a constant value in the loop . Below is the code . I have highlighted the lines where I am getting error. I would really appreciate if anyone could help in this . Thank you. 

 

#include "systemc.h"
SC_MODULE(S_R){
sc_in <bool> clk;
sc_in < sc_bv<8> > din;
sc_in <bool> rst;
sc_out< sc_bv<8> > dout;
sc_in<bool> load;
 
sc_bv<8> dinp;
sc_int<1> i ;
 
 
void shift()
{
if(rst)
{
dout=0;
}
else if(load)
{
dinp=din;
i.write('0');
dout[0].write(dinp[7]);
cout<<sc_time_stamp()<<"\tDESIGN1 --> input data:"<<dinp<<"\toutput data:"<<dout<<"\n";
}
else
{
dinp=dinp<<1;
dout.write(dinp[7]);
i=i+1;
cout<<sc_time_stamp()<<"\tDESIGN --> input data:"<<dinp<<"\toutput data:"<<dout<<"\n";
 
}
 
}
 
 
SC_CTOR(S_R)
{
SC_METHOD(shift);
sensitive<<clk.pos();
 
}
 
};

Hello,

 A bit vector is a C++ RTL vector. So, have you looked into the possibility

of using a copy constructor ? I am sure the basic C++ STL vector supports

a cop constructor, so this ought to work.

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.

Sign in to follow this  

×
×
  • Create New...