Fonction d'interfaçage
fr
DEC2BIN_c
//DEC2BIN_c Scicos Random Integer Generator block
//Classical interface function ver1.0 - scicoslab 4.3
//14 Février 2009 - INRIA - Author : A.Layec
function [x,y,typ]=DEC2BIN_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,insz,N,msb,is_sign,outtyp,exprs] = getvalue('Scicos Decimal number to Bit number',...
['Input size';
'Number of bits per integer';
'MSB first (0:No/1:Yes)';
'Signed number (0:No/1:Yes)';
'Output data type'],...
list('vec',1,'vec',1,'vec',1,'vec',1,'vec',1),exprs);
if ~ok then break,end;
//## check in size
if insz<=0 then
message('Input Size must be positive.');
ok=%f;
end
//## check number of bit per integer
if N<=0 | N>=31 then
message([' Number of bits per integer';...
'must be in [1;31].']);
ok=%f;
end
//## check msb dialogue parameter
if msb<0 | msb>1 then
message([' The dialogue parameter';...
'''MSB first'' must be 0 or 1.']);
ok=%f;
end
//## check is_sign dialogue parameter
if is_sign<0 | is_sign>1 then
message([' The dialogue parameter';...
'''Signed number'' must be 0 or 1.']);
ok=%f;
end
//## check output data type
if ~(or(outtyp==[1:8])) then
message([' Set -1 for automatic switch for output data type';...
'or use a scicos datatype number (1,2,3,4,5,6,7 or 8)']);
ok=%f;
end
if ok then
[model,graphics,ok] = set_io(model,graphics,list([insz,1],-1),list([N*insz,1],outtyp),[],[])
model.ipar = [N,msb,is_sign]
graphics.exprs = exprs;
x.graphics = graphics;
x.model = model;
break;
end
end
case 'define' then
N = 4 //## nb de bits par entier
msb = 1 //## msb en premier
is_sign = 0 //## nombre signé(0:oui/1:non)
insz = 1 //## taille de l'entrée
outtyp = 8 //## type de donnée de la sortie
model = scicos_model()
model.sim = list('dec2bin',4)
model.in = insz
model.in2 = 1
model.intyp = -1
model.out = N*insz
model.out2 = 1
model.outtyp = 8
model.evtin = []
model.ipar = []
model.blocktype = 'd'
model.firing = [N;msb;is_sign]
model.dep_ut = [%t %f]
gr_i = ['txt=[''Dec2Bin''];';
'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
label = [string(insz);string(N);string(msb);string(is_sign);string(outtyp)];
x = standard_define([2.5 2],model,label,gr_i)
end
endfunction