File size: 19,981 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 | <?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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
xmlns:scilab="http://www.scilab.org" xml:id="SHIFT" xml:lang="en_US">
<refnamediv>
<refname>SHIFT</refname>
<refpurpose>Shift/Rotates Bits</refpurpose>
</refnamediv>
<refsection>
<title>Block Screenshot</title>
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../../images/palettes/SHIFT.png"/>
</imageobject>
</inlinemediaobject>
</refsection>
<refsection id="Contents_SHIFT">
<title>Contents</title>
<itemizedlist>
<listitem>
<xref linkend="Description_SHIFT">Description</xref>
</listitem>
<listitem>
<xref linkend="Data_Type_SHIFT">Data types</xref>
</listitem>
<listitem>
<xref linkend="Dialogbox_SHIFT">Parameters</xref>
</listitem>
<listitem>
<xref linkend="Defaultproperties_SHIFT">Default properties</xref>
</listitem>
<listitem>
<xref linkend="Interfacingfunction_SHIFT">Interfacing function</xref>
</listitem>
<listitem>
<xref linkend="Computationalfunction_SHIFT">Computational function</xref>
</listitem>
<listitem>
<xref linkend="Example_SHIFT">Example</xref>
</listitem>
<listitem>
<xref linkend="Seealso_SHIFT">See also</xref>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Description_SHIFT">
<title>Description</title>
<para>
This block shifts the bits of the input signal. In this operation the digits are moved to the
right or to the left. The user can choose the rule to shifts the bits that can be normal or cycle
by setting the <emphasis role="bold">Shift Type</emphasis> parameter to <literal>0</literal> or <literal>1</literal>. The number and
the direction of the shifts are set with the <emphasis role="bold">Number of Bits to Shift Left</emphasis>.
If this number is positive the input is shifted to the left, otherwise it is shifted to the right.
</para>
<para>
When the <emphasis role="bold">Shift Type</emphasis> parameter is :
</para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">0</emphasis> : an arithmetic shift is applied to the input signal.
In this case, the bits that are shifted out of either end are discarded. Zeros are shifted
in on the right, in the case of left shift; in the case of right shifts, copies of the sign
bit is shifted in on the left.
</para>
<para>
By example, the one bit shift right gives:
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../images/palettes/integer_pal/shift_arithmetic_right.gif"/>
</imageobject>
<textobject>
<programlisting role="pic"><![CDATA[
.PS
First: box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
Last: box width 0.25 height 0.25 "1";
move 0.5; arrow 0.5 dashed; move 0.5;
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
spline at First.w left 0.375 then up 0.5 then right 0.5 then down 0.375 ->;
up;
arrow at Last.n;
.PE
]]></programlisting>
</textobject>
</inlinemediaobject>
and the one bit shift left gives:
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../images/palettes/integer_pal/shift_arithmetic_left.gif"/>
</imageobject>
<textobject>
<programlisting role="pic"><![CDATA[
.PS
First: box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
Last: box width 0.25 height 0.25 "1";
move 0.5; arrow 0.5 dashed; move 0.5;
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "0";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
up;
arrow at First.n;
move;
down;
arrow at Last.n+(0,0.5) " 0";
.PE
]]></programlisting>
</textobject>
</inlinemediaobject>
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">1</emphasis> : a circular shift is applied to the input signal.
In this case, the bits are rotated as if the left and right ends of the register are joined.
The value that is shifted in on the right during a left-shift is whatever values was shifted
out on the left, and vice versa.
</para>
<para>
By example, the one bit rotation right gives:
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../images/palettes/integer_pal/shift_rotate_right.gif"/>
</imageobject>
<textobject>
<programlisting role="pic"><![CDATA[
.PS
First: box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
Last: box width 0.25 height 0.25 "1";
move 0.5; arrow 0.5 dashed; move 0.5;
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "1";
spline at First.s down 0.25 then right then right 1.125 then right then up 0.375 then left 0.25 ->;
.PE
]]></programlisting>
</textobject>
</inlinemediaobject>
and the one bit rotation left gives:
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../images/palettes/integer_pal/shift_rotate_left.gif"/>
</imageobject>
<textobject>
<programlisting role="pic"><![CDATA[
.PS
First: box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
Last: box width 0.25 height 0.25 "1";
move 0.5; arrow 0.5 dashed; move 0.5;
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
box height 0.25 "...";
box width 0.25 height 0.25 "1";
box width 0.25 height 0.25 "0";
spline at Last.s down 0.25 then left then left 1.125 then left then up 0.375 then right 0.25 ->;
.PE
]]></programlisting>
</textobject>
</inlinemediaobject>
.
</para>
</listitem>
</itemizedlist>
<para>
The shift register makes a multiplication by
<literal>2<superscript>n</superscript></literal>
(arithmetic left shift) or an integer division by
<literal>2<superscript>n</superscript></literal>
(arithmetic right shift), where <literal>n</literal> is the number of bit shifts.
It can also be used to serialize data or to create a memory buffer.
</para>
</refsection>
<refsection id="Data_Type_SHIFT">
<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 and dimensions than input.
</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Dialogbox_SHIFT">
<title>Parameters</title>
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../gui/integer_pal/en_US/SHIFT_gui.png" 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 type of the input/output : between 3 and 8.
</para>
<para>Properties : Type 'vec' of size 1.</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">Number of Bits to Shift Left (Negative number to shift right)</emphasis>
</para>
<para>
It indicates the number of bits the input signal is shifted/rotated. A positive value indicates
a shift left, a negative value a shift right. The index must be, when 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>
<para>Properties : Type 'vec' of size 1.</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">Shift Type (0:Arithmetic, 1:Circular)</emphasis>
</para>
<para>
O or 1. It indicates the rule used to shift the bits. It can be arithmetic or circular.
When it is :
</para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">0</emphasis>, an arithmetic shift is applied to the input signal.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">1</emphasis>, a circular shift is applied to the input signal.
</para>
</listitem>
</itemizedlist>
<para>See description for more information.</para>
<para>Properties : Type 'vec' of size 1.</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Defaultproperties_SHIFT">
<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,-2] / type 3</emphasis>
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">regular outputs:</emphasis>
</para>
<para>
<emphasis role="bold">- port 1 : size [-1,-2] / 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">shift_32_LA</emphasis>
</para>
</listitem>
</itemizedlist>
<para/>
</refsection>
<refsection id="Example_SHIFT">
<title>Example</title>
<para>
In this example the Super block is a binary counter with 3 bits output. In order to obtain the corresponding decimal value,
the outputs
<emphasis><literal>Q<subscript>1</subscript></literal></emphasis> and
<emphasis><literal>Q<subscript>2</subscript></literal></emphasis>
of the counter are respectively shifted left
of one bit and of two bits. Finally the
<emphasis><literal>Q<subscript>0</subscript></literal></emphasis>
output, and the shifted outputs are added.
</para>
<para>
To better see the output change, set the parameter <emphasis>Real Time Scale</emphasis> to 0.5
in the <emphasis>Settings menu</emphasis> item of the <emphasis>Simulation menu</emphasis>.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/examples/integer_pal/en_US/SHIFT_en_US.zcos">
<inlinemediaobject>
<imageobject>
<imagedata fileref="../../../../examples/integer_pal/en_US/SHIFT_en_US.zcos" align="center"/>
</imageobject>
</inlinemediaobject>
</link>
</para>
<para>
Below the details of the binary counter.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/examples/integer_pal/en_US/SHIFT_internal_en_US.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../../examples/integer_pal/en_US/SHIFT_internal_en_US.zcos"/>
</imageobject>
</inlinemediaobject>
</link>
</para>
</refsection>
<refsection id="Interfacingfunction_SHIFT">
<title>Interfacing function</title>
<itemizedlist>
<listitem>
<para>
<link type="scilab" linkend="scilab.scinotes/scicos_blocks/macros/IntegerOp/SHIFT.sci">SCI/modules/scicos_blocks/macros/IntegerOp/SHIFT.sci</link>
</para>
</listitem>
</itemizedlist>
</refsection>
<refsection id="Computationalfunction_SHIFT">
<title>Computational function</title>
<itemizedlist>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_32_LA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_32_LC.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_32_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_u32_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_32_RC.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_16_LA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_16_LC.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_16_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_u16_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_16_RC.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_8_LA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_8_LC.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_8_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_u8_RA.c
</listitem>
<listitem>
SCI/modules/scicos_blocks/src/c/shift_8_RC.c
</listitem>
</itemizedlist>
</refsection>
<refsection role="see also" xml:id="Seealso_SHIFT">
<title>See also</title>
<simplelist type="inline">
<member>
<link linkend="BITSET">BITSET</link>
</member>
<member>
<link linkend="BITCLEAR">BITCLEAR</link>
</member>
</simplelist>
</refsection>
</refentry>
|