code::perl::fixing bit blasted instances of modules in verilog

Some EDA tools have the bad habit of mangling the port names. For instance have a look at submodule2 in Snippet 1 below. The instance in top module has the ports converted from x, y to \x(1), \x(0), \y(2), ... etc.

Snippet 1:
module top;
submodule1 x1 (.\a(1) (net1), .\a(0) (net2));
submodule2 x2 (.\x(1) (x2), .\y(0) (x1) ,.\x(0) (1'b1), .\y(1) (\net=+123), .\y(2) (1'bz) ) ;
endmodule

//
module submodule1 (\a(1) ,\a(0) );
input \a(1) ;
input \a(0) ;
endmodule

//
module submodule2 (x , y);
input [1:0] x;
output [2:0] y;
endmodule


The perl script in Snippet 3, will convert the netlist from Snippet 1 to the one in Snippet 2.

But beware, see what happened to submodule1. If your netlist already has mangled ports but matched at both instance and entity levels, then this script will break the netlist. However this is rarely the case, so use it, but at your own risk.

Snippet 2:
module top;
submodule1 x1 ( .a ({net1 ,net2 }));
submodule2 x2 ( .y ({1'bz ,\net=+123 ,x1 }), .x ({x2 ,1'b1 })) ;
endmodule

//
module submodule1 (\a_1_ ,\a_0_ );
input \a_1_ ;
input \a_0_ ;
endmodule

//
module submodule2 (x , y);
input [1:0] x;
output [2:0] y;
endmodule

Snippet 3:
#!/usr/local/bin/perl

($#ARGV == 0 ) || die "Usage:fixBitBlastInstances.pl \nStopped";

open(FILEIN,$ARGV[0]);
open(FILEOUT,'>temp.v');

@lines = ;
close(FILEIN);
$text = "@lines";
$text =~ s/(\\\w+\S*)\((\d+)\)/\1_\2_/g;
@instances = split(/;/,$text);

for ($i= 0;$i != $#instances;$i++)
{ if ($instances[$i] =~ /\.\\\w+_\d+_/ )
{
$inst2proc = $instances[$i];
$inst2print = "";
%$pinlist = ();
while ($inst2proc =~ /\.\\(\w+)_(\d+)_\s+\((\S*?)\)\s*,?/)
{
$inst2print .= $`;
$inst2proc = $';
$pinlist->{$1}->[$2] = "$3";
}
print FILEOUT "$inst2print ";
@temparray = keys(%$pinlist);
$lastpin = pop @temparray;
foreach $pin (keys(%$pinlist)){
print FILEOUT ".$pin ({";
$k=scalar(@{$pinlist->{$pin}});
for($j=$k-1;$j >= 0; $j--) {
print FILEOUT "$pinlist->{$pin}->[$j] ";
if($j)
{print FILEOUT " ,";}
else
{print FILEOUT " })";}
}
if (($inst2proc =~ /\w+/)||($pin ne $lastpin)) {print FILEOUT ", ";}
}
print FILEOUT "$inst2proc;"
}
else
{ print FILEOUT "$instances[$i];"; }
}

print FILEOUT "\nendmodule";
close(FILEOUT);

vim: Search & Replace

The vim search and replace command is of the form:

:range s[ubstitute]/pattern/string/cgiI


The command for each line in the range replaces a match of the pattern with the string.

Where range can be:
number an absolute line number
. the current line
$ the last line in the file
% the whole file. The same as 1,$
't position of mark "t"
/pattern[/] the next line where text "pattern" matches.
?pattern[?] the previous line where text "pattern" matches
\/ the next line where the previously used search pattern matches ("\" "/")
\? the previous line where the previously used search pattern matches
\& the next line where the previously used substitute pattern matches

Please note:
  • You can mark your current position in the text by typing "mt", where "t" can be any letter, and use it as a mark later defining the line address.
  • If no line range is specified the command will operate on the current line only.
And where pattern consists of anchors, metacharacters and quantifiers:
Anchors:
\<>
Word boundary de-limiters
^
Beginning of the line
$
End of the line

Metacharacters:
.
any character except new line
\s
whitespace character
\S
non-whitespace character
\d
digit
\D
non-digit
\x
hex digit
\X
non-hex digit
\o
octal digit
\O
non-octal digit
\h
head of word character (a,b,c...z,A,B,C...Z and _)
\H
non-head of word character
\p
printable character
\P
like \p, but excluding digits
\w
word character
\W
non-word character
\a
alphabetic character
\A
non-alphabetic character
\l
lowercase character
\L
non-lowercase character
\u
uppercase character
\U
non-uppercase character


Quantifiers may be greedy or non-greedy.

Here are the greedy ones: (here n and m are positive integers)
*
matches 0 or more of the preceding characters, ranges or metacharacters .* matches everything including empty line
\+
matches 1 or more of the preceding characters...
\=
matches 0 or 1 more of the preceding characters...
\{n,m}
matches from n to m of the preceding characters...
\{n}
matches exactly n times of the preceding characters...
\{,m}
matches at most m (from 0 to m) of the preceding characters...
\{n,}
matches at least n of of the preceding characters...

and here are the non-greedy quantifiers:

\{-}
matches 0 or more of the preceding atom, as few as possible
\{-n,m}
matches 1 or more of the preceding characters...
\{-n,}
matches at least 1 or more of the preceding characters...
\{-,m}
matches 1 or more of the preceding characters...

Finally the "search and replace command" may be followed by:
c Confirm each substitution
g Replace all occurrences in the line (without g - only first).
i Ignore case for the pattern.
I Don't ignore case for the pattern.


This is just an extract from:
http://larc.ee.nthu.edu.tw/~cthuang/vim/files/vim-regex/vim-regex.htm
For detailed usage visit the link.


About ADCs

The need for an antialiasing filter in an ADC topology is to prevent the aliasing of noise and not the signal. Except when very high frequencies are involved, it is always posssible to sample at greater than the twice of the signal bandwidth and this guarantees no aliasing will take place for the signal. But noise which is present at all frequencies gets aliased, folds back, and overlaps several times in the signal band. Thereby detoriating the SNR. Thus an Antialiasing filter is required. A LPF with cutoff at fs/2 will guarantee no fold-backs occuring for the noise.

- SNR is affected by both the quantisation noise and circuit noise. Quantisation noise is architectural and can not be avoided. The limit of SNR limited due to quantisation is often calculated to be = 6.02N + 1.75 dB ; where N is the ADC resolution( # of bits).

- Over-sampling and Noise Shaping converters are called Sigma-Delta converters. The name derives from a Sigma and Delta modulation scheme often used in communication theory.

- The benefits of over-sampling (sampling at a much greater than Nyquist rate) in an ADC:
o Shifts the complexity of filter design into the digtal logic domain. The anti-alising filter design, to be implemented in the analog domain, is greatly simplified.
o Shaping of quantisation noise becomes possible. Thereby improving the SNR.

- Since over-sampling requires sampling at frequencies much higher than Fs, the application is limited to low/medium speed converters.

ADC Spec drivers

Zero offset

The first code transition should ideally occur at an analog value 1/2 LSB above V REF -. The zero offset error is defined as the error between the ideal first transition point and the actual first transition. This error effectively shifts left or right an ADC transfer function

Gain error

The first code transition should occur at an analog value 1/2 LSB above negative full scale. The last transition should occur at an analog value a 1/2 LSB below the nominal full scale. Gain error is the deviation of the actual difference between first and last code transitions and the ideal difference between first and last code transitions.

Differential nonlinearity
An ideal ADC exhibits code transitions that are exactly 1 LSB apart. DNL is the deviation from this ideal value. A differential nonlinearity error of less than ±1 LSB ensures no missing codes.

Integral nonlinearity
Integral nonlinearity refers to the deviation of each individual code from a line drawn from zero through full scale. The point used as zero occurs 1/2 LSB before the first code transition. The full scale point is defined as level 1/2 LSB beyond the last code transition. The deviation is measured from the center of each particular code to the true straight line between these two points.

Signal-to-noise ratio + total distortion (SNTD)
SNTD is the ratio of the rms value of the measured input signal to the rms sum of all other spectral components below the Nyquist frequency, including harmonics but excluding dc. The value for SNTD is expressed in decibels.

Spurious free dynamic range (SFDR)

SFDR is the difference in dB between the rms amplitude of the input signal and the largest peak spurious signal.

Information required in a new work setup

When changing jobs/work environment(say new site) what information you might need to start functioning efficiently at the new place?

Here's a checklist that you might like your new employer to complete for you:

o Version Control overview
o Load Sharing Facility/Compute Farm overview
o Technical & Logistical Support structure overview
o Flow & Methodology overview
o Library Overview (Cell library, Memory Generators, IP archiving)

mishrav's shared items