Jump to content
dakupoto

Question regarding VHDL -> SystemC conversion

Recommended Posts

Could some SystemC guru please provide some hints to my

problem ? I am trying to translate some old VHDL code into

SystemC, and running into issues.

I have a VHDL entity with 3 input ports and one output ports.

Of the 3 input ports, the data type of 2 is std_logic, which

can be immediately translated to sc_dt::sc_logic. The other

input port and the one output port has data type Boolesn.

I am confused about how to convert VHDL statements

that are executed always, into corresponding SystemC

methods. If I use a SystemC SC_METHOD, they will

always get executed, or alternatively use SC_THREAD

and make the method sensitive to changes in the input

ports. For example, if I have the following VHDL statement :

rstall <= resetn and pcirst when PCIEN else resetn;

(Here, 'resetn' and 'pcirst' are input ports of type std_logic

in VHDL, and PCIEN is a Boolean environment variable)

Any hint, suggestions would be of immense help. Thanks

in advance for your help.

Share this post


Link to post
Share on other sites

I am sorry I am not able to understand the statement " If I use a SystemC SC_METHOD, they will

always get executed". SC_METHOD will only get executed in case of activity on their senstivity list.

If I have understood your problem correctly then the above statement rstall <= resetn and pcirst when PCIEN else resetn; can be implemented as follows.

SC_METHOD(drive_rstall);

sensitive << resetn << pcirst;

void drive_rstall(void)

{

if(PCIEN){

rstall.write(resetn.read() & pcirst.read());

}else{

rstall.write(resetn.read());

}

}

So the above process will only be executed whenever there is any activity on resetn and pcirst.

Hope it helps.

Although I am not an expert on VHDL to SystemC conversion but there are some commericial tools available from companies like Carbon which can convert your behavioral VHDL/Verilog code to equivalent SystemC code. You may explore them too.

Share this post


Link to post
Share on other sites

Hello Sir,

I fully agree with your point about SC_METHOD, but why not use a

SC_THREAD as:

void test_thread_0()

{

while(1)

{

wait();

rstall = PCIEN == '1' ? (rstin.read() & pcirstin.read()) : rstin.read();

}

}

And in the constructor:

SC_CTOR(test)

{

SC_THREAD(test_thread_0);

sensitive << rstin << pcirstin;

}

Once again, this thread will respond to any changes in either input

port rstin or pcirstin.

So, which is a better way to tackle this issue ?

Share this post


Link to post
Share on other sites

Hi, a couple of points - firstly if you use SC_THREAD to emulate a VHDL process, the wait() function call should be at the bottom of the thread.

Regarding SC_METHOD vs SC_THREAD, in this case there is no different behaviour. SC_METHODs may simulate faster due to few context switches to the kernel, so I would prefer an SC_METHOD.

regards

Alan

Share this post


Link to post
Share on other sites

As mentioned by Alan, using SC_METHOD is mostly recommended due to context switching involved with SC_THREADs and in your case since you don't have any blocking needs or delays to be inserted , SC_METHOD should be the preferrable choice.

Regards,

Sandeep Jana

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

×