Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

SystemC without Signals

$
0
0

Hi All

 

I tried to implement a simple Task Scheduler in SystemC. It works as follows:

I have three modules "TaskA" , "TaskB" and "CPU". The algorithm works in such a way that the CPU gives full utilization if only one task is present at a time and gives 50% utilization if both the tasks are present. The Arrival times of both the tasks are assigned before the start of the simulation. I was able to implement it with ports and signals, but now i want to measure the performace without ports and signals (i.e) using the C++ and the internal clock of systemc( sc_time_stamp(), sc_start() etc ).

 

Presently, i have the following:

 

class Task : sc_module

{

void taskA()

{

....

bool tskA = true;

if(tskA)

{

eventA.notify(10,SC_NS); // Arrival time of A as a Event

tskA = false

}

else

{

outA= true // So that we get the event after 10ns of simualtion time

}

 

void taskB()

{

.....

bool tskB = true;

if(tskB)

{

eventB.notify(20,SC_NS); // Arrival Time of B as a Event

tskB = false;

}

else

{

outB = true; // To get taskB after 20ns after the start simulation 

}

}

 

SC_CTOR()

{

SC_METHOD(taskA);

SC_METHOD(taskB);

 

sensitive << eventA;

sensitive << eventB;

}

 

 

class CPU: sc_module

{

 

Task A;

Task B;

 

void cpu()

{

 

A.taskA();

B.taskB();

 

if(outA)

{

//Debug statement

 

cout << "A arrives @"<< sc_time_stamp() << endl;

 

some calculation

}

else if (outA && outB)

{

//Debug Statement

 

cout << "B arrives @" << sc_time_stamp() << endl;

 

some calculation}

 

}

}

 

SC_CTOR(CPU) : A("AT"), B("BT")

{

SC_METHOD(cpu);

 

sensitive << eventA;

sensitive << eventB;

}

 

 

But, the problem is the modules gets executed always. To me more precise:

 

What I expect as Output is:

 

A arrives @ 10ns

B arrives @ 20ns

 

 

But, What I am getting now is

 

A arrives @ 10ns

B arrives @ 10ns

A arrives @ 20ns

B arrives @ 20ns

 

I am not able to figure out where I am going wrong, can anyone please give me suggestions/ point out the msitake i am doing here?


Viewing all articles
Browse latest Browse all 595

Trending Articles