[SI-LIST] Re: Creating Pseudo Random Bit Sequence (PRBS) stimulifor Hspic


I while back I wrote some C code to generate PRBS sequences in hspice
PWL format. Here it is if anyone is interested:

Marcus

listing of hrand.c


#include <math.h>
#include <stdio.h>
// written by Marcus van Ierssel (vane@xxxxxxxxxxxxxxxx)
// University of Toronto
main(argc, argv )
    int argc;
    char *argv[];
{
    int n,poly;
    int state,count;
    int bit,xor,new;
    int size,len;
    int period, slew;
    float time;
    char *eh;

    int i;
    if (argc != 13) {
        printf("\nUsage:\n");
        printf("hrand  vname node0 node1 vlow vhigh start period slew size poly 
seed len\n\n");
        printf("This utility produces a hspice pwl voltage source containing 
a\n");
        printf("pseudo random bit sequence using maximum-length shift 
registers\n");
        printf("\nvname - name of source in spice netlist\n");
        printf("node0 - node0 of source in spice netlist\n");
        printf("node1 - node1 of source in spice netlist\n");
        printf("vlow - voltage that represents '0' in the sequence\n");
        printf("       also starts and ends sequence with this bit\n");
        printf("vhigh - voltage that represents '1' in the sequence\n");
        printf("start - start time in ps of the sequence\n");
        printf("period - period of the sequence\n");
        printf("slew - time in ps to change voltage\n");
        printf("size - number of bits of state of the sequence.\n");
        printf("       max. sequence repeats every 2^n - 1 bits\n");
        printf("poly - characteristic poly of the sequence (inoctal).\n");
        printf("seed - starting state of the sequence. Anything but 0\n");
        printf("len - number of random bits in the sequence. \n");
        printf("\nexample: hrand vin1 in1 0 0v 3.3v 150 100 1 12 10123 
1400\n\n");
        exit(1);
    }
    time=atoi(argv[6]);
    period=atoi(argv[7]);
    slew=atoi(argv[8]);
    n=atoi(argv[9]);
    poly=strtol(argv[10],NULL,8);
    state=atoi(argv[11]);
    size=pow(2,n);

    printf("%s %s %s pwl 0ps %s %fps %s\n",
        argv[1], argv[2], argv[3], argv[4], time-slew/2.0, argv[4]);

    for(count=0;count<(atoi(argv[12]));count++) {
        xor=state & (poly >> 1);
        new = 0;
        for(bit=0;bit<n;bit++) {
            new = new ^ ((xor >> bit) & 0x1);
        }
        state=(state<<1) & (size - 1) | new;
        printf("+%fps %s %fps 
%s\n",time+slew/2.0,argv[4+new],time+period-slew/2.0, argv[4+new]);
        time=time+period;
    }
    printf("+%fps %s\n",time+slew/2.0,argv[4]);
}


------------------------------------------------------------------
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: