<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Lothar Miller - Numeric_Std</title>
    <link>http://www.lothar-miller.de/s9y/</link>
    <description>Elektronik und Musik</description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <pubDate>Thu, 10 Dec 2009 12:43:42 GMT</pubDate>

    <image>
        <url>http://www.lothar-miller.de/s9y/templates/bulletproof/img/s9y_banner_small.png</url>
        <title>RSS: Lothar Miller - Numeric_Std - Elektronik und Musik</title>
        <link>http://www.lothar-miller.de/s9y/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Vektormanipulation</title>
    <link>http://www.lothar-miller.de/s9y/archives/65-Vektormanipulation.html</link>
            <category>Numeric_Std</category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/65-Vektormanipulation.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=65</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.lothar-miller.de/s9y/rss.php?version=2.0&amp;type=comments&amp;cid=65</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Mit der numeric_std lassen sich schöne Dinge anstellen, die den Code fast unlesbar machen &lt;img src=&quot;http://www.lothar-miller.de/s9y/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;/p&gt;&lt;p&gt;Hier einige akademische und praktische Beispiele, wie ein &lt;b&gt;16-Bit Integer in einzelne Nibble zerlegt&lt;/b&gt; werden kann:&lt;/p&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; &lt;span&gt;IEEE&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; &lt;span&gt;IEEE&lt;/span&gt;.&lt;span&gt;STD_LOGIC_1164&lt;/span&gt;.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; &lt;span&gt;IEEE&lt;/span&gt;.&lt;span&gt;NUMERIC_STD&lt;/span&gt;.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;entity&lt;/span&gt; &lt;span&gt;Vectors&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( &lt;span&gt;vin&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;15&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;           &lt;span&gt;sel&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;           &lt;span&gt;voutA&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;           &lt;span&gt;voutB&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;           &lt;span&gt;voutC&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;           &lt;span&gt;voutD&lt;/span&gt; : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC_VECTOR&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;));&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; &lt;span&gt;Vectors&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;architecture&lt;/span&gt; &lt;span&gt;Behavioral&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; &lt;span&gt;Vectors&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;s&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;i&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;integer&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;range&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;to&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;**&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;-&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;h&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;integer&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;range&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;to&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;i&lt;/span&gt; &amp;lt;= &lt;span&gt;to_integer&lt;/span&gt;(&lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;vin&lt;/span&gt;));&lt;br /&gt;   &lt;span&gt;s&lt;/span&gt; &amp;lt;= &lt;span&gt;sel&lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;) &amp;amp; &lt;span&gt;sel&lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt;);&lt;br /&gt;   &lt;span&gt;h&lt;/span&gt; &amp;lt;= &lt;span&gt;to_integer&lt;/span&gt;(&lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;s&lt;/span&gt;));          &lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;with&lt;/span&gt; &lt;span&gt;s&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;select&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;voutA&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;00&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;7&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;01&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;11&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;8&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;10&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;15&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;12&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;others&lt;/span&gt;;&lt;br /&gt;            &lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;with&lt;/span&gt; &lt;span&gt;s&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;select&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;voutB&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;     ,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;00&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;  ,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;01&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;256&lt;/span&gt; ,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;background-color: rgb(255, 240, 240); color: rgb(221, 34, 0);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;10&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;br /&gt;            &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1024&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;others&lt;/span&gt;;&lt;br /&gt;            &lt;br /&gt;   &lt;span&gt;voutC&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;16&lt;/span&gt;)(&lt;span&gt;h&lt;/span&gt;*&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;+&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span&gt;h&lt;/span&gt;*&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- leider noch nicht synthetisierbar&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;voutD&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;/(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;**(&lt;span&gt;h&lt;/span&gt;*&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)),&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;4&lt;/span&gt;)); &lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; &lt;span&gt;Behavioral&lt;/span&gt;;&lt;/pre&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;p&gt;Zuerst wird vorbereitend der Eingangsvektor vin in einen Integer i umgewandelt. Im echten Leben wäre i z.B. ein Zähler oder ein Rechenwert. Der Auswahlvektor s wird aus einzelnen Bits eines Eingangssignals zusammengesetzt. Über s wird dann jeweils ein Nibble von i auf voutA..C abgebildet. &lt;br /&gt;&lt;br /&gt;Wie im RTL-Schaltplan zu sehen ist, werden alle drei gültigen Beschreibungen identisch implementiert:&lt;/p&gt;&lt;div style=&quot;width: 593px;&quot; class=&quot;serendipity_imageComment_center&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:128 --&gt;&lt;img height=&quot;544&quot; width=&quot;593&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Mux.gif&quot; class=&quot;serendipity_image_center&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;Alle drei Beschreibungen erzeugen die selbe Hardware&lt;/div&gt;&lt;/div&gt;&lt;p /&gt;&lt;p&gt;&lt;br /&gt;voutD simuliert zwar schön, kann aber von der Synthese nicht abgebildet werden, Xilinx ISE meldet:&lt;br /&gt;&lt;font color=&quot;#0000cc&quot;&gt;&lt;b&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;Operator &amp;lt;DIVIDE&amp;gt; must have constant operands or first operand must be power of 2&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;Die Fehlermeldung ist nicht ganz einsichtig, denn 2**(h*4) ist eine Zweierpotenz &lt;img src=&quot;http://www.lothar-miller.de/s9y/templates/default/img/emoticons/sad.png&quot; alt=&quot;:-(&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Soll aus einem &lt;b&gt;Integer ein einzelnes Bit&lt;/b&gt; herausgelöst werden, können diese Beschreibungen verwendet werden:&lt;/p&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;pre&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;bit9&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC&lt;/span&gt;;&lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;bit8&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;STD_LOGIC&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- ein einzelnes Bit aus einem Integer herausholen&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;bit8&lt;/span&gt; &amp;lt;= &lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;9&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;8&lt;/span&gt;);&lt;br /&gt;   &lt;br /&gt;   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- to_unsigned(i,1) gibt einen Vektor (0 downto 0) zurück&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- daraus wird dann das Bit 0 verwendet&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;bit9&lt;/span&gt; &amp;lt;= &lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span&gt;i&lt;/span&gt;/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;**&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;9&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;)(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;/pre&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;
 
    </content:encoded>

    <pubDate>Tue, 08 Dec 2009 06:23:00 +0100</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/65-guid.html</guid>
    
</item>
<item>
    <title>Vektor-Vergleich</title>
    <link>http://www.lothar-miller.de/s9y/archives/28-Vektor-Vergleich.html</link>
            <category>Numeric_Std</category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/28-Vektor-Vergleich.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=28</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.lothar-miller.de/s9y/rss.php?version=2.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Wie gerne möchte man in VDHL für einen &lt;b&gt;Vektorvergleich&lt;/b&gt; einfach wie bei einer Vektor-Zuweisung &lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt;: &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;);&lt;br /&gt;&lt;span&gt;vec&lt;/span&gt; &amp;lt;= (&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;others&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;);&lt;/pre&gt;&lt;p&gt;den (others =&amp;gt; &#039;0&#039;) Konstrukt verwenden und schreiben:&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;span&gt;erg&lt;/span&gt;  &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = (&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;others&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p /&gt;&lt;p /&gt;&lt;p&gt;Aber dann hagelt es bei Verwendung der genormten numeric_std nur Fehlermeldungen &lt;img src=&quot;http://www.lothar-miller.de/s9y/templates/default/img/emoticons/sad.png&quot; alt=&quot;:-(&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;Warum denn? &lt;br /&gt;Und wie kann ich das trotzdem so machen?&lt;br /&gt;&lt;br /&gt;Der einfache Grund warum dieser Vergleich nicht funktioniert, ist, dass der Wortbreitenqualifier für den Vektor fehlt. Der Synthesizer stellt sich also doof und sagt: Ich kann den linken Vektor &lt;br /&gt;nicht mit einem Vektor &lt;b&gt;unbekannter Breite&lt;/b&gt; vergleichen. &lt;/p&gt;&lt;p&gt;Also muß ihm das gesagt werden. So geht es mit &lt;b&gt;manueller Bereichsangabe&lt;/b&gt;:&lt;/p&gt;&lt;pre&gt;&lt;span&gt;erg&lt;/span&gt;  &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;/pre&gt;&lt;p&gt;Und so wird automatisch der &lt;b&gt;Bereich des Vektors&lt;/b&gt; verwendet:&lt;/p&gt;&lt;pre&gt;&lt;span&gt;erg&lt;/span&gt;  &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = (&lt;span&gt;vec&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;r&lt;/span&gt;&lt;span&gt;ange&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;/pre&gt;&lt;p&gt;Natürlich gilt das vorherige auch für if-Abfragen und i.A. für Vergleiche.&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = (&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;downto&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;=&amp;gt;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;..&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = (&lt;span&gt;vec&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;r&lt;/span&gt;&lt;span&gt;ange&lt;/span&gt; =&amp;gt;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;..&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;Ein Vergleich mit einem &lt;b&gt;Zahlenwert &lt;/b&gt;muß bei Verwendung der numeric_std ein wenig konvertiert und gecastet werden. Hier wird einfach die Wortbreite (&#039;length) des Vektors angegeben:&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span&gt;vec&lt;/span&gt; = &lt;span style=&quot;color: rgb(51, 68, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;to_unsigned&lt;/span&gt;( &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; ,&lt;span&gt;vec&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;&lt;span&gt;ength&lt;/span&gt;)) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;...&lt;/pre&gt;
 
    </content:encoded>

    <pubDate>Thu, 08 Oct 2009 20:13:00 +0200</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/28-guid.html</guid>
    
</item>
<item>
    <title>Numeric_Std</title>
    <link>http://www.lothar-miller.de/s9y/archives/14-Numeric_Std.html</link>
            <category>Numeric_Std</category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/14-Numeric_Std.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=14</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.lothar-miller.de/s9y/rss.php?version=2.0&amp;type=comments&amp;cid=14</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Die gerne noch verwendeten Quasi-Industrie-Standards der Synopsys-Lib sind schon geraume Zeit obsolete. &lt;/p&gt;&lt;p&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;library IEEE;&lt;br /&gt;use IEEE.STD_LOGIC_1164.ALL;&lt;br /&gt;use IEEE.STD_LOGIC_ARITH.ALL;&lt;br /&gt;use IEEE.STD_LOGIC_UNSIGNED.ALL;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;Statt dessen sollte die Numeric_Std Library verwendet werden. Diese ist herstellerunabhängig und über IEEE 1076.3 genormt.&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;library IEEE;&lt;br /&gt;use IEEE.STD_LOGIC_1164.ALL;&lt;br /&gt;use IEEE.NUMERIC_STD.ALL;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Hier eine kurze Übersicht, wie die Datentypen &lt;font color=&quot;#0000ff&quot;&gt;signed &lt;/font&gt;und &lt;font color=&quot;#0000ff&quot;&gt;unsigned &lt;/font&gt;zwischen &lt;font color=&quot;#0000ff&quot;&gt;integer &lt;/font&gt;und &lt;font color=&quot;#0000ff&quot;&gt;std_logic_vector&lt;/font&gt; sitzen.  
&lt;/p&gt;&lt;p&gt;&lt;a class=&quot;serendipity_image_link&quot; href=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Usage_of_numeric_std.pdf&quot; onclick=&quot;F1 = window.open(&#039;/s9y/uploads/Bilder/Usage_of_numeric_std.pdf&#039;,&#039;Zoom&#039;,&#039;height=579,width=615,top=318,left=500,toolbar=no,menubar=no,location=no,resize=1,resizable=1,scrollbars=yes&#039;); return false;&quot;&gt;&lt;!-- s9ymdb:31 --&gt;&lt;img width=&quot;600&quot; height=&quot;564&quot; class=&quot;serendipity_image_center&quot; style=&quot;border: 0px none; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Usage_of_numeric_std.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Von &lt;b&gt;&lt;font color=&quot;#0000cc&quot;&gt;std_logic_vector&lt;/font&gt; nach &lt;font color=&quot;#0000cc&quot;&gt;signed/unsigned&lt;/font&gt;&lt;/b&gt; und zurück wird &amp;quot;nur&amp;quot; gecastet mit singed(), unsigned() und std_logic_vector().

&lt;br /&gt;&lt;br /&gt;Von &lt;b&gt;&lt;font color=&quot;#0000cc&quot;&gt;signed/unsigned&lt;/font&gt; nach &lt;font color=&quot;#0000cc&quot;&gt;integer&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#0000cc&quot;&gt; &lt;/font&gt;und zurück wird konvertiert, das ist leicht zu erkennen an dem Prefix &amp;quot;to_&amp;quot; bei to_signed(), to_unsigned() und to_integer().&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Tue, 14 Oct 2008 08:07:44 +0200</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/14-guid.html</guid>
    
</item>

</channel>
</rss>
