Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

A simple perl script, to count the number of data valid pulses in each packet, in a VCD wave file.

  1. I needed today a script, that counts the number of times RX data valid is asserted in VCD wave format.
    The script implements a counter, which is cleared every time that start of packet is rising (0 to 1 edge detect in VCD wave file). Once detected and if the counter is not zero, its value is printed.
    The counter is incremented each time a rising edge is encountered on the valid signal in the VCD wave file.
    Last, but not least, a time variable is updated too, when ever a time statement, in the VCD file is seen. This enables to print the time together with the pulse count information.

  2. In VCD every signal is represented by an alias. This is defined in the first part of the VCD wave file. The second part is for data change values and time. In my case, I have identified, that start of packet is aliased to va and valid to wa.
    The script is invoked from within vim by :

    :% !perl ~/bin/vim_vcd_count.pl


  3. The script is listed below:

    1. #!/bin/perl
    2. $rxdv=0;
    3. $sop=0;
    4. $time=0;
    5. $cnt=0;
    6. #sop va rxdv wa
    7. while (<STDIN>) {
    8.   chomp($_);
    9.   print("$_\n");
    10.   if($_ =~ /^#([0-9]*)/) { $time=$1; }
    11.   else {
    12.     $len=length($_);
    13.     if($len == 3) { #update sop
    14.       $flg=0;
    15.       $ix=index($_, "va");
    16.       if($ix == 1) {$sop_n = substr($_, 0, 1); $flg=1;}
    17.     }
    18.     if($sop == 0 && $sop_n == 1) {
    19.       if($cnt > 0) {print("count rxdv $cnt at $time\n");}
    20.       $cnt=0;
    21.     }
    22.     if($flg == 1) { $sop = $sop_n; }
    23.     if($len == 3) { #update rxdv
    24.       $flg=0;
    25.       $ix=index($_, "wa");
    26.       if($ix == 1) {$rxdv_n = substr($_, 0, 1); $flg=1;}
    27.     }
    28.     if($rxdv == 0 && $rxdv_n == 1) {
    29.       $cnt++;
    30.     }
    31.     if($flg == 1) { $rxdv = $rxdv_n; }
    32.   }
    33. }#while



  4. If your GTKWAVE supports TCL, you may select to extract values using the TCL. For instance this TCL script will print to screen some values of a signal:

    1. set signal sys.cpp_fft_i_chip_Re
    2. set start_time 127370
    3. foreach {time value} [gtkwave::signalChangeList $signal -start_time $start_time -max 100] {
    4.   puts "Sim Time:: $time val: $value"
    5. }


  ...


Home

some memory VHDL models

A simple c-code program to read a memory array from verilog RTL, using VPI.






Search This Site


Feedback This Site




new pages on this site