Jump to content
Sign in to follow this  
Jeime_Rhee

SystemC vcd file cannot open GTKwave

Recommended Posts

Hi

I'm learning SystemC language and I made a JK flipflop and 8bit counter using 8-JK flipflop there's no problem building project but if I running GTKwave using vcd trace file it cannot show anything. please help me

 

//test.h

#include "systemc.h"
 
SC_MODULE(test)
{
      sc_in<bool> clock;
      sc_out<bool>  go;
 
      void do_test();
 
      SC_CTOR(test)
      {
             SC_CTHREAD(do_test, clock);
             go.initialize(0);
      }
};
 
//test.cpp
#include "test.h"
 
void test::do_test()
{
      go.write(1);
      while(true)
      {
             wait(1);
      }
}
 
//JK_FlipFlop.h
#include "systemc.h"
 
SC_MODULE(JK_FlipFlop)
{
      sc_in<bool> Input_J; 
      sc_in<bool> Input_K; 
      sc_in<bool> Input_clk;
 
      sc_out<bool> Output_q1;
      sc_out<bool> Output_q2;
 
      void do_jk();
 
      SC_CTOR(JK_FlipFlop)
      {
             SC_METHOD(do_jk);
             sensitive<< Input_clk.neg() << Input_J << Input_K;
             Output_q1.initialize(0);
             Output_q2.initialize(1);
       }
};
 
//JK_FlipFlop.cpp
#include "JK_FlipFlop.h"
 
void JK_FlipFlop::do_jk()
{
       if(Input_J == true && Input_K == false)
       {
                 Output_q1.write(1);
                 Output_q2.write(0);
        }
 
       else if(Input_J == false && Input_K == true)
       {
                 Output_q1.write(0);
                 Output_q2.write(1);
       }
 
       else if(Input_J == true && Input_K == true)
      {
                 Output_q1.write(!Output_q1);
                 Output_q2.write(!Output_q2);
       }
 
      else
      {
                Output_q1.write(Output_q1);
                Output_q2.write(Output_q2);
       }
}
 
//counter.h
#include "JK_FlipFlop.h"
 
SC_MODULE(counter)
{
          sc_in<bool> clk, go;
          sc_out<unsigned char> value;
          sc_signal<bool> connect1; 
          sc_signal<bool> connect2;
          sc_signal<bool> connect3;
          sc_signal<bool> connect4;
          sc_signal<bool> connect5;
          sc_signal<bool> connect6;
          sc_signal<bool> connect7;
          sc_signal<bool> connect8;
          sc_signal<bool> no1, no2, no3, no4, no5, no6, no7, no8;
 
          JK_FlipFlop *FF1;
          JK_FlipFlop *FF2;
          JK_FlipFlop *FF3;
          JK_FlipFlop *FF4;
          JK_FlipFlop *FF5;
          JK_FlipFlop *FF6;
          JK_FlipFlop *FF7;
          JK_FlipFlop *FF8;
 
          void do_count();
          SC_CTOR(counter)
          {
                    FF1 = new JK_FlipFlop("jk1");
                    FF2 = new JK_FlipFlop("jk2");
                    FF3 = new JK_FlipFlop("jk3");
                    FF4 = new JK_FlipFlop("jk4");
                    FF5 = new JK_FlipFlop("jk5");
                    FF6 = new JK_FlipFlop("jk6");
                    FF7 = new JK_FlipFlop("jk7");
                    FF8 = new JK_FlipFlop("jk8");
 
                    FF1->Input_clk(clk); FF1->Input_J(go); FF1->Input_K(go); FF1->Output_q1(connect1); FF1->Output_q2(no1);
                    FF2->Input_clk(connect1); FF2->Input_J(go); FF2->Input_K(go); FF2->Output_q1(connect2); FF2->Output_q2(no2);
                    FF3->Input_clk(connect2); FF3->Input_J(go); FF3->Input_K(go); FF3->Output_q1(connect3); FF3->Output_q2(no3);
                    FF4->Input_clk(connect3); FF4->Input_J(go); FF4->Input_K(go); FF4->Output_q1(connect4); FF4->Output_q2(no4);
                    FF5->Input_clk(connect4); FF5->Input_J(go); FF5->Input_K(go); FF5->Output_q1(connect5); FF5->Output_q2(no5);
                    FF6->Input_clk(connect5); FF6->Input_J(go); FF6->Input_K(go); FF6->Output_q1(connect6); FF6->Output_q2(no6);
                    FF7->Input_clk(connect6); FF7->Input_J(go); FF7->Input_K(go); FF7->Output_q1(connect7); FF7->Output_q2(no7);
                    FF8->Input_clk(connect7); FF8->Input_J(go); FF8->Input_K(go); FF8->Output_q1(connect8); FF8->Output_q2(no8);
 
                    SC_METHOD(do_count);
                    sensitive << clk;
                    sensitive << go;
          }
};
 
//counter.cpp
#include "counter.h"
 
void counter::do_count()
{
          unsigned char local_value = 0;
 
          local_value |= (FF1->Output_q1)<<0;
          local_value |= (FF2->Output_q1)<<1;
          local_value |= (FF3->Output_q1)<<2;
          local_value |= (FF4->Output_q1)<<3;
          local_value |= (FF5->Output_q1)<<4;
          local_value |= (FF6->Output_q1)<<5;
          local_value |= (FF7->Output_q1)<<6;
          local_value |= (FF8->Output_q1)<<7;
 
          value.write(local_value);
}

 

 

//main.cpp

#include "counter.h"
#include "test.h"
 
int sc_main(int argc, char* argv[])
{
 
          sc_signal<unsigned char> Value;
          sc_signal<bool> Go;
 
 
          sc_clock CLK("clock", 50, SC_NS);
 
          counter COUNTER("ccc");
          COUNTER.clk(CLK);
          COUNTER.go(Go);
 
          COUNTER.value(Value);
 
 
          test TST("TST");
          TST.clock(CLK);
          TST.go(Go);
 
          sc_trace_file *tf = sc_create_vcd_trace_file("wave");
 
          sc_trace(tf, COUNTER.connect1, "jk1"); sc_trace(tf, COUNTER.connect2, "jk2"); sc_trace(tf, COUNTER.connect3, "jk3");
          sc_trace(tf, COUNTER.connect4, "jk4"); sc_trace(tf, COUNTER.connect5, "jk5"); sc_trace(tf, COUNTER.connect6, "jk6");
          sc_trace(tf, COUNTER.connect7, "jk7"); sc_trace(tf, COUNTER.connect8, "jk8");
 
          sc_trace(tf, CLK, "clock"); sc_trace(tf, Value, "SystemC value");
 
          sc_start(20000, SC_NS);
          sc_close_vcd_trace_file(tf);
 
          return(0);
}
 
 
 
 
test is making signal always true
 
jk flip-flop working only falling edge so I'm using clk.neg()
 
counter have 8 flip-flop. first flip-flop clock accept main clock and second flip flop accept first flip-flop's q1 value the other flip-flop connected same way to second flip-flop
 
is there any problem??
 
I can't find any problem but I can't see anything in GTKwave
 
please tell me why. I need your help
 
(P.S : Actually I can't speaking English very well. so please understand I'm using wrong grammar or vocabulary. Thanks)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×