Jump to content

ankit

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. 1) I followed following steps to execute and to debug but could not see use of debugger a) g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -o out stack_class.cpp -lsystemc -lm gdb out c) b sc_main d) run ------failed to see step-by-step output 2) if in switch i interchange wait and notify statement it give incorrect output. I wish to know how scheduler is working 3) i have used most of C++ as when i used more of systemC constructs such as ( read, write, sc_in, sc_out ) it leads to numerous error. 4) seek guidance to implement stack code in systemc in whatsoever best possible optimized manner #include "systemc.h" #include "iostream" using namespace std; SC_MODULE (stack_1) { sc_event e1,e2; sc_int<10> ch,num,top,space_left; sc_int<10> a[5]; SC_CTOR(stack_1) { top=0; SC_METHOD(read_1); sensitive<<e1; dont_initialize(); SC_METHOD(write_1); sensitive<<e2; dont_initialize(); SC_THREAD(sync); } void sync() { cout<<"\n***** MY STACK CODE *****"; do { cout<<"\nInput READ(0) or write(1)"; cin>>ch; switch(ch) { case 1: e2.notify(); wait(5,SC_SEC); cout<<"\n@"<<sc_time_stamp(); break;d case 0: e1.notify(); wait(5,SC_SEC); cout<<"\n@"<<sc_time_stamp(); break; default: cout<<"bad choice"; break; } }while(ch==0 || ch==1); } void read_1() { if(top==0) { cout<<"\nStack Underflow--cannot read"; } else { top --; cout<<"\nRead element is:"; cout<<a[top]; } } void write_1() { if(top==5) { cout<<"\nStack Overflow--cannot write"; } else { cout<<"\nenter element to write:"; cin>>num; a[top++]=num; } } }; int sc_main(int argc,char* argv[]) { stack_1 s("s"); sc_start(100,SC_SEC); return (0); }
  2. 1) I will be thankful if i could get some support to resolve error in the attachment as i have tried to implement a pre-defined example. 2) for what time wait() statement is used in method tb_input 3) please guide me a bit about hierarchy ( module instantiation ) syntax part 4) how to view output in waveform #include "systemc.h" SC_MODULE (d_ff) { sc_in<bool> d; sc_in<bool> q; bool clk; SC_CTOR (d_ff) { SC_METHOD(flop); sensitive<<clk.pos(); } void flop() { q.write(d.read()); } }; // hierarchy SC_MODULE (d_ff_4) { sc_in<bool> d; sc_out<bool> q3; sc_signal<bool> q0,q1,q2; bool clk; d_ff d1,d2,d3,d4; SC_CTOR(d_ff_4) : d1("d1"), d2("d2"),d3("d3"),d4("d4") { d1.d(d); d1.clk(clk); d1.q(q0); d2.d(q0); d2.clk(clk); d2.q(q1); d3.d(q1); d3.clk(clk); d3.q(q2); d4.d(q2); d4.clk(clk); d4.q(q3); } }; //test bench SC_MODULE(tb) { sc_out<bool> d; bool clk; void tb_input() { d.write(false); wait(); d.write(true); wait(); sc_stop(); } SC_CTOR(tb) { SC_THREAD(tb_input); sensitive<<clk.pos(); } }; //top int sc_main(int argc, char* argv[]) { sc_clock testclk("testclock", 10, SC_NS,0.5); d_ff d_111("d_111"); d_mast.flop(); d_ff_4 d_112("d_112"); tb t1("t1"); t1.tb_input(); sc_start(); return (0); }
×
×
  • Create New...