pngen

Capsim Block Documentation

Short Description

This function generates a random sequence of bits, which can be used to exercise a data transmission system.The early, reference, and late signals are generated with the early signal shifted with the positive edge of the input clock.

Top
Input Connections
Port Type Name
0 float clock
Top
Output Connections
Port Type Name
0 float early
1 float reference
2 float late
Top
Parameters
Num Description Type Name Default Value
0 number of samples to delay each way int num_delay 4
1 Length of shift register int shift_length 7
2 Initialization for shift register int initialize 12
3 Array of polynomial (0 or 1) array poly
Top
States
Num Type Name Initial Value Description
0 int shift_reg
1 int no_inbuf
2 int no_outbuf
3 float fbit_early[100]
4 float fbit_temp[100]
Top

Declarations


 

	int i,j,k;
	int samples;
	int temp_val;
	int kp;



Top

Initialization Code



 

	if((no_outbuf = NO_OUTPUT_BUFFERS() ) <= 0) {
		fprintf(stderr,"pngen: no output buffers\n");
		return(1); /* no output buffers */
	}
	shift_reg = initialize;
	for(i=0; i<101; i++)
	{
		fbit_early[i] = 0.0;
	}




Top

Main Code



 


	for(samples = MIN_AVAIL(); samples > 0; --samples) {

		temp_val = 0;
		IT_IN(0);
		for(i=0; i<2*num_delay; i++)
		{
			fbit_temp[i] = fbit_early[i];
		}

		if(clock(1) == 0.0 && clock(0) == 1.0) {

			for(i=0; i> i) & kp);
			}
			shift_reg = (temp_val % 2) + (shift_reg << 1);
			
			for(j=1; j<2*num_delay; j++)
			{
				fbit_early[j] = fbit_temp[j-1];
			}
			fbit_early[0] = (float) ((shift_reg >> shift_length) & 1);
		}
		else
		{
			for(k=1; k<2*num_delay; k++)
			{
				fbit_early[k] = fbit_temp[k-1];
			}
			fbit_early[0] = fbit_temp[0]; 
		}
		if(IT_OUT(0)) {
			KrnOverflow("pngen",0);
			return(99);
		}
		early(0) = fbit_early[0];
		if(IT_OUT(1)) {
			KrnOverflow("pngen",1);
			return(99);
		}
		reference(0) = fbit_early[num_delay - 1];
		if(IT_OUT(2)) {
			KrnOverflow("pngen",2);
			return(99);
		}
		late(0) = fbit_early[2*num_delay-1];
	}
	return(0);




Top

Wrapup Code



 





Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/* pngen.s */
/**********************************************************************
                pngen()
***********************************************************************
This function generates a random sequence of bits, which can be used
to exercise a data transmission system.
The early, reference, and late signals are generated with the early
signal shifted with the positive edge of the input clock.
Any degree polynomial can be implemented
as specified in a parameter array.
Input parameters:
	num_delay: Number of samples to delay each way
	shift_length: Length of shift register
	poly[]: Generation polynomial in array
	shift_reg: Initial shift reg for pseudo random sequence

pngen


This function generates a random sequence of bits, which can be used
to exercise a data transmission system.
The early, reference, and late signals are generated with the early
signal shifted with the positive edge of the input clock.
Any degree polynomial can be implemented
as specified in a parameter array.
Input parameters:
	num_delay: Number of samples to delay each way
	shift_length: Length of shift register
	poly[]: Generation polynomial in array
	shift_reg: Initial shift reg for pseudo random sequence


	
*/