Capsim Block Documentation
Review code.
Port | Type | Name | |
---|---|---|---|
0 | float | x |
Port | Type | Name | |
---|---|---|---|
0 | float | y |
Num | Description | Type | Name | Default Value | |
---|---|---|---|---|---|
0 | Number of bits per frame (Info Only) | int | numberOfBits | 128 | |
1 | Debug:1=true,0=false | int | debugFlag | 0 |
unsigned short carry; int bit; int i; unsigned int m; int numberOfSamples; UINT16 checkStuff; int mask; int done; int bitPos; int bytePos; int rc; |
---|
if(debugFlag) { debug_F=fopen("bitmanip.dbg","w"); if(debug_F == NULL) return(2); } infoLengthBytes = numberOfBits/8+1; for(i=0; i<8; i++) { queue_A[i]=(char*)calloc(infoLengthBytes,sizeof(char)); if(queue_A[i]==NULL) { fprintf(stderr,"bitmanip could not allocate space\n"); return(1); } } |
---|
while(IT_IN(0) ) { /* * collect the bits * and store them in a buffer * first info frames are stored in queue zero */ bit=(int)(x(0)+0.001); buildByte |= bit; buildByteBits++; if(debugFlag) fprintf(debug_F,"bit=%d,buildByte=%4x,buildByteBits=%d,byteCount=%d\n", bit,buildByte,buildByteBits,byteCount); if(buildByteBits == 8) { queue_A[0][byteCount]=buildByte; buildByte=0; buildByteBits=0; byteCount++; } bitCount++; if(bitCount == numberOfBits) { infoComplete=1; queue_A[0][byteCount]=buildByte; byteCount=0; buildByte=0; buildByteBits=0; bitCount=0; break; } buildByte <<= 1; } if(infoComplete) { done=0; bitsProc=0; while(!done) { /* * get a bit */ bytePos=bitsProc >> 3; bitPos = 7-(bitsProc % 8); mask=1; mask <<= bitPos; bit = (queue_A[0][bytePos] & mask) ? 1:0; if(debugFlag) fprintf(debug_F,"output:bit=%d,queue=%4x,bitPos=%d,bytePos=%d\n", bit,queue_A[0][bytePos],bitPos,bytePos); bitsProc++; if(bitsProc == numberOfBits) { endFrame=1; bitsProc=0; } /* * Output bit */ if(IT_OUT(0) ){ KrnOverflow("bitmanip",0); return(99); } y(0) = bit; if(endFrame) { /* * Finished outputting * Reset everything */ frameCount++; done=1; infoComplete=0; endFrame=0; } } } return(0); |
---|
fprintf(stderr,"bitmanip: number of outputted frames=%d\n",frameCount); for(i=0; i<8; i++) free(queue_A[i]); if(debugFlag) fclose(debug_F); |
---|
/* 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 */ |
---|
/* |
---|