//GENSYMB_f Scicos Generic Symbol Generator block //Classical interface function ver1.0 - scilab-3.0 //1st Feb 2005 Author : - IRCOM GROUP - A.Layec //Doit etre complètement revu : fait l'affaire pour l'instant function [x,y,typ]=GENSYMB_f(job,arg1,arg2) x=[];y=[];typ=[] select job case 'plot' then standard_draw(arg1) case 'getinputs' then [x,y,typ]=standard_inputs(arg1) case 'getoutputs' then [x,y,typ]=standard_outputs(arg1) case 'getorigin' then [x,y]=standard_origin(arg1) case 'set' then x=arg1; graphics=arg1.graphics;model=arg1.model; exprs1=graphics.exprs(1:7) exprs2=graphics.exprs(8:10) while %t do text=['Set Symbol Generator Block'] [ok,nb_sym,nbit,typm,typu,nech,typf,enin,exprs1]=getvalue(text,... ['Number of Symbols';... 'Number of bits per symbol' 'Type of Modulation(0:PSK,1:QAM)';... 'Type of Upsample(0:No UpSample,1:Upsample,2:Resample)';... 'Samples per symbol';... 'Type of filtering(0:No filter,1:Generic,2:RRC,3:RC,4:Gauss)';... 'Enable external input integer port (0/1)?'],... list('vec',1,'vec',1,'vec',1,'vec',1,'vec',1,'vec',1,'vec',1),exprs1) if ~ok then break,end; if(nb_sym<0) then flag_seq=1; nb_sym=1 else flag_seq=0; end if flag_seq then sz_out=1 else sz_out=nb_sym*nech; //output size end m=2^nbit; //number of states if typf==0 then if flag_seq then nb_coef=0 m1=0; initc=0; pulse=0; else nb_coef=nb_sym; m1=0; initc=0; pulse=0; end ok2=%t //Attention il y a un bug à corriger sur le //comportement de la var ok elseif typf==1 then [ok2,Nu,nb_coef,pulse,exprs2]=get_genfir(exprs2) if flag_seq then m1=0 initc=1 else m1=2^(int(log(sz_out+nb_coef-1)/log(2))+1) //size of fft input (for zero pading) initc=1 end else message('Only No Filter and Generic filter are activated') ok2=%f end if(typm<>0) then message('Only PSK Modulation is activated') ok=%f end if(typu<>1) then message('Only Upsample(Type 1) is activated') ok=%f end if(nbit<1) then message('Number of bits : Wrong parameter') ok=%f end if ok&ok2 then if (nbit>1) then if(enin==0) then [model,graphics,ok]=check_io(model,graphics,[],[sz_out;sz_out],[1],[]) model.dep_ut=[%f %f] model.out=[sz_out;sz_out] else if flag_seq then [model,graphics,ok]=check_io(model,graphics,[1],[sz_out;sz_out],[1],[]) model.dep_ut=[%f %f] model.in=[1] else [model,graphics,ok]=check_io(model,graphics,[nb_sym],[sz_out;sz_out],[],[]) model.in=[nb_sym] model.dep_ut=[%t %f] end model.out=[sz_out;sz_out] nb_sym=0 end if flag_seq then if (nb_coef<>0) then model.dstate=[1;zeros(nb_coef,1);zeros(nb_coef,1)] else model.dstate=[1] end else model.dstate=[zeros(nb_coef,1);zeros(nb_coef,1)] end elseif(nbit==1) then if(enin==0) then [model,graphics,ok]=check_io(model,graphics,[],[sz_out],[1],[]) model.dep_ut=[%f %f] model.out=[sz_out] else if flag_seq then [model,graphics,ok]=check_io(model,graphics,[1],[sz_out],[1],[]) model.dep_ut=[%f %f] model.in=[1] else [model,graphics,ok]=check_io(model,graphics,[nb_sym],[sz_out],[],[]) model.dep_ut=[%t %f] model.in=[nb_sym] end model.out=[sz_out] nb_sym=0 end if flag_seq then if (nb_coef<>0) then model.dstate=[1;zeros(nb_coef,1)] else model.dstate=[1] end else model.dstate=[zeros(nb_coef,1)] end end model.rpar=[pulse(:)] model.ipar=[nb_sym;nbit;m;nech;initc;nb_coef;m1;flag_seq] exprs=[exprs1(:)',exprs2(:)'] graphics.exprs=exprs x.graphics=graphics;x.model=model break; end end case 'define' then nb_sym=64; //number of symbol (input size) nbit=1; //Lenght of symbol typm=0; //Type of modulation typu=1; //Type of upsample nech=1; //Upsample factor typf=0; //Type of filtering enin=0; //enable external input flag_seq=0; //Type of generator (0:vectorial;1:sequential) herit=0; sz_out=nb_sym*nech; // output size m=2^nbit; //number of states initc=1; //initial counter of upsampler //Generic pulse=[1;-1;1] //impulse response nb_coef=3 //number of filter tap plot_rep=0 //flag for plotting rep impulse in graph wind m1=2^(int(log(sz_out+nb_coef-1)/log(2))+1) //size of fft input (for zero pading) //filter_tap fe=12 //frequency sampling gain=1 //output gain of filter r=0.35 //roll-off factor (for RRC,RC) b=0.5 //BT factor (for gauss) model=scicos_model() model.sim=list('gensymb',4) model.in=[] model.out=[sz_out] model.evtin=[1] model.evtout=[] model.dstate=[zeros(nb_coef,1);zeros(nb_coef,1)] model.rpar=[pulse(:)] model.ipar=[nb_sym;nbit;m;nech;initc;nb_coef;m1;flag_seq] model.blocktype='d' model.firing=[] model.dep_ut=[%f %f] gr_i=['txt=[''Symbol'';''Generator''];'; 'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');'] exprs1=[string(nb_sym),string(nbit),string(typm),string(typu),string(nech),string(typf),string(enin)] exprs2=[string('-1'),sci2exp(pulse),string(plot_rep)] //genfir exprs=[exprs1,exprs2] x=standard_define([2 2],model,exprs,gr_i) end endfunction function [ok,Nu,nb_coef,pulse,exprs]=get_genfir(exprs) in_sz=[];Nu=[]; while %t do [ok,nb_coef,pulse,plot_rep,exprs]=getvalue('Set Generic Impulse Response Vector',... ['Number of coefficients';... 'Vector of impulse response';... 'Plot impulse response (0:No/Windows Id)?'],... list('vec',-1,'vec',-1,'vec',1),exprs) if ~ok then break,end; Nu=prod(size(nb_coef)) if Nu<>1 then message('Sorry, for the moment only one scalar or vector of symbol can be generated'); ok=%f end if ok then // if size(nb_coef,'*')<>1 then nb_coef=nb_coef(:) ptri=1 ptrf=nb_coef(1) elseif nb_coef==-1 then Nu=1; nb_coef=size(pulse,'*') ptri=1 ptrf=nb_coef else Nu=1; ptri=1 ptrf=nb_coef end pulse=pulse(:); for j=1:Nu if j>1 then ptri=ptrf+1 ptrf=ptri+nb_coef(j)-1 end if plot_rep<>0 then puls=pulse(ptri:ptrf); win=xget("window"); xset("window",int(plot_rep+j-1)); xset("wdim",300,200); xbasc(); plot2d3(1:nb_coef(j),puls,,"111",,rect=[0,min(puls),nb_coef(j),max(puls)]); xset("window",win); end end break; end end endfunction