summaryrefslogtreecommitdiff
path: root/js/IntegerOp/SHIFT.js
blob: 48bc9d66819bfa9858bbe766a2d4c678e2bac03a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* autogenerated from "macros/IntegerOp/SHIFT.sci" */
function SHIFT() {
SHIFT.prototype.define = function SHIFT() {
sgn=[0,0];
OPER=0;
model=scicos_model();
model.sim=list("shift_32_LA",4);
model.in1=-1;
model.out=-1;
model.in2=-2;
model.out2=-2;
model.intyp=3;
model.outtyp=3;
model.rpar=[];
model.ipar=sgn;
model.blocktype="c";
model.dep_ut=[true,false];
exprs=[sci2exp(3),sci2exp(0),sci2exp(0)];
gr_i=[];
x=standard_define([3,2],model,exprs,gr_i);
}
SHIFT.prototype.details = function SHIFT() {
}
SHIFT.prototype.get = function SHIFT() {
}
SHIFT.prototype.set = function SHIFT() {
x=arg1;
graphics=arg1.graphics;
model=arg1.model;
exprs=graphics.exprs;
while (true) {
[ok,Datatype,nb,np,exprs]=scicos_getvalue([msprintf(gettext("Set %s block parameters"),"SHIFT")," ",gettext("Shift/Rotates bits")],[msprintf(gettext("Data Type %s"),"(3:int32, 4:int16, 5:int8, ...)"),gettext("Number of Bits to Shift Left (Negative number to shift right)"),gettext("Shift Type (0:Arithmetic, 1:Circular)")],list("vec",1,"vec",1,"vec",1),exprs);
if (!ok) {
break
}
if ((np!=0&&np!=1)) {
block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Shift Type"),np),msprintf(gettext("Must be in the interval %s."),"[0, 1]"));
ok=false;
}
it=Datatype;
ot=Datatype;
if ((Datatype==3||Datatype==6)) {
if (nb>0) {
switch (np) {
case 0:
model.sim=list("shift_32_LA",4);
case 1:
model.sim=list("shift_32_LC",4);
}
} else if (nb<0) {
switch (np) {
case 0:
switch (Datatype) {
case 3:
model.sim=list("shift_32_RA",4);
case 6:
model.sim=list("shift_u32_RA",4);
}
case 1:
model.sim=list("shift_32_RC",4);
}
}
} else if ((Datatype==4||Datatype==7)) {
if (nb>0) {
switch (np) {
case 0:
model.sim=list("shift_16_LA",4);
case 1:
model.sim=list("shift_16_LC",4);
}
} else if (nb<0) {
switch (np) {
case 0:
switch (Datatype) {
case 4:
model.sim=list("shift_16_RA",4);
case 7:
model.sim=list("shift_u16_RA",4);
}
case 1:
model.sim=list("shift_16_RC",4);
}
}
} else if ((Datatype==5||Datatype==8)) {
if (nb>0) {
switch (np) {
case 0:
model.sim=list("shift_8_LA",4);
case 1:
model.sim=list("shift_8_LC",4);
}
} else if (nb<0) {
switch (np) {
case 0:
switch (Datatype) {
case 5:
model.sim=list("shift_8_RA",4);
case 8:
model.sim=list("shift_u8_RA",4);
}
case 1:
model.sim=list("shift_8_RC",4);
}
}
} else {
block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Data Type"),Datatype),msprintf(gettext("Must be in the interval %s."),"[3, 8]"));
ok=false;
}
if (ok) {
[model,graphics,ok]=set_io(model,graphics,list([-1,-2],it),list([-1,-2],ot),[],[]);
}
if (ok) {
model.ipar=nb;
graphics.exprs=exprs;
x.graphics=graphics;
x.model=model;
break
}
}
}
}