Jump to content

kihtrak

Members
  • Posts

    20
  • Joined

  • Last visited

Posts posted by kihtrak

  1. Thanks Alan. Changing to SC_METHOD() solved the issue.

    The output seems to be:

     

    At time 0s: i/p:0000 o/p :0000

    At time 5ns: i/p: 0001 o/p: 0000

    At time 5ns: i/p: 0001 o/p:0001

    At time 110ns: i/p: 0000 o/p:0001

    At time 110ns: i/p: 0000 o/p:0000

    At time 115ns: i/p: 0001 o/p:0000

    At time 115ns: i/p: 0001 o/p:0001

     

    1.At time 5ns, the first output is 0 , and the next displayed output is 1. Is this what they call the delta delay which occurs when writing to a port?

    2.Also, after 5ns, why does it jump to 110ns instead of 105ns? 

     

    Please help me in finding answers for these .

    Thanks Gerth and Roman :)

  2. Hello all , 

    This is my complete code:

     

    #include"systemc.h"
     
    SC_MODULE(gtb) {
     
     
     
    sc_in<sc_uint<3> >  bin;
    sc_out<sc_uint<3> > grayout; 
     
    void proc_graytobinary(); 
     
    SC_CTOR(gtb)
    {
    SC_THREAD(proc_graytobinary); 
    sensitive<<bin; 
    }
    };
     
    Gtb.cpp
     
    include"gtb.h"
     
    void gtb::proc_graytobinary() {
     
     
     
    switch(bin.read())
    {
     
    case 0: grayout = 0; break;
    case 1: grayout = 1; break; 
    default: grayout = 3; break; 
    }
     
    Driver.cpp
     
    #include "driver.h"
     
    void driver::proc_driver() 
    {
     
     
    while(1)
    {
     
    d_bin = 0;
    wait(5, SC_NS); 
     
     
    d_bin = 1; 
    wait(5, SC_NS);
     
     
    wait(100, SC_NS); 
     
    }
    }
     
    Gtbmain.cpp
    // File : decodermain.cpp
     
    #include"gtb.h"
    #include"driver.h"
    #include"monitor.h"
     
    int sc_main(int argc, char* argv[]) 
    {
    sc_signal <sc_uint<3> > t_bin; 
    sc_signal <sc_uint<3> > t_grayout; 
     
     
    sc_trace_file *tfile = sc_create_vcd_trace_file("graytobinary");
    tfile->set_time_unit(1, SC_NS);
     
     
    gtb d1("GraytoBinary"); 
    d1 << t_bin << t_grayout; 
     
    driver dr("GenerateWaveforms"); 
    dr << t_bin ; 
     
    monitor mon("MonitorWaveforms"); 
    mon << t_bin << t_grayout; 
     
    sc_trace(tfile, t_bin,  "t_bin"); 
    sc_trace(tfile, t_grayout, "t_grayout"); 
     
     
     
     
    sc_start(150, SC_NS); 
    //sc_stop(); 
    sc_close_vcd_trace_file(tfile);
    return(0); 
    }
     
     
    Please help me solve this issue. 
     
    Thanks :)
     
     
     
  3. Hey Roman, 

    I tried assigning "1" to bin, as well some other value which is not listed in the case statement. I did this to check whether "default" as well as the other case statements are executed. But, all it does is just prints "0" for any input value, i.e only the first case statement is executed. I tried changing the value in the first case statement, but still only that value is printed and rest all case statements are ignored. 

     

    Please help me solve this issue

  4. Hello there, 

    Am trying to implement binary to gray converter using simple case statements. When I try to execute, only the first statement of the switch case is being executed. 

     

    Here's my gtb.cpp and driver module

     

    // driver.cpp
     
    #include "driver.h"
     
    void driver::proc_driver() 
    {
     
     
     
     
    while(1)
    {
     
    d_bin = 0;
    wait(5, SC_NS); 
     
     
    d_bin = 4;
    wait(5, SC_NS);
     
     
     
     
     
    }
    }
     
    #include"gtb.h"
     
    void gtb::proc_graytobinary() {
     
     
     
     
    switch(bin.read())
    {
    case 0 : grayout = 0; break; 
    case 1 : grayout = 1; break;
    default: grayout = 2; break;
     
     
     
    }
     
     
    }
     
    Please help me solve this issue. 
     
    Thanks in advance :)
     
     
  5. Hello there, 

    The simulation for my module stops at 55 ns. This might probably happen because of my driver. In GTKwave , am not able to view what is the input and output at 55(th) ns, since the simulation stops exactly stops at 55. 

    How to keep the simulation time to be infinite or extend more so that I can also view the last set of inputs? 

    I also tried deactivating the "sc_stop()" command, but no change was found. If so, what's the need of sc_stop() ?

     

    Any help would be appreciated. :)

     

    Thanks in advance.

  6. Hello Gerth. 

     

    Since am a beginner to SystemC, am facing some difficulty in understanding what really the issue is. Can you please explain in detail?

     

     

    //File: decoder_top.cpp
     
    #include "driver.h"
    #include "monitor.h"
    #include "2_by_4_decoder.h"
     
     
    int sc_main(int argc, char* argv[])
    {
    sc_signal<bool>  t_enable; 
    sc_signal<sc_uint<2> > t_select; 
    sc_signal<sc_uint<4> > t_z; 
     
     
     
     
    sc_trace_file *wf = sc_create_vcd_trace_file("decoder"); 
    wf->set_time_unit(1, SC_NS); 
     
     
    decoder2by4 dcdr("2by4decodr"); 
    dcdr.enable(t_enable);
    dcdr.select(t_select); 
    dcdr.z(t_z); 
     
     
    driver dr("Waveform"); 
    dr.d_enable(t_enable); 
    dr.d_select(t_select); 
     
    monitor mo1 ("MonitorWaveforms"); 
    mo1.m_select(t_select); 
    mo1.m_enable(t_enable);
    mo1.m_z(t_z); 
     
    sc_trace(wf, t_select, "t_select"); 
    sc_trace(wf, t_enable, "t_enable"); 
    sc_trace(wf, t_z, "t_z"); 
     
    sc_start(100, SC_NS);
     
    //if(not sc_end_of_simulation_invoked()) {
    //cout<< "ERROR: Simulation stopped "; 
    sc_stop(); 
    //}
     
     
    sc_close_vcd_trace_file(wf);
     
     
    return(0); 
    }
     
     
    Result:
     

     

    Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
    At time0 s:: (select, enable) 00output is 0
     
    Info: /OSCI/SystemC: Simulation stopped by user.
     
     
    Thanks in advance. 
  7. Hello there, 

    While trying to run the executable, I get the following message:

     
    Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
    At time0 s:: (select, enable) 00output is 0
     
    Info: /OSCI/SystemC: Simulation stopped by user.
     
    Please suggest me on how to solve this issue. 
     
    Thanks in advance. 
  8. Hello Alan, 

    As told by Stephen, he could run the code successfully! But, am not able to understand why it doesn't run for me. 

     

    I even tried deleting all the object files, moved the source codes to a new directory and compiled again. But, still am getting the same error. What possibly would be the issue, can you please help me solve this?

     

    Thanks in advance. 

  9. Hello Alan, 

     

    The "driver" module has just two ports. 

     

    //File:driver.h
     
    #include "systemc.h"
     
    SC_MODULE (driver)
    {
    sc_out<bool> d_enable ;
    sc_out<sc_uint<2> > d_select; 
      
     
     
    sc_uint<2> pattern;
     
    void prc_driver(); 
     
    SC_CTOR(driver)
    {
    SC_THREAD(prc_driver); 
     
    }
    };
     
     
    Still I don't know why the error has popped up this way!
     
    Please help me solve this issue. 
     
    Thanks in advance. 
  10. Hello there, 

     

    Am facing the same issue. 

     

    Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
     
    Error: (E109) complete binding failed: port not bound: port 'Waveform.port_2' (sc_out)
    In file: ../../../../src/sysc/communication/sc_port.cpp:231
     
    What does this mean?
     
    I have bounded both ports of the driver(concerned) module to the top module (no port is left unbounded ). Is there something else that I need to change?
  11. Hello Gerth, 

    Am sorry for bugging you a lot! 

    Am still getting the same error, if I just change the type d_select port in the driver module from sc_lv to sc_uint. 

     

    I've also attached the Makefile. Please help me sort this out. 

     

     
    SYSTEMC=/usr/local/systemc231
    ARCH=linux64
     
    CPP_FLAGS= -I. -I$(SYSTEMC)/include
    LDFLAGS=-L$(SYSTEMC)/lib-linux64 -lsystemc
     
    SRC= decoder2by4.cpp decoder_top.cpp  monitor.cpp driver.cpp
    OBJS= decoder2by4.o decoder_top.o  driver.o monitor.o
     
     
    all: 2by4decoder
     
    decoder_top.o:  decoder_top.cpp
    g++ $(CPP_FLAGS) -c decoder_top.cpp 
     
    decoder2by4.o:  decoder2by4.cpp
    g++ $(CPP_FLAGS) -c decoder2by4.cpp 
     
    driver.o:  driver.cpp
    g++ $(CPP_FLAGS) -c driver.cpp 
     
    monitor.o:  monitor.cpp
    g++ $(CPP_FLAGS) -c monitor.cpp 
     
     
    2by4decoder: $(OBJS)  
    g++ $(LDFLAGS) -o 2by4decoder $(OBJS)
     
     
    The commands I entered (in the terminal): 
    1. make
    2. ./2by4decoder  (to run the executable )
     
    Thanks a lot for your patience! 
  12. Hello Gerth, 

     

    I get the idea behind defining the argument for instances. Thanks!

     

    Let me post the complete code of mine:

     

    //File : 2-by-4 decoder.h
     
     
    #include "systemc.h"
     
    SC_MODULE(decoder2by4)
     
    {
     
    sc_in<bool>enable; 
    sc_in<sc_uint<2> > select; 
    sc_out<sc_lv<4> > z; 
     
    void prc_decoder2by4(); 
     
    SC_CTOR(decoder2by4)
    {
    SC_METHOD(prc_decoder2by4); 
    sensitive<<enable<<select; 
    }
    }; 
     
    //File: decoder2by4.cpp
     
    #include"2_by_4_decoder.h"
     
    void decoder2by4::prc_decoder2by4()
    {
    if(enable)
    {
    switch(select.read())
    {
    case 0: z = 0001;  break;
    case 1: z= 0010; break; 
    case 2: z= 0100; break;
    case 3: z= 1000; break; 
    }
    }
    else
    z = 1111; 
    }
     
     
    //File: decoder_top.cpp
     
    #include "driver.h"
    #include "monitor.h"
    #include "2_by_4_decoder.h"
     
     
    int sc_main(int argc, char* argv[])
    {
    sc_signal<bool>  t_enable; 
    sc_signal<sc_uint<2> > t_select; 
    sc_signal<sc_lv<4> > t_z; 
     
    sc_trace_file *wf = sc_create_vcd_trace_file("decoder"); 
    wf->set_time_unit(1, SC_NS); 
     
     
    decoder2by4 dcdr("2by4decodr"); 
    dcdr.enable(t_enable);
    dcdr.select(t_select); 
    dcdr.z(t_z); 
     
     
    driver dr("GenerateWaveform"); 
    dr.d_select(t_select); 
    dr.d_enable(t_enable); 
     
     
    monitor mo1 ("MonitorWaveforms"); 
    mo1.m_select(t_select); 
    mo1.m_enable(t_enable);
    mo1.m_z(t_z); 
     
    sc_trace(wf, t_select, "t_select"); 
    sc_trace(wf, t_enable, "t_enable"); 
    sc_trace(wf, t_z, "t_z"); 
     
     
    sc_start(100, SC_NS); 
     
    sc_stop(); 
     
    sc_close_vcd_trace_file(wf);
     
     
    return(0); 
    }
     
     
    //File: driver.cpp
     
     
    #include "driver.h"
     
    void driver::prc_driver()
    {
    sc_uint<2> pattern; 
    pattern = 0; 
     
    bool temp_enable; 
     
    temp_enable = 0;  
     
    while(1)
    {
     
    temp_enable!= temp_enable; 
     
    wait(); 
     
    d_enable.write(temp_enable); 
     
    while (temp_enable)
    {
    d_select.write(pattern); 
    d_enable.write(temp_enable);
    //d_cin = pattern[2]; 
    wait (5, SC_NS); 
    pattern++; 
     
     
     
    temp_enable!= temp_enable; 
     
    }
     
    }
    }
     
    //File:driver.h
     
    #include "systemc.h"
     
    SC_MODULE (driver)
    {
    sc_out<bool> d_enable ;
    sc_out<sc_lv<2> > d_select; 
    //sc_out<sc_uint<4> > d_z;  
     
     
    sc_uint<2> pattern;
     
    void prc_driver(); 
     
    SC_CTOR(driver)
    {
    SC_THREAD (prc_driver) ;
    sensitive<< d_enable<< d_select;
    }
    };
     
     
    //File : monitor.cpp
     
     #include "monitor.h"
     
    void monitor::prc_monitor()
    {
    cout<<"At time"<<sc_time_stamp()<<"::";
    cout<<" (select, enable) "; 
    cout<<m_select<<m_enable; 
    cout<<"output is "<<m_z<<endl; 
    }
     
     
    /File: monitor.h
     
    #include"systemc.h"
     
    SC_MODULE (monitor)
    {
    sc_in<bool> m_enable;
    sc_in<sc_uint<2> > m_select;
    sc_in<sc_lv<4> > m_z;   
     
    void prc_monitor (); 
     
     
    SC_CTOR(monitor)
    {
    SC_METHOD (prc_monitor); 
    sensitive << m_enable << m_select<<m_z;  
    }
    }; 
     

     

    Please help me correct the errors. 

    Thanks in advance.

  13. Hi Gerth, 

     

    I've made changes as told by you. One more error pops up like this . while trying to run the executable.

     

    Info: (I703) tracing timescale unit set: 1 ns (decoder.vcd)
     
    Error: (E109) complete binding failed: port not bound: port 'GenerateWaveform.port_2' (sc_out)
    In file: ../../../../src/sysc/communication/sc_port.cpp:231
     
    I've already posted the top module, let me post the rest:
     
    /File:driver.h
     
    #include "systemc.h"
     
    SC_MODULE (driver)
    {
    sc_out<bool> d_enable ;
    sc_out<sc_uint<2> > d_select; 
    //sc_out<sc_uint<4> > d_z;  
     
     
    sc_uint<2> pattern;
     
    void prc_driver(); 
     
    SC_CTOR(driver)
    {
    SC_THREAD (prc_driver) ;
    sensitive<< d_enable<< d_select;
    }
    };
     
     
     
    //File: driver.cpp
     
    #include "driver.h"
     
    void driver::prc_driver()
    {
    sc_uint<2> pattern; 
    pattern = 0; 
     
    bool temp_enable; 
     
    temp_enable = 0;  
     
    while(1)
    {
     
    temp_enable!= temp_enable; 
     
    wait(); 
     
    d_enable.write(temp_enable); 
     
    while (temp_enable)
    {
    d_select.write(pattern); 
    d_enable.write(temp_enable);
    //d_cin = pattern[2]; 
    wait (5, SC_NS); 
    pattern++; 
     
     
     
    temp_enable!= temp_enable; 
     
    }
     
    }
    }
     
     
    //File : 2-by-4 decoder.h
     
     
    #include "systemc.h"
     
    SC_MODULE(decoder2by4)
     
    {
     
    sc_in<bool>enable; 
    sc_in<sc_uint<2> > select; 
    sc_out<sc_uint<4> > z; 
     
    void prc_decoder2by4(); 
     
    SC_CTOR(decoder2by4)
    {
    SC_METHOD(prc_decoder2by4); 
    sensitive<<enable<<select; 
    }
    }; 
     
     
    //File: monitor.h
     
    #include"systemc.h"
     
    SC_MODULE (monitor)
    {
    sc_in<bool> m_enable;
    sc_in<sc_uint<2> > m_select;
    sc_in<sc_uint<4> > m_z;   
     
    void prc_monitor (); 
     
     
    SC_CTOR(monitor)
    {
    SC_METHOD (prc_monitor); 
    sensitive << m_enable << m_select<<m_z;  
    }
    }; 
     
    Please help me solve this issue!
    Thanks in advance
     
    [Also I've another question: In the top module, do I have to include any "arguments" like - driver d1 ("GenerateWaveforms"); ? If I don't it gives some errors. Please help me understand why is that so.]
  14. Hello there,

    I've been trying to create a vcd file which helps me study the waveform of a 2 by 4 decoder. But, when I try to open the file "decoder.vcd" , it tells me that there is no such file or directory [ on Ubuntu 14.0.4  ].

     

    //File: decoder_top.cpp

    #include "driver.h"                                 //module that drives DUT
    #include "monitor.h"                              //module that monitors DUT
    #include "2_by_4_decoder.h"               //module that contains the info of the ports of DUT

    int sc_main(int argc, char* argv[])
    {
    sc_signal<bool> t_select, t_enable, t_z;

    sc_trace_file *wf = sc_create_vcd_trace_file("decoder");
    wf->set_time_unit(1, SC_NS);


    decoder2by4 dcdr("2by4decoder");
    dcdr<<t_enable <<t_select <<t_z;

    driver d1("GenerateWaveforms");

    d1.d_select(t_select);
    d1.d_enable(t_enable);
    //d1.d_cin(t_cin);

    monitor mo1 ("MonitorWaveforms");
    mo1<< t_select << t_enable << t_z;

    sc_trace(wf, t_select, "t_select");
    sc_trace(wf, t_enable, "t_enable");
    sc_trace(wf, t_z, "t_z");


    sc_start(100, SC_NS);

    sc_stop();

    sc_close_vcd_trace_file(wf);


    return(0);
    }


    Please help me solve this issue.

    Thanks in advance!

×
×
  • Create New...