File size: 24,430 Bytes
39e01c4 | 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | <?xml version="1.0" encoding="UTF-8"?>
<!--
* Xcos
*
* Copyright (C) INRIA - METALAU Project <scicos@inria.fr> (HTML version)
* Copyright (C) DIGITEO - Scilab Consortium (XML Docbook version)
* Copyright 2011 - Bernard DUJARDIN <bernard.dujardin@contrib.scilab.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* See the file ./license.txt
*
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
xmln.mml="http://www.w3.org/1998/Math/MathML" xml:id="EXTRACTBITS" xml:lang="en_US">
<refnamediv>
<refname>EXTRACTBITS</refname>
<refpurpose>Bits Extraction</refpurpose>
</refnamediv>
<refsection>
<title>Block Screenshot</title>
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../../images/palettes/EXTRACTBITS.png" align="center"/>
</imageobject>
</inlinemediaobject>
</refsection>
<refsection id="Contents_EXTRACTBITS">
<title>Contents</title>
<itemizedlist>
<listitem>
<xref linkend="Description_EXTRACTBITS">Description</xref>
</listitem>
<listitem>
<xref linkend="Data_Type_BITCLEAR">Data types</xref>
</listitem>
<listitem>
<xref linkend="Dialogbox_EXTRACTBITS">Parameters</xref>
</listitem>
<listitem>
<xref linkend="Defaultproperties_EXTRACTBITS">Default properties</xref>
</listitem>
<listitem>
<xref linkend="Interfacingfunction_EXTRACTBITS">Interfacing function</xref>
</listitem>
<listitem>
<xref linkend="Computationalfunction_EXTRACTBITS">Computational function</xref>
</listitem>
<listitem>
<xref linkend="Example_EXTRACTBITS">Example</xref>
</listitem>
<listitem>
<xref linkend="Seealso_EXTRACTBITS">See also</xref>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Description_EXTRACTBITS">
<title>Description</title>
<para>
For an integer input this block outputs a contiguous selection of bits. The operation can be
summarized by this expression:
</para>
<para>
<emphasis>Output = Input ∧ Mask</emphasis>
</para>
<para>
i.e. a bitwise <literal>AND</literal> between <literal>Input</literal> and
<literal>Mask</literal> an integer of the same length as input with the bits to extract
set to <literal>1</literal> and the other bits set to <literal>0</literal>.
<emphasis role="bold">Bits to Extract</emphasis> parameter defines the method by which the
user selects the output bits as summarized by the following table with index
<literal>0</literal>, as that of the least significant bit :
</para>
<informaltable border="1" cellpadding="2">
<tr>
<td align="left">
<emphasis role="bold">Bits to Extract</emphasis>
</td>
<td align="left">
<emphasis role="bold">Output</emphasis>
</td>
<td align="left">
<emphasis role="bold">Number of Bits or Index of Bit</emphasis>
</td>
</tr>
<tr>
<td align="left">
<emphasis role="bold">Upper Half</emphasis>
</td>
<td align="left">Half of the input that contain the most significant bit</td>
<td align="left">Ignored</td>
</tr>
<tr>
<td align="left">
<emphasis role="bold">Lower Half</emphasis>
</td>
<td align="left">Half of the input that contain the least significant bit</td>
<td align="left">Ignored</td>
</tr>
<tr>
<td align="left">
<emphasis role="bold">Range from MSB</emphasis>
</td>
<td align="left">
<emphasis role="bold">Number of Bits or Index of Bit</emphasis> bits of the input that
contain the most significant bit (MSB)
</td>
<td align="left">
Number of bits to extract.
</td>
</tr>
<tr>
<td align="left">
<emphasis role="bold">Range to LSB</emphasis>
</td>
<td align="left">
<emphasis role="bold">Number of Bits or Index of Bit</emphasis> bits of the input that
contain the least significant bit (LSB)
</td>
<td align="left">
Number of bits to extract.
</td>
</tr>
<tr>
<td align="left">
<emphasis role="bold">Range of bits</emphasis>
</td>
<td align="left">
Range of bits of the input between the indexes of the bits <literal>Start</literal> and
<literal>End</literal> of <emphasis role="bold">Number of Bits or Index of Bit</emphasis> parameter.
</td>
<td align="left">
Vector with the format <literal>[Start, End]</literal> where <literal>start</literal>
the first bit index and <literal>end</literal> the last bit index.
</td>
</tr>
</informaltable>
<para>
The output value depends also on the forth parameter
<emphasis role="bold">Treat Bit Field as an Integer</emphasis> :
</para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">0</emphasis> : the output is directly the result of extraction.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">1</emphasis> : the output is the integer conversion of
the extraction result according to the signed or non-signed status of the input.
</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Data_Type_EXTRACTBITS">
<title>Data types</title>
<para>
The block supports the following types :
</para>
<itemizedlist>
<listitem>
<para>
Input : scalar. All Scilab's integer type
(<emphasis role="bold">Data Type</emphasis> parameter).
</para>
</listitem>
<listitem>
<para>
Output : same type than input.
</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Dialogbox_EXTRACTBITS">
<title>Parameters</title>
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../gui/integer_pal/en_US/EXTRACTBITS_gui.png" align="center" style="float:right"/>
<!-- align => Javahelp, style => Online -->
</imageobject>
</inlinemediaobject>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">Data Type (3:int32, 4:int16, 5:int8, ...)</emphasis>
</para>
<para>
It indicates the integer type on input: Between 3 and 8.
</para>
<para> Properties : Type 'vec' of size 1. </para>
</listitem>
<listitem>
<para>
<emphasis role="bold">Bits to Extract</emphasis>
</para>
<para>
It indicates the mode used to extract bits from the input data : Between 1 and 5 (1:Upper Half,
2:Lower Half, 3:Range from MSB, 4:Range to LSB, 5:Range of bits)
</para>
<para> Properties : Type 'vec' of size 1. </para>
</listitem>
<listitem>
<para>
<emphasis role="bold">Number of Bits or Index of Bit</emphasis>
</para>
<para>
When the <emphasis role="bold">Bits to Extract</emphasis> field is set to :
</para>
<itemizedlist>
<listitem>
<para>
1 or 2, this parameter is ignored.
</para>
</listitem>
<listitem>
<para>
3 or 4, this parameter is used to determine the number of bits to extract. This number
must be if the type is :
</para>
<itemizedlist>
<listitem>
<para>
int32 or uint32: positive and less than 32.
</para>
</listitem>
<listitem>
<para>
int16 or uint16: positive and less than 16.
</para>
</listitem>
<listitem>
<para>
int8 or uint8: positive and less than 8.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
5, this parameter is used to determine range of bits to extract and it must have the <literal>[Start, End]</literal> form vector. <literal>Start</literal> must be less than <literal>End</literal>.
These values must be, if the type is:
</para>
<itemizedlist>
<listitem>
<para>
int32 or uint32: positive and less than 32.
</para>
</listitem>
<listitem>
<para>
int16 or uint16: positive and less than 16.
</para>
</listitem>
<listitem>
<para>
int8 or uint8: positive and less than 8.
</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
<para>See description for more information</para>
<para> Properties : Type 'vec' of size -1. </para>
</listitem>
<listitem>
<para>
<emphasis role="bold">Treat Bit Field as an Integer (0:No, 1:Yes)</emphasis>
</para>
<para>
0 or 1. It indicates the scaling mode to use on the output bits selection.
See description for more explanation.
</para>
<para> Properties : Type 'vec' of size 1.</para>
</listitem>
</itemizedlist>
<para/>
</refsection>
<refsection id="Defaultproperties_EXTRACTBITS">
<title>Default properties</title>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">always active:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">direct-feedthrough:</emphasis> yes
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">zero-crossing:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">mode:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">regular inputs:</emphasis>
</para>
<para>
<emphasis role="bold">- port 1 : size [1,1] / type 3</emphasis>
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">regular outputs:</emphasis>
</para>
<para>
<emphasis role="bold">- port 1 : size [1,1] / type 3</emphasis>
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">number/sizes of activation inputs:</emphasis> 0
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">number/sizes of activation outputs:</emphasis> 0
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">continuous-time state:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">discrete-time state:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">object discrete-time state:</emphasis> no
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">name of computational function:</emphasis>
<emphasis role="italic">extract_bit_32_UH0</emphasis>
</para>
</listitem>
</itemizedlist>
<para/>
</refsection>
<refsection id="Example_EXTRACTBITS">
<title>Example</title>
<para>
In the following table, we present the results obtained for the number 215 according to several
combinations of the parameters.
</para>
<informaltable border="1" cellpadding="3">
<tr>
<td>
<emphasis role="bold">Input</emphasis>
</td>
<td>
<emphasis role="bold">Bits to Extract</emphasis>
</td>
<td>
<emphasis role="bold">Number of Bits or Index of Bit</emphasis>
</td>
<td>
<emphasis role="bold">Treat Bit Field as an Integer</emphasis>
</td>
<td>
<emphasis role="bold">Output</emphasis>
</td>
</tr>
<tr>
<td style="white-space:nowrap">11010111 (215)</td>
<td>Upper Half</td>
<td>Ignored</td>
<td>no</td>
<td style="white-space:nowrap">01100000 (208)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Upper Half</td>
<td>Ignored</td>
<td>yes</td>
<td>00001101 (13)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Lower Half</td>
<td>Ignored</td>
<td>no</td>
<td>00000111 (7)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Lower Half</td>
<td>Ignored</td>
<td>yes</td>
<td>00000111 (7)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range starting with MSB</td>
<td>6</td>
<td>no</td>
<td>11010100 (212)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range starting with MSB</td>
<td>6</td>
<td>yes</td>
<td>00110101 (53)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range starting with LSB</td>
<td>6</td>
<td>no</td>
<td>00010111 (23)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range starting with LSB</td>
<td>6</td>
<td>yes</td>
<td>00010111 (23)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range of bits</td>
<td>[ 2, 5 ]</td>
<td>no</td>
<td>00010100 (20)</td>
</tr>
<tr>
<td>11010111 (215)</td>
<td>Range of bits</td>
<td>[ 2, 5 ]</td>
<td>yes</td>
<td>00000101 (5)</td>
</tr>
<tr>
<td>11010111 (-41)</td>
<td>Upper half</td>
<td>Ignored</td>
<td>no</td>
<td>11010000 (-48)</td>
</tr>
<tr>
<td>11010111 (-48)</td>
<td>Upper half</td>
<td>Ignored</td>
<td>yes</td>
<td>11111101 (-3)</td>
</tr>
</informaltable>
<para>
In the following diagram, two decimal digit numbers are coded on an only byte.
The diagram decode the input to obtain two separate digits.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/examples/integer_pal/en_US/EXTRACTBITS_en_US.zcos">
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../../examples/integer_pal/en_US/EXTRACTBITS_en_US.zcos" align="center"/>
</imageobject>
</inlinemediaobject>
</link>
</para>
</refsection>
<refsection id="Interfacingfunction_EXTRACTBITS">
<title>Interfacing function</title>
<itemizedlist>
<listitem>
<para>
<link type="scilab" linkend="scilab.scinotes/scicos_blocks/macros/IntegerOp/EXTRACTBITS.sci">SCI/modules/scicos_blocks/macros/IntegerOp/EXTRACTBITS.sci</link>
</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Computationalfunction_EXTRACTBITS">
<title>Computational function</title>
<itemizedlist>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_UH0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u32_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_LH.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_MSB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u32_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_LSB.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_RB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_32_RB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u32_RB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_UH0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u16_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_LH.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_MSB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u16_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_LSB.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_RB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_16_RB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u16_RB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_UH0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u8_UH1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_LH.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_MSB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u8_MSB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_LSB.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_RB0.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_8_RB1.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/extract_bit_u8_RB1.c
</listitem>
</itemizedlist>
</refsection>
<refsection role="see also" xml:id="Seealso_EXTRACTBITS">
<title>See also</title>
<simplelist type="inline">
<member>
<link linkend="BITSET">BITSET</link>
</member>
<member>
<link linkend="BITCLEAR">BITCLEAR</link>
</member>
<member>
<link linkend="LOGICAL_OP">LOGICAL_OP</link>
</member>
</simplelist>
</refsection>
</refentry>
|