Jump to content

re1418ma

Members
  • Content Count

    11
  • Joined

  • Last visited

Posts posted by re1418ma


  1.  #include "systemc.h"

    #include "systemc-ams.h"

    SC_MODULE (lpf)
    {
        sca_eln::sca_terminal a;
        sca_eln::sca_terminal b;

        sca_eln::sca_r r1;
        sca_eln::sca_c c1;

        SC_CTOR(lpf)
            :a("a"),b("b"),r1("r1",10e3),c1("c1",100e-6),gnd("gnd")
        {
            r1.p(a);
            r1.n(b);

            c1.p(b);
            c1.n(gnd);

        }
    private:
        sca_eln::sca_node_ref gnd;
    };


       hi to all

    i wrote this code for eln low pass filter how should i test it?


  2. you helped a lot sir and for final question i read the post about delay and make some changes

     #include "systemc.h"

    SC_MODULE(and_gate){

     sc_in<bool> a, b;
     sc_out<bool> c;


     void and_gate_p(){
         while(true){
             wait(5,SC_NS);
      c.write(a.read() & b.read());
         }
     }
     SC_CTOR(and_gate){
      SC_THREAD(and_gate_p);
      sensitive << a << b;
     }
    };


    int sc_main(int argc, char* argv[]){
     sc_signal<bool> a, b, c;
     and_gate and1("and_gate_and1");
     and1.a(a);
     and1.b(b);
     and1.c(c);


     sc_trace_file *tf = sc_create_vcd_trace_file("and_gate");

     tf->set_time_unit(1, SC_NS);


     sc_trace(tf, a, "a");
     sc_trace(tf, b, "b");
     sc_trace(tf, c, "c");


     a = 0;
     b = 0;
     sc_start(1.0, SC_NS);

     a = 0;
     b = 1;
     sc_start(1.0, SC_NS);

     a = 1;
     b = 0;
     sc_start(1.0, SC_NS);

     a = 1;
     b = 1;
     sc_start(1.0, SC_NS);

     sc_stop();

     
     sc_close_vcd_trace_file(tf);

     cout << "Finished at time " << sc_time_stamp() << endl;

     return 0;
    }

    is it correct?


  3. thanks for the reply i wrote this code

    #include "systemc.h"

    SC_MODULE(and_gate){

     sc_in<bool> a, b;
     sc_out<bool> c; 


     void and_gate_p(){
      next_trigger(5, SC_NS);
      c.write(a.read() & b.read());
     }
     SC_CTOR(and_gate){
      SC_METHOD(and_gate_p);
      sensitive << a << b;
     }
    };


    int sc_main(int argc, char* argv[]){
     sc_signal<bool> a, b, c;
     and_gate and1("and_gate_and1");
     and1.a(a);
     and1.b(b);
     and1.c(c);


     sc_trace_file *tf = sc_create_vcd_trace_file("and_gate");

     tf->set_time_unit(1, SC_NS);


     sc_trace(tf, a, "a");
     sc_trace(tf, b, "b");
     sc_trace(tf, c, "c");


     a = 0;
     b = 0;
     sc_start(1.0, SC_NS);

     a = 0;
     b = 1;
     sc_start(1.0, SC_NS);

     a = 1;
     b = 0;
     sc_start(1.0, SC_NS);

     a = 1;
     b = 1;
     sc_start(1.0, SC_NS);

     sc_stop();

     
     sc_close_vcd_trace_file(tf);

     cout << "Finished at time " << sc_time_stamp() << endl;

     return 0;
    }

    and still  getting error and i have no idea how to solve the problem

×
×
  • Create New...