Skip Nav
Home » Forums » SystemC Forum

Icon - KMLM List KMLM List

View email archives for the history of this mailing list.

List Home All Archives Dates Threads Authors Subjects
systemc-forum - Re: [systemc-forum] Hi need help regarding executing process and methods Message Thread: Previous | Next
  • To: alan.fitch@xxxxxxxxxx
  • From: Rama krishna Reddy <krisreddi46@xxxxxxxxx>
  • Date: Sun, 12 Feb 2012 00:13:24 +0100
  • Cc: adhikari@xxxxxxxxxxxxxxxx, systemc-forum@xxxxxxxxxxxxxxxxxxx
Send Email to
Send new message
Reply to this message
Hi Alan,
Thanks for suggestion of using sc_fifo.
As i said in the previous reply my module_a should execute for a  duration 20 us, module_b for duration 200 us and module_c for duration of 40 us and then the process should continue till the given simulation time. I made changes to my code using fifos but i am not getting required output. Here i am sending my code please give some suggestions.

#include <systemc.h>
#include <iostream>

SC_MODULE(example_fifo) {
  sc_in<bool> clk;
  void example_fifo::module_b(void);
  void example_fifo::module_a(void);
  void example_fifo::module_c(void);
  // Constructor
  SC_CTOR(example_fifo) {
    // Size the packet_fifo to 5 ints.
    sc_fifo<int> packet_fifo (5);
  // Declare the FIFO
  sc_fifo<int> packet_fifo;

void example_fifo::module_b(void) {
  int val;
  std::cout <<sc_time_stamp()<< ": clk pos edge"<<endl;
  if (packet_fifo.nb_read(val)) {
    std::cout << sc_time_stamp() << ": module_b(): Received " << val <<std::endl;
  } else {
    std::cout << sc_time_stamp() << ": module_b(): FIFO empty." << std::endl;
//  next_trigger(200, SC_US);

void example_fifo::module_a(void) {
  int val = 1000;
  for (;;) {
    std::cout << sc_time_stamp() << ": module_a(): Wrote " << val << std::endl;

void example_fifo::module_c(void) {
  int val=2000;
  for (;;) {
    std::cout << sc_time_stamp() << ": module_c(): Wrote " << val << std::endl;

int sc_main(int argc, char* argv[]) {
  sc_clock clk("clk", 12,SC_US);
  example_fifo ex_fifo ("ex_fifo0");
  sc_start(10, SC_MS);
  return 0;

Thank you.
krishna Reddy.
On Sat, Feb 11, 2012 at 11:49 AM, <alan.fitch@xxxxxxxxxx> wrote:
I would connect the three modules with depth 1 fifos, and then use blocking reads and writes at each end. The you don't need the explicit events at all (unless you are deliberately using immediate notification for some reason - fifos will have delta delays)

For examples

 sc_fifo_in<int> fin;
 sc_fifo_out<int> fout;

 SC_CTOR(c) : fin(1), fout(1) {

 void t () {
    int temp;
    for (;;) {
      temp =;
      wait(200, SC_US);

If you like you can parameterize the delay, create a generic module.

Obviously the first module must generate writes autonomously,


P.S. I haven't compiled that code, I hope it is write(!)

Alan Fitch
Senior Consultant

Doulos - Developing Design Know-how
VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel:  + 44 (0)1425 471223                       Email: alan.fitch@xxxxxxxxxx
Fax:  +44 (0)1425 471573              

Doulos Ltd is registered in England and Wales with company no. 3723454
Its registered office is 4 Brackley Close, Bournemouth International Airport,
 Christchurch, BH23 6SE, UK.

This message (and associated files) may contain information that is confidential,
proprietary, privileged, or subject to copyright. It is intended solely for the use
of the individual to whom it is addressed and others authorised to receive it. If
you have received this email in error, please notify the sender and delete all
copies. This message may contain personal views which are not the views of
Doulos, unless specifically stated.

-----<systemc-forum@xxxxxxxxxxxxxxxxxxx> wrote: -----
To: Sumit Adhikari <adhikari@xxxxxxxxxxxxxxxx>
From: Rama krishna Reddy
Sent by:
Date: 11/02/2012 01:44
Cc: "systemc-forum@xxxxxxxxxxxxxxxxxxx" <systemc-forum@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [systemc-forum] Hi need help regarding executing process and methods sequentially rather then concurrently.

Hello sorry for not mentioning test case. Below is the header and classes which i used. Now when i run all methods are executed concurrently, but i need result as method_a,method_b,method_c,method_a,method_b,method_c......continues till simulation time finishes. 
suppose module_a duration is 20 us, module_b duration is 200 us and module_c duration is 40 us and total simulation time is 1 ms.

Thank you.

SC_MODULE (module_a)
    sc_event event_a;
    void thread_a(void);
    void method_a(void);

SC_MODULE (module_b)
    sc_in<bool> clk;
    void method_b(void);

SC_MODULE (module_c)
    sc_event event_c;
    void thread_c(void);
    void method_c(void);

void module_a::method_a(void)
    cout<<"method_a : "<<sc_time_stamp()<<endl;
void module_a::thread_a(void)

void module_b::method_b(void)
    cout<<"method_b : "<<sc_time_stamp()<<endl;

void module_c::method_c(void)
    cout<<"method_c : "<<sc_time_stamp()<<endl;
void module_c::thread_c(void)

int sc_main(int argc, char* argv[])
    sc_clock clk("clk",30,SC_US);
    module_a imodule_a("imodule_a");
    module_b imodule_b("imodule_b");
    module_c imodule_c("imodule_c");
    return 0;

 On Thu, Feb 9, 2012 at 11:33 PM, Sumit Adhikari <adhikari@xxxxxxxxxxxxxxxx> wrote:
 Rama :

 Reporting a problem without a test case will not help.

 Can you please send us a minimal test case of your issue ?


 Sumit Adhikari,
 Institute of Computer Technology,
 Vienna University of Technology,
 Gußhausstraße 27-29,1040 Vienna
 From: systemc-forum@xxxxxxxxxxxxxxxxxxx [systemc-forum@xxxxxxxxxxxxxxxxxxx] on behalf of Rama krishna Reddy [krisreddi46@xxxxxxxxx]
 Sent: Thursday, February 09, 2012 11:06 PM
 To: systemc-forum@xxxxxxxxxxxxxxxxxxx
 Subject: [systemc-forum] Hi need help regarding executing process and methods sequentially rather then concurrently.

 Hello Friends,

 I am modelling an FSM related to some communication cycle. Each cycle has
 some duration and this cycles are repeated for a particular simulation time.
 Each cycle is divided into 3 parts static, dynamic and idle. The static and idle
 duration is fixed dynamic changes depending on number of slots it has. I
 implemented each of them in separate header files and source respectively; and
 if i start the simulation they are executed in concurrently. But i need to
 execute in sequential way as static,dynamic,idle and this should carry on till
 simulation time finishes.

 Thanks you.


By Date: Previous | Next Current Thread By Thread: Previous | Next