<?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 - Rechnen </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>Wed, 31 Aug 2011 07:38:27 GMT</pubDate>

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

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

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Hier jetzt mal eine Umsetzung des allseits bekannten Bubblesort-Algorithmus in VHDL. &lt;br /&gt;Zuerst die rein kombinatorische Variante:&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; IEEE;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.STD_LOGIC_1164.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;all&lt;/span&gt;;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;package&lt;/span&gt; BSTypes &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
  &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;type&lt;/span&gt; BSData_Typ &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;array&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;9&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 119, 68); 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;127&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; BSTypes;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;package&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;body&lt;/span&gt; BSTypes &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; BSTypes;




&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; IEEE;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.STD_LOGIC_1164.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.NUMERIC_STD.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; work.bstypes.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;all&lt;/span&gt;;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;entity&lt;/span&gt; Bubblesort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( di  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  BSData_Typ;
           do  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt; BSData_Typ );
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; Bubblesort;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;architecture&lt;/span&gt; Behavioral &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; Bubblesort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&gt;

   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;process&lt;/span&gt; (di) 
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; din  : BSData_Typ;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; temp : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;integer&lt;/span&gt;;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; n    : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;integer&lt;/span&gt;;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; oncemore : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;boolean&lt;/span&gt;;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&gt;
      din      := di;
      n        := din&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;ength;
      oncemore := TRUE;
      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;while&lt;/span&gt; oncemore = TRUE &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;and&lt;/span&gt; n &amp;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;loop&lt;/span&gt;
         oncemore := FALSE;
         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&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; din&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;ength-&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, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;
            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; din(i) &amp;gt; din(i+&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;then&lt;/span&gt; 
               temp     := din(i);   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Dreieckstausch&lt;/span&gt;
               din(i)   := din(i+&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;);
               din(i+&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;) := temp;
               oncemore := TRUE;
            &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;if&lt;/span&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;loop&lt;/span&gt;;
         n := n-&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;end&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;;
      do &amp;lt;= din;
   &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;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; Behavioral;&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;In einem Spartan 3 FPGA braucht diese Lösung abhängig vom Abbruch (über die Variable oncemore) unterschiedlich viele Ressourcen:&lt;br /&gt;Mit Abbruch:      Number of Slices  1293         Number of 4 input LUTs 2272&lt;br /&gt;Ohne Abbruch:   Number of Slices  976           Number of 4 input LUTs 1701&lt;/p&gt;&lt;p&gt;Der offensichtlichste Unterschied ist, dass der in der Software effizientere Abbruch (wenn das Array schon vor Ablauf aller Kombinationen schon komplett sortiert ist) in der Hardware nur Nachteile mit sich bringt.&lt;/p&gt;&lt;p&gt;Nachfolgend eine getaktete Lösung, die auf Kosten der Rechenzeit deutlich weniger Ressourcen braucht. &lt;a href=&quot;http://www.lothar-miller.de/s9y/uploads/Bubblesort.zip&quot; title=&quot;Bubblesort.zip&quot; target=&quot;_blank&quot;&gt;Bubblesort.zip&lt;/a&gt;&lt;br /&gt;Insbesondere fällt hier der Unterschied zwischen der Variante mit und der ohneAbbruch wesentlich geringer aus:&lt;br /&gt;Mit Abbruch:      Number of Slices  168           Number of 4 input LUTs 250&lt;br /&gt;Ohne Abbruch:   Number of Slices  167           Number of 4 input LUTs 245&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Typdefinition BSData_Typ s.o.&lt;/span&gt;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; IEEE;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.STD_LOGIC_1164.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.NUMERIC_STD.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; work.bstypes.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;all&lt;/span&gt;;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;entity&lt;/span&gt; Bubblesort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( di    : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  BSData_Typ;
           do    : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt; BSData_Typ;
           start : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;std_logic&lt;/span&gt;;
           done  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;std_logic&lt;/span&gt;;
           clk   : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;std_logic&lt;/span&gt;);
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; Bubblesort;

&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;architecture&lt;/span&gt; Behavioral &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; Bubblesort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; busy     : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;boolean&lt;/span&gt; := FALSE;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; din      : BSData_Typ;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; n,i      : &lt;span style=&quot;color: rgb(0, 119, 68); 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; din&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;ength;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&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;variable&lt;/span&gt; temp : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;integer&lt;/span&gt;;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&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; rising_edge(clk);
      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (busy=FALSE) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;
         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (start=&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;then&lt;/span&gt;
            din  &amp;lt;= di;
            busy &amp;lt;= TRUE;
            n    &amp;lt;= &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;;
            i    &amp;lt;= &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;end&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&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, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (n &amp;lt; din&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;ength) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;
            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (i&amp;lt;din&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;l&lt;/span&gt;ength-&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;then&lt;/span&gt;
               &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; din(i) &amp;gt; din(i+&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;then&lt;/span&gt;
                  temp     := din(i);   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Dreieckstausch&lt;/span&gt;
                  din(i)   &amp;lt;= din(i+&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;);
                  din(i+&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;) &amp;lt;= temp;
               &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;if&lt;/span&gt;;
               i &amp;lt;= i+&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;else&lt;/span&gt;
               i &amp;lt;= &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;;
               n &amp;lt;= n+&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;end&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt;;
         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt;
            busy &amp;lt;= FALSE;       
            do   &amp;lt;= din;
         &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;if&lt;/span&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;if&lt;/span&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;;
   
   done &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; start=&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;and&lt;/span&gt; busy=FALSE &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 style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; Behavioral;&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;Das ist die Testbench für die kombinatorische Variante:&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;LIBRARY&lt;/span&gt; ieee;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;USE&lt;/span&gt; ieee.std_logic_1164.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;USE&lt;/span&gt; ieee.numeric_std.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ALL&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; ieee.math_real.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;all&lt;/span&gt;;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; work.bstypes.&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;all&lt;/span&gt;;
 
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ENTITY&lt;/span&gt; tb_BubbleSort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;IS&lt;/span&gt;
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;END&lt;/span&gt; tb_BubbleSort;
 
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;ARCHITECTURE&lt;/span&gt; behavior &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;OF&lt;/span&gt; tb_BubbleSort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;IS&lt;/span&gt; 
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;COMPONENT&lt;/span&gt; Bubblesort
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( di  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;  BSData_Typ;
           do  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt; BSData_Typ );
    &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;COMPONENT&lt;/span&gt;;

   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;--Inputs&lt;/span&gt;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; di : BSData_Typ := (&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, 0, 221); font-weight: bold;&quot;&gt;6&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;8&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, 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;4&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&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;0&lt;/span&gt;);
   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;--Outputs&lt;/span&gt;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; do : BSData_Typ;
   
&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;BEGIN&lt;/span&gt;
  &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Instantiate the Unit Under Test (UUT)&lt;/span&gt;
   uut: Bubblesort &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;PORT&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;MAP&lt;/span&gt; (
          di =&amp;gt; di,
          do =&amp;gt; do
        );

   &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Stimulus process&lt;/span&gt;
   stim_proc: &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;variable&lt;/span&gt; rand  : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;real&lt;/span&gt;;
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; seed1 : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;positive&lt;/span&gt; := &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;234&lt;/span&gt;;
    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; seed2 : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;positive&lt;/span&gt; := &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;567&lt;/span&gt;;
   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;begin&lt;/span&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;100&lt;/span&gt; ns;  
      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;
         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&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;9&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;
            UNIFORM(seed1, seed2, rand);
            di(i) &amp;lt;= &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;integer&lt;/span&gt;(TRUNC(rand*&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: rgb(102, 0, 238); font-weight: bold;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: rgb(102, 0, 238); font-weight: bold;&quot;&gt;.999&lt;/span&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;loop&lt;/span&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;10&lt;/span&gt; ns;
         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&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;8&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;
            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;assert&lt;/span&gt; do(i)&amp;lt;=do(i+&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;report&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;Falsche Reihenfolge!&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;severity&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;failure&lt;/span&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;loop&lt;/span&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;loop&lt;/span&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;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;END&lt;/span&gt;;&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;Und das kommt dabei heraus:&lt;/p&gt;&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 711px;&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:147 --&gt;&lt;img height=&quot;104&quot; width=&quot;711&quot; class=&quot;serendipity_image_center&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/BubblesortKomb.gif&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;Waveform der Testbench für den kombinatorischen Sortierer&lt;/div&gt;&lt;/div&gt;&lt;p /&gt;&lt;p /&gt;&lt;p&gt;&lt;br /&gt;Und hier können die Dateien gezippt heruntergeladen werden: &lt;b&gt;&lt;a target=&quot;_blank&quot; title=&quot;Bubblesort.zip&quot; href=&quot;http://www.lothar-miller.de/s9y/uploads/Bubblesort.zip&quot;&gt;Bubblesort.zip&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;





 
    </content:encoded>

    <pubDate>Thu, 21 Apr 2011 11:22:18 +0200</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/78-guid.html</guid>
    
</item>
<item>
    <title>Wurzel in VHDL</title>
    <link>http://www.lothar-miller.de/s9y/archives/73-Wurzel-in-VHDL.html</link>
            <category>Rechnen </category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/73-Wurzel-in-VHDL.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=73</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=73</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Eine Wurzel zu ziehen kann recht aufwendig sein. Erschwert wird das Ganze, wenn es in VHDL geschehen soll. Hier eine Gegenüberstellung des Ressourcenverbrauchs einer rein kombinatorischen Lösung verglichen mit einer sequentiellen getakteten Variante in einem Xilinx Spartan3 XC3S200 FPGA. &lt;br /&gt;&lt;br /&gt;Hier als Bezugspunkt die parallel implementierte kombinatorische Lösung:&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; IEEE;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.STD_LOGIC_1164.&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; IEEE.NUMERIC_STD.&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; SQRT &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;Generic&lt;/span&gt; ( b  : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;natural&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;4&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;32&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(136, 136, 136);&quot;&gt;-- Breite &lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( value  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;   &lt;span style=&quot;color: rgb(0, 119, 68); 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;           result : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 119, 68); 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;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;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; SQRT;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;architecture&lt;/span&gt; Behave &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; SQRT &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;begin&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;process&lt;/span&gt; (value)&lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; vop  : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;variable&lt;/span&gt; vres : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;variable&lt;/span&gt; vone : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;begin&lt;/span&gt;&lt;br /&gt;      vone := to_unsigned(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;**(b-&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;),b);&lt;br /&gt;      vop  := &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(value);&lt;br /&gt;      vres := (&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;br /&gt;      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;while&lt;/span&gt; (vone /= &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;loop&lt;/span&gt;&lt;br /&gt;         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (vop &amp;gt;= vres+vone) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;            vop   := vop - (vres+vone);&lt;br /&gt;            vres  := vres/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt; + vone;&lt;br /&gt;         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;            vres  := vres/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&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;if&lt;/span&gt;;&lt;br /&gt;         vone := vone/&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 style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;loop&lt;/span&gt;;&lt;br /&gt;      result &amp;lt;= &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(vres(result&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;r&lt;/span&gt;ange));&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;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt;;&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;Mit diesem Ansatz ergibt sich folgender Ressourcenbedarf:&lt;/p&gt;&lt;p /&gt;&lt;div style=&quot;width: 586px;&quot; class=&quot;serendipity_imageComment_center&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:133 --&gt;&lt;img height=&quot;248&quot; width=&quot;586&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Ressourcen_komb.gif&quot; class=&quot;serendipity_image_center&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;So eine Wurzel braucht schon Platz...&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p /&gt;&lt;p&gt;Und jetzt zum Vergleich die Variante mit der getakteten Berechnung der Wurzel:&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;library&lt;/span&gt; IEEE;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;use&lt;/span&gt; IEEE.STD_LOGIC_1164.&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; IEEE.NUMERIC_STD.&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; SQRT &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;Generic&lt;/span&gt; ( b  : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;natural&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;4&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;32&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(136, 136, 136);&quot;&gt;-- Breite &lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;Port&lt;/span&gt; ( clk    : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;   &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;STD_LOGIC&lt;/span&gt;;&lt;br /&gt;           start  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;   &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;STD_LOGIC&lt;/span&gt;;&lt;br /&gt;           value  : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;in&lt;/span&gt;   &lt;span style=&quot;color: rgb(0, 119, 68); 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;           result : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 119, 68); 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;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;0&lt;/span&gt;);&lt;br /&gt;           busy   : &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;out&lt;/span&gt;  &lt;span style=&quot;color: rgb(0, 119, 68); 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; SQRT;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;architecture&lt;/span&gt; Behave &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; SQRT &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; op  : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; res : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; one : &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(b-&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; bits : &lt;span style=&quot;color: rgb(0, 119, 68); 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; b &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;type&lt;/span&gt; zustaende &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt; (idle, shift, calc, done);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;signal&lt;/span&gt; z : zustaende;&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;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; rising_edge(clk);&lt;br /&gt;      &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;case&lt;/span&gt; z &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; idle =&amp;gt; &lt;br /&gt;            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (start=&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;then&lt;/span&gt; &lt;br /&gt;               z &amp;lt;= shift; &lt;br /&gt;               busy &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;if&lt;/span&gt;;&lt;br /&gt;            one &amp;lt;= to_unsigned(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;**(b-&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;),b);&lt;br /&gt;            op  &amp;lt;= &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(value);&lt;br /&gt;            res &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;br /&gt;&lt;br /&gt;         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; shift =&amp;gt;&lt;br /&gt;            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (one &amp;gt; op) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;               one &amp;lt;= one/&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;else&lt;/span&gt;&lt;br /&gt;               z   &amp;lt;= calc;&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;if&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; calc =&amp;gt;&lt;br /&gt;            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (one /= &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;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; (op &amp;gt;= res+one) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;                  op   &amp;lt;= op - (res+one);&lt;br /&gt;                  res  &amp;lt;= res/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt; + one;&lt;br /&gt;               &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;                  res  &amp;lt;= res/&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&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;if&lt;/span&gt;;&lt;br /&gt;               one &amp;lt;= one/&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;else&lt;/span&gt;&lt;br /&gt;               z    &amp;lt;= done;&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;if&lt;/span&gt;;&lt;br /&gt;            &lt;br /&gt;         &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;when&lt;/span&gt; done =&amp;gt;&lt;br /&gt;            busy &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Handshake: wenn nötig warten, bis start=&#039;0&#039;&lt;/span&gt;&lt;br /&gt;            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;if&lt;/span&gt; (start=&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;               z &amp;lt;= idle; &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;if&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;   result &amp;lt;= &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(res(result&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;r&lt;/span&gt;ange));&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt;;&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;Das Design Summary zeigt jetzt einen deutlich kleineren Ressourcenverbrauch an, wobei der Verbrauch an Slices insgesamt nicht mal so sehr viel höher ist:&lt;/p&gt;&lt;p /&gt;&lt;div style=&quot;width: 655px;&quot; class=&quot;serendipity_imageComment_center&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:134 --&gt;&lt;img height=&quot;292&quot; width=&quot;655&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Ressourcen_synchron.gif&quot; class=&quot;serendipity_image_center&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;... aber es geht auch wesentlich kompakter&lt;/div&gt;&lt;/div&gt;&lt;p /&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;p&gt;&lt;br /&gt;Die Wurzelberechnung basiert auf diesem C Code:&lt;/p&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;int&lt;/span&gt; sqrt(&lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;int&lt;/span&gt; num) {&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;int&lt;/span&gt; op = num;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 119, 68); font-weight: bold;&quot;&gt;int&lt;/span&gt; res = &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, 119, 68); font-weight: bold;&quot;&gt;int&lt;/span&gt; one = &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;30&lt;/span&gt;; &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;// The second-to-top bit is set: 1L&amp;lt;&amp;lt;30 for long&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;// &amp;quot;one&amp;quot; starts at the highest power of four &amp;lt;= the argument.&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;while&lt;/span&gt; (one &amp;gt; op)&lt;br /&gt;        one &amp;gt;&amp;gt;= &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;;&lt;br /&gt;   &lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;while&lt;/span&gt; (one != &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;if&lt;/span&gt; (op &amp;gt;= res + one) {&lt;br /&gt;            op -= res + one;&lt;br /&gt;            res += &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt; * one;&lt;br /&gt;        }&lt;br /&gt;        res &amp;gt;&amp;gt;= &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;        one &amp;gt;&amp;gt;= &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;2&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;return&lt;/span&gt; res;&lt;br /&gt;}&lt;/pre&gt;&lt;hr size=&quot;2&quot; width=&quot;100%&quot; /&gt;&lt;pre&gt;&lt;font face=&quot;verdana,arial,geneva,helvetica,sans-serif&quot;&gt;&lt;/font&gt;&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Tue, 03 Aug 2010 18:44:00 +0200</pubDate>
    <guid isPermaLink="false">http://www.lothar-miller.de/s9y/archives/73-guid.html</guid>
    
</item>
<item>
    <title>Division in VHDL</title>
    <link>http://www.lothar-miller.de/s9y/archives/29-Division-in-VHDL.html</link>
            <category>Rechnen </category>
    
    <comments>http://www.lothar-miller.de/s9y/archives/29-Division-in-VHDL.html#comments</comments>
    <wfw:comment>http://www.lothar-miller.de/s9y/wfwcomment.php?cid=29</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=29</wfw:commentRss>
    

    <author>nospam@example.com (Lothar Miller)</author>
    <content:encoded>
    
&lt;p&gt;Immer wieder braucht man trotz allen Tricks einen Divisionsalgorithmus in VHDL. Leider geht das nicht so einfach wie eine Addition oder eine Multiplikation. Mit irgendwelchen Tools erzeugte Algorithmen sind u.U. nicht so ohne weiteres nicht portierbar, oder man möchte einfach nur mal sehen, wie sowas geht.&lt;/p&gt;&lt;p&gt;Hier habe ich eine Integer Division, die unter dem Namen Radix-2 Division bekannt ist, implementiert. Dieser Algorhtimus benötigt einen Rechenschritt pro Bit. Siehe dazu auch &lt;a href=&quot;http://www.informatik.uni-ulm.de/ni/Lehre/WS02/CA/ArithIntegerE.PDF&quot; target=&quot;_blank&quot; title=&quot;Integer Division&quot;&gt;hier bei der Uni Ulm.&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Eine Division ist an sich nur eine wiederholte Subtraktion. Ähnlich wie in der schriftlichen Division, die wir aus der Schule kennen, beginnt auch die binäre Division bei den höchstwertigen Stellen und gibt pro Rechenschritt eine weitere Quotientenstelle aus. Der Divisionsweg teilt sich in in zwei Abschnitte auf:&lt;br /&gt;1) Scheibe die oberen Bits des Dividenden in den Rest&lt;br /&gt;2) Ziehe den Divisor von dem Wert im Rest ab. &lt;br /&gt;    Das MSB dieser Subtraktion wird ein Bit im Quotienten.&lt;/p&gt;&lt;p&gt; Dividend&lt;br /&gt;---------- = Quotient und Rest&lt;br /&gt; Divisor&lt;/p&gt;&lt;p&gt;Gestartet wird die Division, nachdem der Dividend und der Divisor zugewiesen wurden, mit dem Signal start=&#039;1&#039;. Es reicht aus, wenn start für einen Taktzyklus aktiv ist. Während der Division ist busy=&#039;1&#039;, zum Abschluss der Division wird start kontrolliert und ggf. gewartet, bis start wieder auf &#039;0&#039; gegangen ist.&lt;/p&gt;&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;Divider&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;Generic&lt;/span&gt; ( &lt;span&gt;b&lt;/span&gt;  : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;natural&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;4&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;32&lt;/span&gt; := &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&lt;/span&gt; ); &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Breite &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;start&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;divisor&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_VECTOR&lt;/span&gt; (&lt;span&gt;b&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&gt;dividend&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_VECTOR&lt;/span&gt; (&lt;span&gt;b&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&gt;quotient&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&gt;b&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&gt;remainder&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&gt;b&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&gt;busy&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&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 style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;end&lt;/span&gt; &lt;span&gt;Divider&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;Behave_Unsigned&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;of&lt;/span&gt; &lt;span&gt;Divider&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;dd&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;b&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- dividend&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;dr&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;b&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- divisor&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;q&lt;/span&gt;  : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;b&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- qoutient&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;r&lt;/span&gt;  : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;b&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;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- remainder&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;bits&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 51, 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&gt;b&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;type&lt;/span&gt; &lt;span&gt;zustaende&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;is&lt;/span&gt; (&lt;span&gt;idle&lt;/span&gt;, &lt;span&gt;prepare&lt;/span&gt;, &lt;span&gt;shift&lt;/span&gt;, &lt;span&gt;sub&lt;/span&gt;, &lt;span&gt;done&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;z&lt;/span&gt; : &lt;span&gt;zustaende&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;br /&gt;   &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;variable&lt;/span&gt; &lt;span&gt;diff&lt;/span&gt; : &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;b&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;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;case&lt;/span&gt; &lt;span&gt;z&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;idle&lt;/span&gt; =&amp;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;start&lt;/span&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;then&lt;/span&gt; &lt;br /&gt;               &lt;span&gt;z&lt;/span&gt; &amp;lt;= &lt;span&gt;prepare&lt;/span&gt;; &lt;br /&gt;               &lt;span&gt;busy&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;if&lt;/span&gt;;&lt;br /&gt;            &lt;span&gt;dd&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;dividend&lt;/span&gt;);&lt;br /&gt;            &lt;span&gt;dr&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;unsigned&lt;/span&gt;(&lt;span&gt;divisor&lt;/span&gt;);&lt;br /&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;prepare&lt;/span&gt; =&amp;gt;&lt;br /&gt;            &lt;span&gt;q&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;br /&gt;            &lt;span&gt;r&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;br /&gt;            &lt;span&gt;z&lt;/span&gt;    &amp;lt;= &lt;span&gt;shift&lt;/span&gt;;            &lt;br /&gt;            &lt;span&gt;bits&lt;/span&gt; &amp;lt;= &lt;span&gt;b&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Sonderfall: Division durch Null&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;dr&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;then&lt;/span&gt;  &lt;br /&gt;               &lt;span&gt;q&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;1&#039;&lt;/span&gt;);&lt;br /&gt;               &lt;span&gt;r&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;1&#039;&lt;/span&gt;);&lt;br /&gt;               &lt;span&gt;z&lt;/span&gt; &amp;lt;= &lt;span&gt;done&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;if&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Sonderfall: Divisor größer als Dividend&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;dr&lt;/span&gt;&amp;gt;&lt;span&gt;dd&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&gt;r&lt;/span&gt; &amp;lt;= &lt;span&gt;dd&lt;/span&gt;;&lt;br /&gt;               &lt;span&gt;z&lt;/span&gt; &amp;lt;= &lt;span&gt;done&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;if&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Sonderfall: Divisor gleich Dividend&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;dr&lt;/span&gt;=&lt;span&gt;dd&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&gt;q&lt;/span&gt; &amp;lt;= &lt;span&gt;to_unsigned&lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;,&lt;span&gt;b&lt;/span&gt;);&lt;br /&gt;               &lt;span&gt;z&lt;/span&gt; &amp;lt;= &lt;span&gt;done&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;if&lt;/span&gt;;&lt;br /&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;shift&lt;/span&gt; =&amp;gt;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- erst mal die beiden Operanden &lt;/span&gt;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- für die Subtraktion zurechtrücken&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;r&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&lt;/span&gt;-&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;)) &amp;lt; &lt;span&gt;dr&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&gt;bits&lt;/span&gt; &amp;lt;= &lt;span&gt;bits&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&gt;r&lt;/span&gt;    &amp;lt;= &lt;span&gt;r&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&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&gt;dd&lt;/span&gt;   &amp;lt;= &lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;               &lt;span&gt;z&lt;/span&gt;    &amp;lt;= &lt;span&gt;sub&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;if&lt;/span&gt;;&lt;br /&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;sub&lt;/span&gt; =&amp;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;bits&lt;/span&gt;&amp;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;then&lt;/span&gt;&lt;br /&gt;               &lt;span&gt;r&lt;/span&gt;    &amp;lt;= &lt;span&gt;r&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&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&gt;dd&lt;/span&gt;   &amp;lt;= &lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;br /&gt;               &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Rest minus Divisor&lt;/span&gt;&lt;br /&gt;               &lt;span&gt;diff&lt;/span&gt; := (&lt;span&gt;r&lt;/span&gt;(&lt;span&gt;b&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, 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;amp;&lt;span&gt;dd&lt;/span&gt;(&lt;span&gt;b&lt;/span&gt;-&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1&lt;/span&gt;)) - &lt;span&gt;dr&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;diff&lt;/span&gt;(&lt;span&gt;b&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, 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(136, 136, 136);&quot;&gt;-- wenn kein Unterlauf &lt;/span&gt;&lt;br /&gt;                  &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;--&amp;gt; Divisor passt noch rein &lt;/span&gt;&lt;br /&gt;                  &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;--&amp;gt; MSB=0 --&amp;gt; 1 in Ergebnis einschieben&lt;/span&gt;&lt;br /&gt;                  &lt;span&gt;q&lt;/span&gt; &amp;lt;= &lt;span&gt;q&lt;/span&gt;(&lt;span&gt;b&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, 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;amp; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;1&#039;&lt;/span&gt;;&lt;br /&gt;                  &lt;span&gt;r&lt;/span&gt; &amp;lt;= &lt;span&gt;diff&lt;/span&gt;;&lt;br /&gt;               &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;                  &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- wenn Unterlauf &lt;/span&gt;&lt;br /&gt;                  &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;--&amp;gt; 0 einschieben, mit altem Wert weiterrechnen&lt;/span&gt;&lt;br /&gt;                  &lt;span&gt;q&lt;/span&gt; &amp;lt;= &lt;span&gt;q&lt;/span&gt;(&lt;span&gt;b&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, 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;amp; &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#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;if&lt;/span&gt;;&lt;br /&gt;               &lt;span&gt;bits&lt;/span&gt; &amp;lt;= &lt;span&gt;bits&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;else&lt;/span&gt;&lt;br /&gt;               &lt;span&gt;z&lt;/span&gt;    &amp;lt;= &lt;span&gt;done&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;if&lt;/span&gt;;&lt;br /&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;done&lt;/span&gt; =&amp;gt;&lt;br /&gt;            &lt;span&gt;busy&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&lt;/span&gt;;&lt;br /&gt;            &lt;span style=&quot;color: rgb(136, 136, 136);&quot;&gt;-- Handshake: wenn nötig warten, bis start=&#039;0&#039;&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;start&lt;/span&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&gt;z&lt;/span&gt; &amp;lt;= &lt;span&gt;idle&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;if&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&gt;quotient&lt;/span&gt;  &amp;lt;= &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;q&lt;/span&gt;);&lt;br /&gt;   &lt;span&gt;remainder&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;&quot;&gt;std_logic_vector&lt;/span&gt;(&lt;span&gt;r&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;/pre&gt;&lt;p /&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;p&gt;Die 32 Bit Implementation der Division benötigt laut Syntheseergebnis folgende Ressourcen:&lt;br /&gt;Number of Slices 189&lt;br /&gt;Number of Slice Flip Flops 138&lt;br /&gt;Number of 4 input LUTs     358&lt;/p&gt;&lt;p&gt;Hier noch ein Auszug der Testbench mit den Sonderfällen am Anfang und einigen Divisionen danach.&lt;/p&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;pre&gt;  &lt;span&gt;clk&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;not&lt;/span&gt; &lt;span&gt;clk&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;after&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;3&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;   &lt;br /&gt;  &lt;span&gt;tb&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;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;BEGIN&lt;/span&gt;&lt;br /&gt;    &lt;span&gt;dividend&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;127&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&lt;/span&gt;));&lt;br /&gt;    &lt;span&gt;divisor&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;127&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&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;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;25&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;50&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;      &lt;br /&gt;    &lt;span&gt;dividend&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;127&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&lt;/span&gt;));&lt;br /&gt;    &lt;span&gt;divisor&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&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;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;25&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;50&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;      &lt;br /&gt;    &lt;span&gt;dividend&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;127&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&lt;/span&gt;));&lt;br /&gt;    &lt;span&gt;divisor&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;255&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&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;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;25&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;50&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;    &lt;span&gt;dividend&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;1023&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&lt;/span&gt;));&lt;br /&gt;    &lt;span&gt;divisor&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;128&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&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;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;25&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;222&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;assert&lt;/span&gt; (&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;quotient&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;report&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;Division fehlerhaft&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;severity&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;failure&lt;/span&gt;;      &lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;assert&lt;/span&gt; (&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;remainder&lt;/span&gt;))=&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;127&lt;/span&gt;) &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;report&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;Division fehlerhaft&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;severity&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;failure&lt;/span&gt;;      &lt;br /&gt;      &lt;br /&gt;    &lt;span&gt;dividend&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 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;32&lt;/span&gt;));&lt;br /&gt;    &lt;span&gt;divisor&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 style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;128&lt;/span&gt;,&lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;32&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;5&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&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;wait&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;25&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;start&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: rgb(0, 68, 221);&quot;&gt;&#039;0&#039;&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;for&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 221); font-weight: bold;&quot;&gt;222&lt;/span&gt; &lt;span&gt;ns&lt;/span&gt;;&lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;assert&lt;/span&gt; (&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;quotient&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;report&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;Division fehlerhaft&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;severity&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;failure&lt;/span&gt;;      &lt;br /&gt;    &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;assert&lt;/span&gt; (&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;remainder&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;report&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;Division fehlerhaft&lt;/span&gt;&lt;span style=&quot;color: rgb(119, 17, 0);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;severity&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 136, 0); font-weight: bold;&quot;&gt;failure&lt;/span&gt;;&lt;/pre&gt;&lt;hr width=&quot;100%&quot; size=&quot;2&quot; /&gt;&lt;p&gt;Das ganze sieht in der Wavedarstellung so aus:&lt;/p&gt;&lt;p /&gt;&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 800px;&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:90 --&gt;&lt;img width=&quot;800&quot; height=&quot;131&quot; class=&quot;serendipity_image_center&quot; src=&quot;http://www.lothar-miller.de/s9y/uploads/Bilder/Divider.gif&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;Waveform der 32-bit Division&lt;/div&gt;&lt;/div&gt;&lt;p /&gt;
 
    </content:encoded>

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

</channel>
</rss>
