<?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 - when others</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>Mon, 23 Jan 2012 13:43:59 GMT</pubDate>

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

<item>
    <title>when others</title>
    <link>http://www.lothar-miller.de/s9y/archives/30-when-others.html</link>
            <category>when others</category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/30-when-others.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=30</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=30</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Was passiert eigentlich mit einem mit dem &lt;i&gt;&lt;b&gt;when others&lt;/b&gt;&lt;/i&gt; in einem &lt;i&gt;&lt;b&gt;case&lt;/b&gt;&lt;/i&gt;, in dem alle Zustände verwendet sind? Frisch ans Werk und ausprobiert. Man definiere sich ein paar Zustände, mache dann eine SM, und verwende alle diese Zustände und füge zusätzlich (zur Sicherheit) noch einen &lt;i&gt;when others&lt;/i&gt; Zweig mit einem &lt;i&gt;error &lt;/i&gt;Flag ein. So etwa:&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;SM_ueberdefiniert&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;clk&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, 51, 153); font-weight: bold;&quot;&gt;STD_LOGIC&lt;/span&gt;;&lt;br /&gt;           &lt;span&gt;leds&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, 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;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;error&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, 51, 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;end&lt;/span&gt; &lt;span&gt;SM_ueberdefiniert&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;SM_ueberdefiniert&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;type&lt;/span&gt; &lt;span&gt;dtyp&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt; (&lt;span&gt;aa&lt;/span&gt;, &lt;span&gt;ab&lt;/span&gt;, &lt;span&gt;ac&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;a&lt;/span&gt; : &lt;span&gt;dtyp&lt;/span&gt;;&lt;br /&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;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;process&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;until&lt;/span&gt; &lt;span&gt;rising_edge&lt;/span&gt;(&lt;span&gt;clk&lt;/span&gt;);&lt;br /&gt;      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;error&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;; &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- default&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;case&lt;/span&gt; &lt;span&gt;a&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;when&lt;/span&gt; &lt;span&gt;aa&lt;/span&gt; =&amp;gt; &lt;span&gt;a&lt;/span&gt;&amp;lt;=&lt;span&gt;ab&lt;/span&gt;; &lt;span&gt;leds&lt;/span&gt;&amp;lt;=&lt;span style=&quot;background-color: rgb(255, 240, 240);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 34, 0);&quot;&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(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span&gt;ab&lt;/span&gt; =&amp;gt; &lt;span&gt;a&lt;/span&gt;&amp;lt;=&lt;span&gt;ac&lt;/span&gt;; &lt;span&gt;leds&lt;/span&gt;&amp;lt;=&lt;span style=&quot;background-color: rgb(255, 240, 240);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 34, 0);&quot;&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(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; &lt;span&gt;ac&lt;/span&gt; =&amp;gt; &lt;span&gt;a&lt;/span&gt;&amp;lt;=&lt;span&gt;aa&lt;/span&gt;; &lt;span&gt;leds&lt;/span&gt;&amp;lt;=&lt;span style=&quot;background-color: rgb(255, 240, 240);&quot;&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 34, 0);&quot;&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(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; =&amp;gt; &lt;span&gt;a&lt;/span&gt;&amp;lt;=&lt;span&gt;aa&lt;/span&gt;; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;error&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&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 style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;case&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 style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;process&lt;/span&gt;;&lt;br /&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;&lt;p&gt;Was kommt bei der Synthese dabei heraus?&lt;br /&gt;Erst mal eine Warnung:&lt;/p&gt;&lt;pre&gt;&lt;font color=&quot;#0000cc&quot;&gt;WARNING:Xst:1710 - FF/Latch &amp;lt;error&amp;gt; has a constant value of 0 in block &amp;lt;SM_ueberdefiniert&amp;gt;.&lt;/font&gt;&lt;/pre&gt;&lt;p&gt;Und das schlägt sich dann auch im Syntheseergebnis nieder: &lt;br /&gt;&lt;i&gt;error &lt;/i&gt;wird einfach fest auf GND gelegt, weil der &lt;i&gt;others &lt;/i&gt;Zweig nicht behandelt wird.&lt;/p&gt;&lt;p&gt;&lt;!-- s9ymdb:53 --&gt;&lt;img height=&quot;329&quot; width=&quot;593&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/SM-ueberdefiniert-ausschnitt.gif&quot; /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Fazit&lt;/b&gt;:&lt;br /&gt;bei einer vollständig auscodierten Statemachine ist der &lt;i&gt;when others&lt;/i&gt; Zweig unnötig. Er wird von der Synthese ganz einfach ignoriert, und könnte bestenfalls im Quelltext für Verwirrung sorgen.&lt;br /&gt;&lt;br /&gt;ISE in der Version 13 lässt sich sogar zu einer Info herunter und sagt:&lt;br /&gt;&lt;font face=&quot;courier new,courier,monospace&quot; color=&quot;#990033&quot;&gt;INFO:HDLCompiler:679 - Case statement is complete. others clause is never selected&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Aber ACHTUNG:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;wenn man z.B. 4 Zustände mit einem 2 Bit breiten &lt;b&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;std_logic_vector&lt;/font&gt;&lt;/b&gt; auscodiert, dann hat man (für die Simulation) nicht nur &amp;quot;00&amp;quot;, &amp;quot;01&amp;quot;, &amp;quot;10&amp;quot; und &amp;quot;11&amp;quot;. Sondern man hat noch 77 andere Zustände (wie z.B. &amp;quot;XU&amp;quot;, &amp;quot;1-&amp;quot;, &amp;quot;ZH&amp;quot;, usw), weil ja &lt;b&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;std_logic&lt;/font&gt;&lt;/b&gt; eine 9-wertige Logik beschreibt, und mit 2 Stellen insgesamt 9x9=81 Zustände codierbar wären. &lt;br /&gt;Deshalb macht dort für die Simulation der &lt;i&gt;when others&lt;/i&gt; Pfad durchaus Sinn. Besser wäre es aber, Zustände einer FSM gar nicht manuell zu codieren, sondern dies (wie im obigen Beispiel) immer mit einem entsprechenden Typ erledigt, und so der Synthes Platz zur Optimierung lässt.&lt;br /&gt;&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Thu, 05 Feb 2009 21:02:00 +0100</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/30-guid.html</guid>
    
</item>

</channel>
</rss>
