
//
// top.cc : contains sc_main ; Instantiates FIFO design
//

#include "systemc.h"

#include "consumer.h"
#include "producer.h"
#include "fifo.h"

#ifndef BUFFER_H
#include "buffer.h"
#endif


int sc_main(int ac, char *av[] )
{

  // declare channels/signals
  sc_signal<int> full;
  sc_signal<int> empty;

  sc_link_mp<int> ch1; // refinable
  sc_link_mp<int> ch2; // refinable
  
  sc_time dftime(1.0,sc_ps);          //added
  sc_set_default_time_unit(dftime);

  // create clocks with diff frequencies
  sc_clock clock1 ("Clock1", 5, 0.5, 0.3,true);
  sc_clock clock2 ("Clock2", 40, 0.5, 0.1,true);

  // instantiate all blocks and connect to channels, signals
       //producer block
       producer p1("Master");
       p1.Pout(ch1);
       p1.clk(clock1);
              
       //fifo block
       fifo f1("fifo");
       f1.wclk(clock1);
       f1.rclk(clock2);
       f1.Pwrite(ch1);
       f1.Pread(ch2);
              
       //consumer block
       consumer c1("Slave");
       c1.Cin(ch2);
       c1.clk(clock2);

       sc_time stime(2.0,sc_ns);
       sc_start(stime);

  // return zero if no error
       return 0;
}
