<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dooba.net &#187; VHDL</title>
	<atom:link href="http://dooba.net/tag/vhdl/feed/" rel="self" type="application/rss+xml" />
	<link>http://dooba.net</link>
	<description>Tech, Science, Insanity</description>
	<lastBuildDate>Tue, 27 Jul 2010 03:21:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VHDL Reset</title>
		<link>http://dooba.net/2010/07/27/vhdl-reset/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vhdl-reset</link>
		<comments>http://dooba.net/2010/07/27/vhdl-reset/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 03:21:29 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VHDL]]></category>

		<guid isPermaLink="false">http://dooba.net/?p=234</guid>
		<description><![CDATA[In most HW systems you need a way to do a system reset, but you obviously don&#8217;t want your reset line to miss fire and kill your system. Also, you don&#8217;t want to deal with multiple resets due to bouncing. And depending on your operating environment, you may need to protect your resets from SEI&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>In most HW systems you need a way to do a system reset, but you obviously don&#8217;t want your reset line to miss fire and kill your system. Also, you don&#8217;t want to deal with multiple resets due to bouncing. And depending on your operating environment, you may need to protect your resets from SEI&#8217;s from radiation or whatever.</p>
<p>Below details a simple solution to debounce and enforce a minimum reset hold time in your code.</p>
<p>&#8212;&#8212;</p>
<p>I use Generics in my entity so I can set the sys clk rate and the minimum width for the reset pulse easily:</p>
<blockquote>
<div id="_mcePaste">entity rst_detect is</div>
<div id="_mcePaste">generic(</div>
<div id="_mcePaste">clk_rate_mhz : integer := 20000000;</div>
<div id="_mcePaste">min_width_us : integer := 10000</div>
<div id="_mcePaste">);</div>
<div id="_mcePaste">port(</div>
<div id="_mcePaste">clk     : in std_logic;</div>
<div id="_mcePaste">rst_in  : in std_logic;</div>
<div id="_mcePaste">rst_out : out std_logic</div>
<div id="_mcePaste">);</div>
<div id="_mcePaste">end entity</div>
</blockquote>
<blockquote><p>architecture rtl of por_detect is</p>
<p>&#8211; to get the minimum ticks for a valid por,</p>
<p>&#8211; find the ticks per 1MHz (or 1us) and then</p>
<p>&#8211; multiply by the min us value</p>
<p>constant MIN_TICKS : integer := integer(ceil(real((clk_rate_mhz/1000000)*min_width_us)));</p>
<p>&#8211; min bit width of the counter for to count to min_ticks</p>
<p>constant COUNTER_WID : integer := integer(ceil(log2(real(MIN_TICKS))));</p>
<p>constant MAX_COUNT : integer := integer((2**COUNTER_WID) &#8211; 1);</p>
<p>signal count : std_logic_vector(COUNTER_WID &#8211; 1 downto 0) := (others =&gt; &#8217;0&#8242;);</p>
<p>&#8211;start and stop counter vals</p>
<p>signal s_count : std_logic_vector(COUNTER_WID &#8211; 1 downto 0);</p>
<p>type   por_state_t is (POR_IDLE, POR_WAIT, POR_OUTPUT);</p>
<p>signal por_state : por_state_t := POR_IDLE;</p>
<p>begin</p>
<p>counter : process(clk) begin</p>
<p>if(rising_edge(clk)) then</p>
<p>count &lt;= count + 1;</p>
<p>end if;</p>
<p>end process;</p>
<p>por_det : process(clk) begin</p>
<p>if(rising_edge(clk)) then</p>
<p>case por_state is</p>
<p>when POR_IDLE =&gt;</p>
<p>por_out &lt;= &#8217;0&#8242;;</p>
<p>if(por_in = &#8217;1&#8242;) then</p>
<p>s_count   &lt;= count;</p>
<p>por_state &lt;= POR_WAIT;</p>
<p>else</p>
<p>por_state &lt;= POR_IDLE;</p>
<p>end if;</p>
<p>when POR_WAIT =&gt;</p>
<p>if(por_in = &#8217;0&#8242;) then</p>
<p>por_state &lt;= POR_IDLE;</p>
<p>else</p>
<p>if(count &gt; s_count) then</p>
<p>if(count &#8211; s_count &gt;= MIN_TICKS) then</p>
<p>por_out   &lt;= &#8217;1&#8242;;</p>
<p>por_state &lt;= POR_OUTPUT;</p>
<p>else</p>
<p>por_state &lt;= POR_WAIT;</p>
<p>end if;</p>
<p>else</p>
<p>if((MAX_COUNT &#8211; s_count) + count &gt;= MIN_TICKS) then</p>
<p>por_out   &lt;= &#8217;1&#8242;;</p>
<p>por_state &lt;= POR_OUTPUT;</p>
<p>else</p>
<p>por_state &lt;= POR_WAIT;</p>
<p>end if;</p>
<p>end if;</p>
<p>end if;</p>
<p>when POR_OUTPUT =&gt;</p>
<p>if(por_in = &#8217;0&#8242;) then</p>
<p>por_out &lt;= &#8217;0&#8242;;</p>
<p>por_state &lt;= POR_IDLE;</p>
<p>else</p>
<p>por_state &lt;= POR_OUTPUT;</p>
<p>end if;</p>
<p>when others =&gt;</p>
<p>por_out   &lt;= &#8217;0&#8242;;</p>
<p>por_state &lt;= POR_IDLE;</p>
<p>end case;</p>
<p>end if;<br />
end process;</p>
<p>end architecture rtl</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dooba.net/2010/07/27/vhdl-reset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VHDL inferred gating</title>
		<link>http://dooba.net/2010/02/03/vhdl-inferred-gating/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vhdl-inferred-gating</link>
		<comments>http://dooba.net/2010/02/03/vhdl-inferred-gating/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 06:46:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Xilinx]]></category>
		<category><![CDATA[VHDL]]></category>

		<guid isPermaLink="false">http://dooba.net/2010/02/vhdl-inferred-gating/</guid>
		<description><![CDATA[So this was an interesting find. We have been working with a rather large VHDL code base, and noticed a huge amount of control logic was being generated during synthesis. It seems that part of this is due to an interesting &#8220;feature&#8221; of VHDL, or I suppose more exactly of synthesis tools (we saw this [...]]]></description>
			<content:encoded><![CDATA[<p>So this was an interesting find. We have been working with a rather large VHDL code base, and noticed a huge amount of control logic was being generated during synthesis. It seems that part of this is due to an interesting &#8220;feature&#8221; of VHDL, or I suppose more exactly of synthesis tools (we saw this with XST and Synplicity).</p>
<p>If you have some case statement, if then else, or switch, etc. Look carefully at signal assignments in each of the various cases. We were not always assigning to each signal in every case. This obviously follows from different cases doing different things.. but here is the tricky part. Clock gating and/or registering of signals is *inferred* for any signal that is not assigned to in all cases!</p>
<p>This can eat up logic fast, and if you are running near capacity of your target device, it can make it even worse, the added logic, clocking, and routing can cause the implementation to balloon. For example targeting an LX110-T, if we went above ~80% utilization, by the time we got through mapping and place&amp;route we were close to 95%. The only way we could account for this was the extra logic used for the inferred control signals.</p>
<p>This may not matter in a lot of designs where you have plenty of room in the part, or maybe you don&#8217;t for some reason have a lot of case statements. We ended up refactoring and just assigning a signal to itself or some don&#8217;t care value in the other cases.</p>
]]></content:encoded>
			<wfw:commentRss>http://dooba.net/2010/02/03/vhdl-inferred-gating/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
