Jump to content
Rahul

systemC vcd trace file cannot open display

Recommended Posts

hi all,

    I am just starting my practical implementations in systemC. Below i have implemented a constant module which produces the constant o/p and it is connected to a counter module.

 

 

constant.h
#define SC_INCLUDE_FX
#include "systemc.h"
#include <stdlib.h>
SC_MODULE(constant){
sc_out<bool> output;

int A;
void process(){    //
while(true)
{
wait(19,SC_MS);   // sample time + delay
A=1;
output.write(A);
cout<< "@"<<sc_time_stamp() << " ::constant output written" << output << endl;
}
}
SC_CTOR(constant)
{
SC_THREAD(process);
}
};
 

 

counter.h
#include <systemc.h>
#include <iostream>
#define SC_INCLUDE_FX
SC_MODULE (counter) {
  sc_in<bool> reset;
  sc_in<bool> enable;
  sc_out<sc_ufixed<12,12, SC_TRN, SC_SAT> > counter_out;

  sc_ufixed<12,12, SC_TRN, SC_SAT> count;

   void incr_count () {
   while(true){
   wait(19, SC_MS);
   if (reset.read() == 1) {
      count =  0;
      counter_out.write(count);
      cout<<"@" << sc_time_stamp()<< "::COUNTER IS RESET " <<  counter_out.read() << endl;
    }
     if (enable.read() == 1) {
      count=count+1;
      counter_out.write(count);
      cout<<"@" << sc_time_stamp() <<" :: Incremented Counter "<<counter_out.read()<<endl;
    }
   }
   }
      SC_CTOR(counter) {
      cout<< " executing counter"<< endl;
      SC_THREAD(incr_count);
      dont_initialize();
      sensitive  <<reset << enable ;
    }
};

 

 

test.cpp
#define SC_INCLUDE_FX
#include "count.h"
#include "constant.h"
#include "systemc.h"
int sc_main (int argc, char* argv[]) {
    sc_buffer<sc_ufixed<8,8, SC_TRN, SC_SAT> > dinsignal;
    sc_buffer<bool> rstsignal;
    sc_buffer<bool> ensignal;
    sc_buffer <sc_ufixed<12,12, SC_TRN, SC_SAT > >outputsignal;

     constant c1("constant");
     c1.output(ensignal);


       counter c2("counter");
        c2.reset(rstsignal);
        c2.enable(ensignal);
        c2.counter_out(outputsignal);


        sc_trace_file *tf = sc_create_vcd_trace_file("VCD test");
         // External Signals
         sc_trace(tf, ensignal, "Enable signal");
         sc_trace(tf, outputsignal, "output signal");


        rstsignal = 1;
        sc_start(1, SC_SEC);
        rstsignal = 0;
        sc_start(1, SC_SEC);
        
        sc_close_vcd_trace_file(tf);


        return 0;
}
 

 

The module's works correctly as i expected.

 

But the problem is with the vcd trace file. The main module produces a vcd file of type .vcd format but when i tried to open it in the gtkwave viewer, the vcd file cannot be opened. There is no error message also for debugging the problem.

 

So I thought of debugging the vcd file in a text editor and found this output

 
date
     Oct 08, 2013       15:38:51
$end

$version
              SystemC 2.3.0-ASI --- Aug 26 2013 11:03:53
$end

$timescale
     1 ps
$end

$scope module SystemC $end
$var wire    1  aaa  Enable signal       $end
$var wire   12  aab  output signal [11:0]  $end
$upscope $end
$enddefinitions  $end

$comment
All initial values are dumped below at time 0 sec = 0 timescale units.
$end


$dumpvars
0aaa
b0 aab
$end


#19000000000
1aaa


#38000000000
b1 aab


....


....


....
 

 

As you can see the comment in the tracefile

 All initial values are dumped below at time 0 sec = 0 timescale units.

So is this the reason the vcd file cannot be opened? if yes, what changes do i need to do in the main module to get worked?

(or) the problem would be related to installation of gtkwave viewer?

 

Please help me how to proceed to the problem solution.

 

Thanks in advance.

 

 

Share this post


Link to post
Share on other sites

Rahul,

after fixing the missing '$' at the beginning of your vcd dump, I got the following error on GTKwave:

GTKWave Analyzer v3.3.49 (w)1999-2013 BSI

Near byte 206, $VAR parse error encountered with 'SystemC.Enable'
Near byte 252, $VAR parse error encountered with 'SystemC.output'
No symbols in VCD file..nothing to do!

 

As you can see, there is an error in your VCD file (at least according to GTKwave): You use spaces in your signal names.
Replace those with '_' or something similar, and your VCD viewer should be happy.

 

hth,
  Philipp

 

 

Share this post


Link to post
Share on other sites

As everyone know, being able to view VCD files inside the verification platforms like Mentor QuestaSim (or ModelSim) or Aldec Riviera needs below commands respectively:

 

vcd2wlf

vcd2asdb

 

Then by simply dragging the generated *.wlf and *.asdb files inside the tools, traced objects can be viewed in the waveform window.

 

I did the above procedures for your VCD file and was able to view them without any error inside both tools. I suggest you also do that instead of trying to use gtkwave.

Share this post


Link to post
Share on other sites

Hi Philipp,

 I am starting the practical implementation of systemc code for 4 bit counter using d flip flop. It works properly as it is, But the problem is with the vcd trace file. The main module produces a vcd file of type .vcd format but when i tried to open it in the gtkwave viewer, the vcd file cannot be opened. There is no error message also for debugging the problem.

My systemc code is given below

dff.cpp

#include <systemc.h>

SC_MODULE (dff) {
    sc_in <bool> clk;
    sc_in <bool> din;
    sc_out <bool> dout,;

    void dff_method()
    {
     	dout=din;
    }
    
    SC_CTOR (dff) {
        SC_METHOD (dff_method);
            sensitive_pos << clk;
    }
}
main.cpp

#include <systemc.h>
#include "dff.cpp"

int sc_main(int argc, char* argv[])
{
sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated",
                                           sc_core::SC_DO_NOTHING );
sc_set_time_resolution(100, SC_PS);
sc_signal<bool> din1, dout1;
sc_signal<bool> din2, dout2;
sc_signal<bool> din3, dout3;
sc_signal<bool> din4, dout4;
sc_signal<bool> en;
sc_signal<bool> clk;

int i;
    
dff dff1("dff");
dff1.din(din1);
dff1.dout(dout1);
dff1.clk(clk);

dff dff2("dff");
dff2.din(din2);
dff2.dout(dout2);
dff2.clk(clk);

dff dff3("dff");
dff3.din(din3);
dff3.dout(dout3);
dff3.clk(clk);

dff dff4("dff");
dff4.din(din4);
dff4.dout(dout4);
dff4.clk(clk);

sc_trace_file *fp;                    // VCD file
fp=sc_create_vcd_trace_file("wave");
sc_trace(fp,clk,"clk");               // signals
sc_trace(fp,din1,"en");
sc_trace(fp,dout1,"dout_one");
sc_trace(fp,dout2,"dout_two");
sc_trace(fp,dout3,"dout_three");
sc_trace(fp,dout4,"dout_four");
en=1;
for(i=0;i<40;i++)
{
din1=en^dout1;
din2=((en&dout1)^dout2);
din3=(((en&dout1)&dout2)^dout3);
din4=((((en&dout1)&dout2)&dout3)^dout4);
clk=0;
sc_start(1, SC_NS);
clk=1;
sc_start(1, SC_NS);
cout<<" @ "<<sc_time_stamp()<<" dout: "<<dout4<<dout3<<dout2<<dout1<<endl;
}   
sc_close_vcd_trace_file(fp);
return 0;
}

and the vcd file is shown below:

$date
     Oct 13, 2014       21:46:55
$end

$version
 SystemC 2.3.1-Accellera --- Oct  8 2014 22:37:31
$end

$timescale
     100 ps
$end

$scope module SystemC $end
$var wire    1  aaaaa  clk       $end
$var wire    1  aaaab  en       $end
$var wire    1  aaaac  dout_one       $end
$var wire    1  aaaad  dout_two       $end
$var wire    1  aaaae  dout_three       $end
$var wire    1  aaaaf  dout_four       $end
$upscope $end
$enddefinitions  $end

$comment
All initial values are dumped below at time 0 sec = 0 timescale units.
$end

$dumpvars
0aaaaa
0aaaab
0aaaac
0aaaad
0aaaae
0aaaaf
$end

#10
1aaaaa

#20
0aaaaa
1aaaab

#30
1aaaaa
1aaaac

#40
0aaaaa
0aaaab

#50
1aaaaa
0aaaac
1aaaad

#60
0aaaaa
1aaaab

#70
1aaaaa
1aaaac

#80
0aaaaa
0aaaab

#90
1aaaaa
0aaaac
0aaaad
1aaaae

#100
0aaaaa
1aaaab

#110
1aaaaa
1aaaac

#120
0aaaaa
0aaaab

#130
1aaaaa
0aaaac
1aaaad

#140
0aaaaa
1aaaab

#150
1aaaaa
1aaaac

#160
0aaaaa
0aaaab

#170
1aaaaa
0aaaac
0aaaad
0aaaae
1aaaaf

#180
0aaaaa
1aaaab

#190
1aaaaa
1aaaac

#200
0aaaaa
0aaaab

#210
1aaaaa
0aaaac
1aaaad

#220
0aaaaa
1aaaab

#230
1aaaaa
1aaaac

#240
0aaaaa
0aaaab

#250
1aaaaa
0aaaac
0aaaad
1aaaae

#260
0aaaaa
1aaaab

#270
1aaaaa
1aaaac

#280
0aaaaa
0aaaab

#290
1aaaaa
0aaaac
1aaaad

#300
0aaaaa
1aaaab

#310
1aaaaa
1aaaac

#320
0aaaaa
0aaaab

#330
1aaaaa
0aaaac
0aaaad
0aaaae
0aaaaf

#340
0aaaaa
1aaaab

#350
1aaaaa
1aaaac

#360
0aaaaa
0aaaab

#370
1aaaaa
0aaaac
1aaaad

#380
0aaaaa
1aaaab

#390
1aaaaa
1aaaac

#400
0aaaaa
0aaaab

#410
1aaaaa
0aaaac
0aaaad
1aaaae

#420
0aaaaa
1aaaab

#430
1aaaaa
1aaaac

#440
0aaaaa
0aaaab

#450
1aaaaa
0aaaac
1aaaad

#460
0aaaaa
1aaaab

#470
1aaaaa
1aaaac

#480
0aaaaa
0aaaab

#490
1aaaaa
0aaaac
0aaaad
0aaaae
1aaaaf

#500
0aaaaa
1aaaab

#510
1aaaaa
1aaaac

#520
0aaaaa
0aaaab

#530
1aaaaa
0aaaac
1aaaad

#540
0aaaaa
1aaaab

#550
1aaaaa
1aaaac

#560
0aaaaa
0aaaab

#570
1aaaaa
0aaaac
0aaaad
1aaaae

#580
0aaaaa
1aaaab

#590
1aaaaa
1aaaac

#600
0aaaaa
0aaaab

#610
1aaaaa
0aaaac
1aaaad

#620
0aaaaa
1aaaab

#630
1aaaaa
1aaaac

#640
0aaaaa
0aaaab

#650
1aaaaa
0aaaac
0aaaad
0aaaae
0aaaaf

#660
0aaaaa
1aaaab

#670
1aaaaa
1aaaac

#680
0aaaaa
0aaaab

#690
1aaaaa
0aaaac
1aaaad

#700
0aaaaa
1aaaab

#710
1aaaaa
1aaaac

#720
0aaaaa
0aaaab

#730
1aaaaa
0aaaac
0aaaad
1aaaae

#740
0aaaaa
1aaaab

#750
1aaaaa
1aaaac

#760
0aaaaa
0aaaab

#770
1aaaaa
0aaaac
1aaaad

#780
0aaaaa
1aaaab

#790
1aaaaa
1aaaac

I think the same problem with rahul as i have.

 

$comment

All initial values are dumped below at time 0 sec = 0 timescale units.
$end
 

You said that "after fixing the missing '$' at the beginning of your vcd dump" to rahul, but I cant get the solution clearly. So, Please help me, what changes I need to do in my code.

  Thanks in advance.

Share this post


Link to post
Share on other sites

Hello I see you problem

 

I knew SystemC not allow space character in string

 

so how about change your strings using _ instead of space

 

 

as your code

 

         sc_trace_file *tf = sc_create_vcd_trace_file("VCD test");
         // External Signals
         sc_trace(tf, ensignal, "Enable signal");
         sc_trace(tf, outputsignal, "output signal");

 

 

change like this

 

         sc_trace_file *tf = sc_create_vcd_trace_file("VCD_test");
         // External Signals
         sc_trace(tf, ensignal, "Enable_signal");
         sc_trace(tf, outputsignal, "output_signal");

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

×