ASIC/FPGA Design and Verification Out Source Services
A nice VIM function to fire up vertical differences split
-
This page explains how to add a simple VIM function. The idea is to split the display with
two files taken from a report using one VIM command.
VIM vert diffsplit
-
This is done in a two step procedure. First I run a script to find the differences. An
example
how to recursively operate the script.
-
The first steps ends with a report, that lists the involved files and the differences (piped the output of
linux diff command), which looks like:
FILE ./tbv/specman_wrap.v
----------------
DIR /nfs/iil/proj/ladi/wa47/pkrengel/fpk/fpk-14ww37-1-SN_w001/verif/vunits/intr/
...
To operate simply mark the lines or use line numbers:
:1,3call VertDiff()
-
The function has to be added to your ~/.gvimrc. It is listed below:
"cmp_all gvimdiff auto start
"FILE ./tbv/specman_wrap.v
"----------------
"DIR /nfs/iil/proj/ladi/wa47/pkrengel/fpk/fpk-14ww37-1-SN_w001/verif/vunits/intr/
"==== vim function must start with a captial letter ====
":6,8call VertDiff()
fun! VertDiff() range
let lines = 0
for linenum in range(a:firstline, a:lastline)
if l:lines == 0
let file = substitute(getline(linenum), "FILE \.\/", "", "")
else
if l:lines == 2
let dirA = substitute(getline(linenum), "DIR ", "", "")
execut 'e ' . file
execute 'vert diffsplit ' . dirA . file
endif
endif
let lines += 1
endfor
endfun
The compare perl script:
#!/bin/perl
$tmp="cmp_diff_log.txt";
$fp_bool = open(FPW, ">>$tmp") || die("open fail $tmp\n");
$cmd="cmp " . $ARGV[0] . " " . $ARGV[1] . $ARGV[0];
#$cmd="cmp -s " . $ARGV[0] . " " . $ARGV[1] . $ARGV[0] . "|| echo diff";
#print("$cmd\n");
#check if ignore directory is in the search string
if($ARGV[2] ne "") {
pp=index($ARGV[0], $ARGV[2]);
}
else { $pp=-1; }
if($pp == -1) {
file=$ARGV[1] . $ARGV[0];
if(-e $file) {
dis=`$cmd`;
if(length($dis) > 0) {
cmd="diff -w " . $ARGV[0] . " " . $ARGV[1] . $ARGV[0];
#print("$cmd\n");
dis=`$cmd`;
if(length($dis) > 0) {
print FPW ("FILE $ARGV[0]\n----------------\n");
print FPW ("DIR $ARGV[1]\n----------------\n");
print FPW ("$dis\n----------------\n");
else {
print FPW ("FILE not exist $file\n");
}
}
-
A similar function can be seen at
vert diffsplit on diff -qr output
|