[SI-LIST] Creaging Pseudo Random Bit Sequence (PRBS) stimuli for Hspice

Occassionally someone will inquire about ways to create Pseudo Random Bit 
Sequence (PRBS) stimuli to drive their simulations.  The discussion below 
details *one* way to accomplish this task using Waveformer Pro from 
SynaptiCAD (www.syncad.com).  The output from this procedure is one or
more piecewise linear (PWL) independent voltage sources that can
subsequently be used to stimulate your circuit simulations.

*** This is not an endorsement of any product, company nor  ***
*** process, but simply a sharing of one user's findings.   ***

Step 1.  Add the PRBS functions to Waveformer Pro by copying the code 
segment below into your ..\SynaptiCAD\perl\Autostat.pl file.  You might 
want to save the original under another name beforehand just in case 
your typing is as erratic as mine.  I suggest you copy/paste the new 
code at the bottom of the file.  This code appeared to work with the
current release of Waveformer Pro for WIN2000 (version 8.9b) and 
HPUX11 (version 8.3g).  Caveate emptor:  I make no guarantees.  
See "Create Your Own Label Equation Functions" at 
http://www2.syncad.com/syn_eqn.htm for additional details.


#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# start of code segment
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#-------------------------------------------------------------------------
# dec2bin subroutine  
#-------------------------------------------------------------------------

sub dec2bin
{
 ($_[0] < 0) && ($_[0] *= -1);
 my @bin;
 while ($_[0]>0)
 {
  push(@bin, ($_[0] % 2));
  $_[0] = int($_[0] *= 0.5);
 }
 return(@bin);
}

#-------------------------------------------------------------------------
# PRBS7(length,seed): Generates a PRBS 2^7-1 data stream  
#       length>0: number of bits to generate
#       seed==0:  generates PRBS from a random starting value
#       seed>0:   generates a repeatable PRBS from the given seed value
#-------------------------------------------------------------------------

#2^7-1 pseudo random sequence
#REQUIRES the dec2bin() subroutine listed above

sub PRBS7
{
 my ($len, $seed) = @_;                                 #Get passed params
 ($seed == 0) && ($seed = int(rand(126)+.5));   #If seed == 0, get a random
int between 1-126
 ($seed >127) && ($seed = 127);                 #If seed == 0, get a random
int between 1-126
 my @q;
 my @d = &dec2bin($seed);                               #Get the binary
representation of the seed
 #print("binary state = @d\n");
 while($#d < 6)
 {
  push(@d,0);                                           #Pad with 0s
 }
 #print("binary state = @d\n");
 while ($len--)
 {
  push(@d, $d[1] ^ $d[0]);                              #^ is the bitwise
xor operator
 #print("binary state = @d\n");
  push(@q, shift(@d));
 }
 return(@q);
}

#-------------------------------------------------------------------------
# PRBS15(length,seed): Generates a PRBS 2^15-1 data stream  
#       Written by Steve Currie
#       length>0: number of bits to generate
#       seed==0:  generates PRBS from a random starting value
#       seed>0:   generates a repeatable PRBS from the given seed value
#-------------------------------------------------------------------------


#2^15-1 pseudo random sequence
#REQUIRES the dec2bin() subroutine listed above

sub PRBS15
{
 my ($len, $seed) = @_;                                 #Get passed params
 ($seed == 0) && ($seed = int(rand(32767)+.5)); #If seed == 0, get a random
int between 1-32767
 ($seed >32767) && ($seed = 32767);                     #If seed == 0, get a
random int between 1-32767
 my @q;
 my @d = &dec2bin($seed);                               #Get the binary
representation of the seed
 #print("binary state = @d\n");
 while($#d < 14)
 {
  push(@d,0);                                           #Pad with 0s
 }
 #print("binary state = @d\n");
 while ($len--)
 {
  push(@d, $d[14] ^ $d[0]);                             #^ is the bitwise
xor operator
 #print("binary state = @d\n");
  push(@q, shift(@d));
 }
 return(@q);
}

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# end of code segment
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Step 2.  Use the extended tool to generate your stimuli:

PROCEDURE TO GENERATE PSEUDO RANDOM BIT SEQUENCE [PRBS] STIMULI 
FOR USE IN HSPICE SIMULATIONS USING SYNAPTICAD WAVEFORMER-PRO

2.1   On the Waveformer Pro toolbar click ADD SIGNAL.  See that a 
      new waveform (eg "SIG0") is added to the display.

2.2   Double click on the name of the new signal and see that the 
      Signal Properties dialog box appears.  Rename the signal to 
      match the corresponding node name in your Hspice deck.

2.3   Click the "Analog Props" button and review or edit the rise 
      and fall times along with the voltage values corresponding 
      to logic "1" and logic "0" as desired.

2.4   Enter the timing information for your desired PRBS signal in
      the input box on the right side of the "Wfm Eqn" button.  
      (For example, if you wanted 60 bits at 1nS each then you 
      would enter "(1.0 = V) * 60". See the online help for 
      additional details.)
                    
2.5   Click the Wfm Eqn button to generate the timing envelope.

2.6   Enter the value information for your desired PRBS signal in
      the input box on the right side of the "Label Eqn" button.  
      (For example, if you wanted a PRBS 2^7-1 pattern 60 bits long 
      seeded with the value of 85 (=01010101b) then you enter 
      "PRBS7(60,85)".  This seed gives you a fast pattern at the 
      start of the sim so you can see that things are working right 
      before starting that overnight run.  See PRBS FUNCTION CALL 
      SYNTAX below for additional details.)
                       
2.7   Click the Label Eqn button to generate the values.

2.8   Repeat steps 2.1 thru 2.7 for any additional PRBS signals you 
      desire.

2.9   Once all your stimuli are represented, on the Waveformer Pro 
      toolbar click "EXPORT>Export Timing Diagram As" and see that 
      the Save As dialog box appears.  From the "Save As Type" 
      pulldown list select "Hspice sources (*.cir)s"  Enter the 
      desired filename and click "Save".
 
2.10  Be sure to add an .INCLUDE statement to your Hspice deck 
      to access the stimuli you have generated.


PRBS FUNCTION CALL SYNTAX

Note: In the discussion below, the "+" means "modulo-2 sum" which is 
equivalent to a bitwise exclusive-or gate.

The PRBS functions listed above currently support two formats:

PRBS7(length,seed) generates the 2^7-1 pattern using the x7 + x1 + 1 
polynomial where:
*  "length" is an integer >0 which specifies the number of bits to be 
   generated.
*  "seed" is an integer (0 thru 127) which initializes the bit sequence 
   in the shift register.  Seed values of 1 thru 127 initialize the 
   shift register to the binary equivalent of that value while a seed 
   value of zero causes the function to generate a random number to 
   initialize the bit sequence.

PRBS15(length,seed) generates the 2^15-1 pattern using the x15 + x1 + 1 
polynomial where: 
*  "length" is an integer >0 which specifies the number of bits to be 
   generated.
*  "seed" is an integer (0 thru 32767) which initializes the bit 
   sequence in the shift register.  Seed values of 1 thru 32767 
   initialize the shift register to the binary equivalent of that 
   value while the seed value of zero causes the function to generate 
   a random number to initialize the bit sequence.

Additional information regarding PRBS's may be found in 
"Pseudo-Random Sequences and Arrays", Proceedings of the IEEE,
Vol 64, No. 12, pp. 1715-1718, 1976 by Sloane and MacWilliams.

This proceedure seems to work but I make no claims that it is the best
way to generate PRBS stimuli.  Others may have their own tips to share
or suggestions to add.

Humbly submitted,
jf

------------------------------------------------------------------------
"A home without a cat, and a well-fed, well-petted and properly revered
cat, may be the perfect home, perhaps, but how can it prove its title?"  
-Mark Twain

Jonathan Fasig                      Email:  fasig.jonathan@xxxxxxxx     
Mayo Foundation 
4001 41st Street NW 
MSC Sn 2-132                        Phone:  (507) 538-5464
Rochester, MN 55901                 Fax:    (507) 284-9171

------------------------------------------------------------------
To unsubscribe from si-list:
si-list-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field

or to administer your membership from a web page, go to:
http://www.freelists.org/webpage/si-list

For help:
si-list-request@xxxxxxxxxxxxx with 'help' in the Subject field

List archives are viewable at:     
                http://www.freelists.org/archives/si-list
or at our remote archives:
                http://groups.yahoo.com/group/si-list/messages 
Old (prior to June 6, 2001) list archives are viewable at:
                http://www.qsl.net/wb6tpu
  

Other related posts: