summaryrefslogtreecommitdiff
path: root/js/IntegerOp/EXTRACTBITS.js
diff options
context:
space:
mode:
authorSunil Shetye2018-06-25 18:20:39 +0530
committerSunil Shetye2018-06-26 11:06:22 +0530
commit7465daea85285ba7f291b6bf6ddc45caa9e7ad65 (patch)
treee8e3e4dd60d469c290d55de15644ddbc1e013bc6 /js/IntegerOp/EXTRACTBITS.js
parent7c70459c10aed0d74ee03896abaf47fefdbf7c8f (diff)
downloadsci2js-7465daea85285ba7f291b6bf6ddc45caa9e7ad65.tar.gz
sci2js-7465daea85285ba7f291b6bf6ddc45caa9e7ad65.tar.bz2
sci2js-7465daea85285ba7f291b6bf6ddc45caa9e7ad65.zip
add spacing to end of block also
Diffstat (limited to 'js/IntegerOp/EXTRACTBITS.js')
-rw-r--r--js/IntegerOp/EXTRACTBITS.js401
1 files changed, 201 insertions, 200 deletions
diff --git a/js/IntegerOp/EXTRACTBITS.js b/js/IntegerOp/EXTRACTBITS.js
index a2f1a280..c8cc060a 100644
--- a/js/IntegerOp/EXTRACTBITS.js
+++ b/js/IntegerOp/EXTRACTBITS.js
@@ -15,215 +15,216 @@ function EXTRACTBITS() {
model.dep_ut = [true,false];
exprs = [[sci2exp(3)],[sci2exp(1)],[sci2exp(0)],[sci2exp(0)]];
gr_i = [];
- x = standard_define([4,2],model,exprs,gr_i);
+ this.x = standard_define([4,2],model,exprs,gr_i);
}
EXTRACTBITS.prototype.details = function EXTRACTBITS() {
+ return this.x;
}
EXTRACTBITS.prototype.get = function EXTRACTBITS() {
}
EXTRACTBITS.prototype.set = function EXTRACTBITS() {
- x = arg1;
+ this.x = arg1;
graphics = arg1.graphics;
exprs = graphics.exprs;
model = arg1.model;
while (true) {
- [ok,Datatype,rule,bit,scal,exprs] = scicos_getvalue([[msprintf(gettext("Set %s block parameters"),"EXTRACTBITS")],[" "],[gettext("Bits Extraction")],[" "],[gettext(" - Bits to Extract:")],[gettext("    1 Upper Half")],[gettext("    2 Lower Half")],[gettext("    3 Range from MSB")],[gettext("    4 Range to LSB")],[gettext("    5 Range of Bits")],[gettext(" - Number of Bits or Index of bit : Index 0 is LSB")],[gettext("    If \'Bits to Extract\' is set to \'Range of bits\': [Start, End]")],[" "]],[[msprintf(gettext("Data Type %s"),"(3:int32, 4:int16, 5:int8, ...)")],[gettext("Bits to extract")],[gettext("Number of Bits or Index of Bit")],[gettext("Treat Bit Field as an Integer (0:No, 1:Yes)")]],list("vec",1,"vec",1,"vec",-1,"vec",1),exprs);
- if (!ok) {
-break;
-}
- bitstr = strcat(string(bit.slice())," ");
- if ((rule<1)||(rule>5)) {
-block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Bits to Extract"),rule),msprintf(gettext("Must be in the interval %s."),"[1, 5]"));
- ok = false;
- } else if (scal<0||scal>1) {
-block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Treat Bit Field as an Integer"),scal),msprintf(gettext("Must be in the interval %s."),"[0, 1]"));
- ok = false;
- } else {
- in1 = [model.in1,model.in2];
- bit = int(bit);
- rule = int(rule);
- if ((rule==3)||(rule==4)) {
- if ((size(bit,"*")!=1)) {
-block_parameter_error(msprintf(gettext("Wrong size for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),gettext("Must be a single value."));
- ok = false;
- } else {
- numb = bit;
-}
- } else if ((rule==5)) {
- if ((size(bit,"*")!=2)) {
-block_parameter_error(msprintf(gettext("Wrong size for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),gettext("Must have this form: [Start, End]."));
- ok = false;
- } else if (bit[1-1]>bit[2-1]) {
-block_parameter_error(msprintf(gettext("Wrong values for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("\'Start\' must be less than \'End\'.")));
- ok = false;
- } else {
- numb = bit[2-1]-bit[1-1];
-}
- } else {
- bit = 0;
- numb = [];
-}
-}
- if (ok) {
- if ((Datatype==3||Datatype==6)) {
- if (or(bit.slice()>31)||or(bit.slice()<0)) {
-block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 31]"));
- ok = false;
-}
- switch (rule) {
- case 1:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_32_UH0",4);
- case 1:
- switch (Datatype) {
- case 3:
- model.sim = list("extract_bit_32_UH1",4);
- case 6:
- model.sim = list("extract_bit_u32_UH1",4);
-}
-}
- case 2:
- model.sim = list("extract_bit_32_LH",4);
- case 3:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_32_MSB0",4);
- case 1:
- switch (Datatype) {
- case 3:
- model.sim = list("extract_bit_32_MSB1",4);
- case 6:
- model.sim = list("extract_bit_u32_MSB1",4);
-}
-}
- case 4:
- model.sim = list("extract_bit_32_LSB",4);
- case 5:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_32_RB0",4);
- case 1:
- switch (Datatype) {
- case 3:
- model.sim = list("extract_bit_32_RB1",4);
- case 6:
- model.sim = list("extract_bit_u32_RB1",4);
-}
-}
-}
- } else if ((Datatype==4||Datatype==7)) {
- if (or(bit.slice()>15)||or(bit.slice()<0)) {
-block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 15]"));
- ok = false;
-}
- switch (rule) {
- case 1:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_16_UH0",4);
- case 1:
- switch (Datatype) {
- case 4:
- model.sim = list("extract_bit_16_UH1",4);
- case 7:
- model.sim = list("extract_bit_u16_UH1",4);
-}
-}
- case 2:
- model.sim = list("extract_bit_16_LH",4);
- case 3:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_16_MSB0",4);
- case 1:
- switch (Datatype) {
- case 4:
- model.sim = list("extract_bit_16_MSB1",4);
- case 7:
- model.sim = list("extract_bit_u16_MSB1",4);
-}
-}
- case 4:
- model.sim = list("extract_bit_16_LSB",4);
- case 5:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_16_RB0",4);
- case 1:
- switch (Datatype) {
- case 4:
- model.sim = list("extract_bit_16_RB1",4);
- case 7:
- model.sim = list("extract_bit_u16_RB1",4);
-}
-}
-}
- } else if ((Datatype==5||Datatype==8)) {
- if (or(bit.slice()>7)||or(bit.slice()<0)) {
-block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 7]"));
- ok = false;
-}
- switch (rule) {
- case 1:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_8_UH0",4);
- case 1:
- switch (Datatype) {
- case 5:
- model.sim = list("extract_bit_8_UH1",4);
- case 8:
- model.sim = list("extract_bit_u8_UH1",4);
-}
-}
- case 2:
- model.sim = list("extract_bit_8_LH",4);
- case 3:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_8_MSB0",4);
- case 1:
- switch (Datatype) {
- case 5:
- model.sim = list("extract_bit_8_MSB1",4);
- case 8:
- model.sim = list("extract_bit_u8_MSB1",4);
-}
-}
- case 4:
- model.sim = list("extract_bit_8_LSB",4);
- case 5:
- switch (scal) {
- case 0:
- model.sim = list("extract_bit_8_RB0",4);
- case 1:
- switch (Datatype) {
- case 5:
- model.sim = list("extract_bit_8_RB1",4);
- case 8:
- model.sim = list("extract_bit_u8_RB1",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) {
- it = Datatype;
- ot = Datatype;
- out = [1,1];
- [model,graphics,ok] = set_io(model,graphics,list(in1,it),list(out,ot),[],[]);
-}
- if (ok) {
- graphics.exprs = exprs;
- model.ipar = [[int(bit.slice())],[int(numb.slice())]];
- x.graphics = graphics;
- x.model = model;
-break;
-}
-}
+ [ok,Datatype,rule,bit,scal,exprs] = scicos_getvalue([[msprintf(gettext("Set %s block parameters"),"EXTRACTBITS")],[" "],[gettext("Bits Extraction")],[" "],[gettext("&nbsp;- Bits to Extract:")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;1 Upper Half")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;2 Lower Half")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;3 Range from MSB")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;4 Range to LSB")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;5 Range of Bits")],[gettext("&nbsp;- Number of Bits or Index of bit : Index 0 is LSB")],[gettext("&nbsp;&nbsp;&nbsp;&nbsp;If \'Bits to Extract\' is set to \'Range of bits\': [Start, End]")],[" "]],[[msprintf(gettext("Data Type %s"),"(3:int32, 4:int16, 5:int8, ...)")],[gettext("Bits to extract")],[gettext("Number of Bits or Index of Bit")],[gettext("Treat Bit Field as an Integer (0:No, 1:Yes)")]],list("vec",1,"vec",1,"vec",-1,"vec",1),exprs);
+ if (!ok) {
+ break;
+ }
+ bitstr = strcat(string(bit.slice())," ");
+ if ((rule<1)||(rule>5)) {
+ block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Bits to Extract"),rule),msprintf(gettext("Must be in the interval %s."),"[1, 5]"));
+ ok = false;
+ } else if (scal<0||scal>1) {
+ block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %d."),gettext("Treat Bit Field as an Integer"),scal),msprintf(gettext("Must be in the interval %s."),"[0, 1]"));
+ ok = false;
+ } else {
+ in1 = [model.in1,model.in2];
+ bit = int(bit);
+ rule = int(rule);
+ if ((rule==3)||(rule==4)) {
+ if ((size(bit,"*")!=1)) {
+ block_parameter_error(msprintf(gettext("Wrong size for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),gettext("Must be a single value."));
+ ok = false;
+ } else {
+ numb = bit;
+ }
+ } else if ((rule==5)) {
+ if ((size(bit,"*")!=2)) {
+ block_parameter_error(msprintf(gettext("Wrong size for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),gettext("Must have this form: [Start, End]."));
+ ok = false;
+ } else if (bit[1-1]>bit[2-1]) {
+ block_parameter_error(msprintf(gettext("Wrong values for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("\'Start\' must be less than \'End\'.")));
+ ok = false;
+ } else {
+ numb = bit[2-1]-bit[1-1];
+ }
+ } else {
+ bit = 0;
+ numb = [];
+ }
+ }
+ if (ok) {
+ if ((Datatype==3||Datatype==6)) {
+ if (or(bit.slice()>31)||or(bit.slice()<0)) {
+ block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 31]"));
+ ok = false;
+ }
+ switch (rule) {
+ case 1:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_32_UH0",4);
+ case 1:
+ switch (Datatype) {
+ case 3:
+ model.sim = list("extract_bit_32_UH1",4);
+ case 6:
+ model.sim = list("extract_bit_u32_UH1",4);
+ }
+ }
+ case 2:
+ model.sim = list("extract_bit_32_LH",4);
+ case 3:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_32_MSB0",4);
+ case 1:
+ switch (Datatype) {
+ case 3:
+ model.sim = list("extract_bit_32_MSB1",4);
+ case 6:
+ model.sim = list("extract_bit_u32_MSB1",4);
+ }
+ }
+ case 4:
+ model.sim = list("extract_bit_32_LSB",4);
+ case 5:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_32_RB0",4);
+ case 1:
+ switch (Datatype) {
+ case 3:
+ model.sim = list("extract_bit_32_RB1",4);
+ case 6:
+ model.sim = list("extract_bit_u32_RB1",4);
+ }
+ }
+ }
+ } else if ((Datatype==4||Datatype==7)) {
+ if (or(bit.slice()>15)||or(bit.slice()<0)) {
+ block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 15]"));
+ ok = false;
+ }
+ switch (rule) {
+ case 1:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_16_UH0",4);
+ case 1:
+ switch (Datatype) {
+ case 4:
+ model.sim = list("extract_bit_16_UH1",4);
+ case 7:
+ model.sim = list("extract_bit_u16_UH1",4);
+ }
+ }
+ case 2:
+ model.sim = list("extract_bit_16_LH",4);
+ case 3:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_16_MSB0",4);
+ case 1:
+ switch (Datatype) {
+ case 4:
+ model.sim = list("extract_bit_16_MSB1",4);
+ case 7:
+ model.sim = list("extract_bit_u16_MSB1",4);
+ }
+ }
+ case 4:
+ model.sim = list("extract_bit_16_LSB",4);
+ case 5:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_16_RB0",4);
+ case 1:
+ switch (Datatype) {
+ case 4:
+ model.sim = list("extract_bit_16_RB1",4);
+ case 7:
+ model.sim = list("extract_bit_u16_RB1",4);
+ }
+ }
+ }
+ } else if ((Datatype==5||Datatype==8)) {
+ if (or(bit.slice()>7)||or(bit.slice()<0)) {
+ block_parameter_error(msprintf(gettext("Wrong value for \'%s\' parameter: %s."),gettext("Number of Bits or Index of Bit"),bitstr),msprintf(gettext("Indexes must be in the interval %s."),"[0, 7]"));
+ ok = false;
+ }
+ switch (rule) {
+ case 1:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_8_UH0",4);
+ case 1:
+ switch (Datatype) {
+ case 5:
+ model.sim = list("extract_bit_8_UH1",4);
+ case 8:
+ model.sim = list("extract_bit_u8_UH1",4);
+ }
+ }
+ case 2:
+ model.sim = list("extract_bit_8_LH",4);
+ case 3:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_8_MSB0",4);
+ case 1:
+ switch (Datatype) {
+ case 5:
+ model.sim = list("extract_bit_8_MSB1",4);
+ case 8:
+ model.sim = list("extract_bit_u8_MSB1",4);
+ }
+ }
+ case 4:
+ model.sim = list("extract_bit_8_LSB",4);
+ case 5:
+ switch (scal) {
+ case 0:
+ model.sim = list("extract_bit_8_RB0",4);
+ case 1:
+ switch (Datatype) {
+ case 5:
+ model.sim = list("extract_bit_8_RB1",4);
+ case 8:
+ model.sim = list("extract_bit_u8_RB1",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) {
+ it = Datatype;
+ ot = Datatype;
+ out = [1,1];
+ [model,graphics,ok] = set_io(model,graphics,list(in1,it),list(out,ot),[],[]);
+ }
+ if (ok) {
+ graphics.exprs = exprs;
+ model.ipar = [[int(bit.slice())],[int(numb.slice())]];
+ this.x.graphics = graphics;
+ this.x.model = model;
+ break;
+ }
+ }
}
}