scrambler

Capsim Block Documentation

Short Description

The scrambler and descrambler implemented here,which are self-synchronizing, are given in the CCITT recommendation V35.

Top
Input Connections
Port Type Name
0 float bitin
Top
Output Connections
Port Type Name
0 float bitout
Top
Parameters
Num Description Type Name Default Value
0 mode: The operation done on the input sequence is either scrambling,mode = 0,or descrambling,mode = 1. int mode
1 seed: Can be used to force two scramblers out of phase by choosing two values for the seed. int seed 12
Top
States
Num Type Name Initial Value Description
0 long shift_reg seed
Top

Declarations


 

	long output_bit;
	int	no_samples;



Top

Initialization Code



 

		/* error if mode not zero or one */
		if(mode != 0 && mode != 1)
			return(1);




Top

Main Code



 


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

		IT_IN(0);
		/* error if bitin(0) not zero or one */
		if((bitin(0) != (float) 0) && (bitin(0) != (float) 1))
			return(2);

		/* algorithms are slightly different for scrambling
		   and descrambling */
		if(mode == 0) { /* scrambling desired */
			
			/* generate next output bit */
			output_bit = (((shift_reg>>2)&1) +
			 	((shift_reg>>19)&1) + 1 + (long) bitin(0));
			output_bit = output_bit & 1;

			/* generate next shift register state */
			shift_reg = (shift_reg << 1) | output_bit;
			}

		else {  /* descrambling desired */

			/* generate next shift register state */
			shift_reg = (shift_reg<<1)|(long) bitin(0);

			/* generate next output bit */
			output_bit = (((shift_reg >> 3) & 1) + 1 +
		  	  ((shift_reg>>20)&1) + (shift_reg&1))%2;
			}

		if(IT_OUT(0)) {
			KrnOverflow("scrambler",0);
			return(99);
		}
		bitout(0) = (float) (output_bit == 0);
		}

	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



 

/***********************************************************
			scrambler()
************************************************************
This routine expects a sequence of input bits (0.0 or 1.0)
and gives as an output another sequence of bits (also 0.0
or 1.0).
The scrambler and descrambler implemented here,
which are self-synchronizing,
are given in the CCITT recommendation V35.
The input parameters are:
mode: The operation done on the input sequence is either scrambling
	(if mode = 0 ) or descrambling (if mode = 1 ).
seed: Can be used to force two scramblers out of phase
	by choosing two values for the seed

scrambler


This routine expects a sequence of input bits (0.0 or 1.0)
and gives as an output another sequence of bits (also 0.0
or 1.0).
The scrambler and descrambler implemented here,
which are self-synchronizing,
are given in the CCITT recommendation V35.
The input parameters are:
mode: The operation done on the input sequence is either scrambling
	(if mode = 0 ) or descrambling (if mode = 1 ).
seed: Can be used to force two scramblers out of phase
	by choosing two values for the seed


Programmer: O. E. Agazzi / D.G.Messerschmitt
Date: March 31, 1982.
Converted to V2.0 by DGM March 11, 1985

*/