Spaces:
Sleeping

XCos_MCP / data /help /Integer_pal /SHIFT.xml
xcos-bot
Deploy snapshot from 23aafd1a (verified archive)
39e01c4
Raw History Blame Contribute Delete
20 kB
<?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>