//BINREG_c Scicos Binary shift register function block //Classical interface function ver1.0 - scilab-4.1 //20 mars 2007 - INRIA - Author : A.Layec function [x,y,typ]=BINREG_c(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; exprs=graphics.exprs; while %t do [ok,nbit,nw,ci,cc2_in,cc2_out,exprs]=getvalue('Scicos Binary shift register block',... ['Number of bit';'Number of word';'Output initial condition'; '2''s complement in input (0:No/1:Yes)';... '2''s complement in output (0:No/1:Yes)'],... list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs); if ~ok then break,end; if(size(nbit)==size(nw)&... size(nbit)==size(ci)&... size(nbit)==size(cc2_in)&... size(nbit)==size(cc2_out)) then if ok then Nu=size(nbit,'*'); graphics.exprs=exprs ipar=[cc2_in(:);cc2_out(:);nbit(:);nw(:)] model.ipar=ipar(:) model.dstate=ci(:) model.in=Nu; model.out=Nu [model,graphics,ok]=check_io(model,graphics,Nu,Nu,[1;1],[]); x.graphics=graphics; x.model=model; break; end else message('Inconsistent parameters dimensions'); end end case 'define' then Nu=1 cc2_in=1 cc2_out=1 ci=0 nbit=3 nw=4 model=scicos_model() model.sim=list('binreg',4) model.in=Nu model.out=Nu model.evtin=[1;1] model.evtout=[] model.dstate=ci model.rpar=[] model.ipar=[cc2_in;cc2_out;nbit;nw] model.blocktype='d' model.firing=[] model.dep_ut=[%f %f] gr_i=['txt=['' Binary'';''Shift Reg.''];'; 'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');'] exprs=[string(nbit),string(nw),string(ci),string(cc2_in),string(cc2_out)] x=standard_define([2 2],model,exprs,gr_i) end endfunction