KMLM List
View email archives for the history of this mailing list.
|
|
|
|
systemc-forum - an observation of sc_pause()
|
Message Thread:
Previous |
Next
|
- To: systemc-forum@xxxxxxxxxxxxxxxxxxx
- From: "Sun, Guanyi" <falcom.sgy@xxxxxxxxx>
- Date: Thu, 16 Feb 2012 16:14:30 +0800
- Send Email to systemc-forum@lists.accellera.org:
- Send new message
- Reply to this message
|
Hi all,
Recently, i do an experiment of sc_pause(). I write following code
// ===============example =====================//
SC_MODULE (TEST) {
SC_CTOR (TEST) {
SC_METHOD(pause);
sensitive << pause_event;
dont_initialize();
SC_THREAD(test_thread_1);
SC_THREAD(test_thread_2);
}
void pause()
{
sc_pause();
sc_start();
}
void test_thread_1()
{
for (int i = 0; i < 10; i++)
{
printf("in thread_1 @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
wait(5,sc_core::SC_NS);
}
}
void test_thread_2()
{
for (int i = 0; i < 5; i++)
{
printf("in thread_2 @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
wait(10,sc_core::SC_NS);
sc_pause();
printf("thread_2 pause @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
sc_start();
printf("thread_2 work again @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
}
}
// ===============example=====================//
The result shows following
in thread_1 @ 0 ns
in thread_2 @ 0 ns
in thread_1 @ 5 ns
thread_2 pause @ 10 ns
in thread_1 @ 10 ns
in thread_1 @ 15 ns
in thread_1 @ 20 ns
in thread_1 @ 25 ns
in thread_1 @ 30 ns
in thread_1 @ 35 ns
in thread_1 @ 40 ns
in thread_1 @ 45 ns
The thread_2 does work again after first sc_pause() called.
Then, i change the design
// ==============new code =====================//
void test_thread_2()
{
for (int i = 0; i < 5; i++)
{
printf("in thread_2 @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
wait(10,sc_core::SC_NS);
printf("thread_2 pause @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
b_event.notify();
printf("thread_2 work again @ %d ns\n",
sc_core::sc_time_stamp().value()/1000);
}
}
//===============new code ====================//
This time the result like
in thread_1 @ 0 ns
in thread_2 @ 0 ns
in thread_1 @ 5 ns
thread_2 pause @ 10 ns
thread_2 work again @ 10 ns
in thread_2 @ 10 ns
in thread_1 @ 10 ns
in thread_1 @ 15 ns
thread_2 pause @ 20 ns
thread_2 work again @ 20 ns
in thread_2 @ 20 ns
in thread_1 @ 20 ns
in thread_1 @ 25 ns
thread_2 pause @ 30 ns
thread_2 work again @ 30 ns
in thread_2 @ 30 ns
in thread_1 @ 30 ns
in thread_1 @ 35 ns
thread_2 pause @ 40 ns
thread_2 work again @ 40 ns
in thread_2 @ 40 ns
in thread_1 @ 40 ns
in thread_1 @ 45 ns
thread_2 pause @ 50 ns
thread_2 work again @ 50 ns
This time, thread-2 can work normally. I still have no idea about this
after check the IEEE1666-2011 document. I want to know why and which
key information i am missing.
--
Thanks a lot
Sun,Guanyi
|
|
By Date:
Previous |
Next
|
Current Thread
|
By Thread:
Previous |
Next
|
- an observation of sc_pause(), Sun, Guanyi (you are here)
|
|