/* Modnumlib Scicos interfacing function * Copyright (C) 2009 Alan Layec * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 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 * General Public License for more details. * * You should have received a copy of the GNU 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. */ /* genint Scicos Random Integer Generator block * Type 4 simulation function ver 1.0 - scilab-3.0 * 3 janvier 2005 - IRCOM GROUP - Author : A.Layec */ /* REVISION HISTORY : * $Log$ */ #include <scicos/scicos_block.h> #include "modnum_lib.h" /* Ce bloc est générateur de nombre entier aléatoire. Il peut générer des trains binaires * type RZ ou NRZ ou bien des nombres entiers de longueurs déterminées, signés ou non signés * * entrées régulières : néant * sorties régulières : sortie du générateur * entrée évènementielle : détermine la cadence de génération * * paramètres entiers : ipar[0..outsz[0]-1] : vecteur du nombre de bit du mot de sortie * ipar[outsz[0]..2*outsz[0]-1]: vecteur du type de générateur * * nb : Type 0: génére 1 seul bit codé NRZ * 1: génère 1 seul bit codé RZ, ou un mot non signé * 2: génère un mot codé code complément à 2 */ /*prototype*/ void genint(scicos_block *block,int flag) { /*Déclaration des variables*/ double *y; int ny; /*Récupération de l'adresse du port de sortie régulier*/ y=(double *)block->outptr[0]; /*Récupération de la taille du vecteur de sortie*/ ny=block->outsz[0]; /*Le flag 1 recopie le vecteur Z dans le vecteur Y*/ if (flag==1||flag==6) { copyd_c(&ny,&block->z[0],&y[0]); } /*Le flag 2 calcul les valeurs ou mots binaires dans Z*/ else if(flag==2||flag==4) { /*Appel genintv_c*/ genintv_c(&ny,&block->ipar[0],&block->ipar[ny],&block->z[0]); } }