#!/bin/perl #perl vcd_split.pl bench.vcd 1000 2000 open(FPR, $ARGV[0]) || die("open fail $ARGV[0]\n"); $tmp="split_" . $ARGV[1] . "_" . $ARGV[2] . ".vcd"; open(FPW, ">$tmp"); #check input switches $line_i=0; $h_flg=0; $prt=1; while(eof(FPR) != 1) { $line=; chomp($line); $line_i++; if($h_flg == 0) { print FPW ("$line\n"); if($line =~ /.enddefinitions .end/) { $h_flg=1; } } else { if($line =~ /^#(\d*)/) { $n=$1; if($n < $ARGV[1] || $n > $ARGV[2]) { if($prt == 1) {print("stopped at $n range is $ARGV[1]...$ARGV[2]\n");} $prt = 0; if($n > $ARGV[2]) {last;} } else { if($prt == 0) {print("started at $n range is $ARGV[1]...$ARGV[2]\n");} $prt = 1; } } if($prt == 1) {print FPW ("$line\n");}; } }#while close(FPR); close(FPW);