linecode

Capsim Block Documentation

Short Description

This star inputs 0/1 binary data and outputs various line codes (NRZ,Biphase Manchester,2B1Q,RZ-AMI).

Top
Input Connections
Port Type Name
0 float bindata
Top
Parameters
Num Description Type Name Default Value
0 Code type:0-Binary(NRZ),1-Biphase(Manchester),2-2B1Q,3-RZ-AMI(Alternate mark inversion) int code_type 0
1 Samples per baud int smplbd 8
Top
States
Num Type Name Initial Value Description
0 float* template
1 int even 1
2 int oneState -1
3 int numberOutputBuffers
4 float sample_A[25]
5 int overFlowBuffer_A[25]
6 int overFlowIndex
7 float overFlowCodeValue
8 int overFlow
Top

Declarations


 

	int i;
	int j;
	int sign;
	int mag;
	int code_val;
	int no_samples;



Top

Initialization Code



 

	if((template = (float*)calloc(smplbd, sizeof(float))) == NULL) {
		fprintf(stderr, "linecode: cannot allocate space\n");
		return(1);
	}
	if((code_type == 0) || (code_type == 3)) {	/* Binary */
		template[0] = 1.;
	}
	else if(code_type == 1) {	/* Biphase */
		if(smplbd%2 != 0) {
			fprintf(stderr,
				"linecode: oversample rate not \
					compatible with code type\n");
			return(1);
		}
		template[0] = -1.;
		template[smplbd/2] = 1.;
	}
	else if(code_type == 2) {	/* 2B1Q */
		template[0] = 1.;
	}
	else {
		fprintf(stderr,"linecode: unrecognized code type\n");
		return(2);
	}
        numberOutputBuffers = NO_OUTPUT_BUFFERS();
	if(numberOutputBuffers == 0) {
                fprintf(stderr,"linecode: no output buffers connected \n");
                return(3);
        }	
	overFlow=FALSE;




Top

Main Code



 


 for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) {
		IT_IN(0);
		if(code_type == 2) {
			even = ++even % 2;
			if(even) {
				mag = 1;
				if(bindata(0) == bindata(1)) mag = 3;	
				sign = -1;
				if(bindata(0) > 0.5) sign = 1;
			}
			else   continue;
		}
		else if (code_type == 3) {
			if (bindata(0)) {
				oneState = -1*oneState;
				sign = oneState;
				mag = 1.0;
			} else {
				mag = 0.0;
			}
		}
		else 	{	/* other code types */
			mag = 1;
			sign = -1;
			if(bindata(0) > 0.5) sign = 1;
		}

		code_val = sign * mag;
		for(i=0; i
    
Top

Wrapup Code



 

	free(template);




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



 

/**********************************************************************
                linecode()
***********************************************************************
Description:
This star inputs 0/1 binary data and outputs various line codes.
Line codes are selectable by the first input parameter `code_type':
	0 - Binary (NRZ) (1 = +1, 0 = -1)  (Default; 1 phase)
	1 - Biphase (Manchester) (1 = -1,+1; 0 = +1,-1)  (2 phase)
	2 - 2B1Q  (00 = -3, 01 = -1, 10 = +1, 11 = +3)  (1 phase)
	3 - RZ-AMI (Alternate mark inversion)
The code output oversampling rate (samples per baud interval) is
selected by the second parameter `smplbd'.  Note that multi-phase
codes require oversampling rates which are integer multiples of the
number of phases!
I/O buffers are float to be compatible with most stars.
Output buffer 0: Over sampled symbols.
Output buffer 1 (optional): symbols at baud rate.
Programmer:  L.J. Faber
Date: 11/25/86
Modified: 4/18/88 add 2B1Q
Modified: 5/88 add output1 as coded symbols, not oversampled
Modified: 6/88 change oversampling method to zero fill

linecode


This star inputs 0/1 binary data and outputs various line codes.
Line codes are selectable by the first input parameter `code_type':
	0 - Binary (NRZ) (1 = +1, 0 = -1)  (Default; 1 phase)
	1 - Biphase (Manchester) (1 = -1,+1; 0 = +1,-1)  (2 phase)
	2 - 2B1Q  (00 = -3, 01 = -1, 10 = +1, 11 = +3)  (1 phase)
	3 - RZ-AMI (Alternate mark inversion)
The code output oversampling rate (samples per baud interval) is
selected by the second parameter `smplbd'.  Note that multi-phase
codes require oversampling rates which are integer multiples of the
number of phases!
I/O buffers are float to be compatible with most stars.
Output buffer 0: Over sampled symbols.
Output buffer 1 (optional): symbols at baud rate.


Programmer:  L.J. Faber
Date: 11/25/86
Modified: 4/18/88 add 2B1Q
Modified: 5/88 add output1 as coded symbols, not oversampled
Modified: 6/88 change oversampling method to zero fill

*/