<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" 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/"><channel><title>VHDL PWM generator with dead time: the design</title><link>/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><description>I posted a series of FPGA blogs. They focus on the toolchains and steps to get a working design.
A common theme in those articles is the VHDL source. Each time, it&amp;#39;s a PWM generator.
A specific kind of PWM block: it can generate complementary output </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Mon, 21 Jun 2021 15:46:01 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>wolfgangfriedrich</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Overall a great example how simple it is to implement functionality in VHDL.&lt;/p&gt;&lt;p&gt;2 things I would like to mention to make it even better. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;1) The module is missing a reset signal, to make it start at a defined state.&lt;/p&gt;&lt;p&gt;Something like this (updated lines 3,17,18,19:&lt;/p&gt;&lt;ol start="1"&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;entity Pwm is&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp; port (&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; n_reset_i : in&amp;nbsp; &lt;span&gt;std_logic;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- async reset&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clk_i&amp;nbsp; : in&amp;nbsp; std_logic;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- Input clock.&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; duty_i : in&amp;nbsp; std_logic_vector (7 downto 0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- Duty-cycle input.&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; band_i : in&amp;nbsp; std_logic_vector (3 downto 0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- number of clock-ticks to keep both signals low before rising edge&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwmA_o&amp;nbsp; : out std_logic;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- PWM output.&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwmB_o&amp;nbsp; : out std_logic&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- PWM output inverse.&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;end entity;&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;architecture arch of Pwm is&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp; signal timer_r&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : natural range 0 to 2**duty_i&amp;#39;length-1;&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;begin&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp; process(clk_i)&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp; begin&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if n_reset_i = &amp;#39;0&amp;#39; then&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer &amp;lt;= 0;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight:inherit;font-style:inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elsif rising_edge(clk_i) then&amp;nbsp; &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;2) It is good practice to have output signals of a module synchronous to its clock and not being straight from combinatorial logic. &lt;/p&gt;&lt;p&gt;The first attempt &amp;quot;Full VHDL&amp;quot; had all logic description encased by the &amp;#39;if (rising_edge(clk_i)&amp;#39;, which generates flipflops for each signal.&lt;/p&gt;&lt;p&gt;The latest version (in the comments) has only the timer_r sync to the input clock and the outputs are generated from logic only. &lt;/p&gt;&lt;p&gt;This can cause timing issues when you use those signals for more logic operations outside the module before going through the next register. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I hope this makes sense.&lt;/p&gt;&lt;p&gt;- W.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Sun, 20 Jun 2021 17:00:53 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>jc2048</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I should probably stop doing this, but here&amp;#39;s one more for luck. This is on a VIDOR 4000 (a Cyclone 10 FPGA).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x349/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/0116.contentimage_5F00_208435.png:620:349]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/600x450/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/3568.contentimage_5F00_208436.jpg:600:450]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/480x234/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/2063.contentimage_5F00_208437.png:480:234]&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Thu, 17 Jun 2021 17:37:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The Zynq approach is interesting. I didn&amp;#39;t have a clue when I got the board.&lt;/p&gt;&lt;p&gt;I knew it was a processor and FPGA combination on a single chip. But sceptic on the value of that.&lt;/p&gt;&lt;p&gt;I thought that the Linux part would distract from the FPGA part. After working with the board, I realised that isn&amp;#39;t true.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;There is (maybe unintended) value when learning VHDL/Verilog: It&amp;#39;s easier to create test beds for the custom bitstreams you are creating.&lt;/p&gt;&lt;p&gt;You can make a small component or large design. The Linux / Pynq combination allow to put that code to test fairly easy.&lt;/p&gt;&lt;p&gt;It took me a day to learn that, and I have a higher learning speed since that.&lt;/p&gt;&lt;p&gt;Part of that are the Jupyter books. They make it easy to write test scenarios and run them repeatedly.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The real &amp;quot;in production&amp;quot; value is that there is a close integration between the ARM processors and FPGA fabric.&lt;/p&gt;&lt;p&gt;I didn&amp;#39;t understand it after reading product overviews. I needed a hands-on to see it.&lt;/p&gt;&lt;p&gt;I can see these immediate values:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;you can write hardware designs that act as common peripherals. You control them from Linux via memory mapped register locations. Supports hardware interrupts.&lt;/li&gt;&lt;li&gt;Data steams both ways (with DMA!): an efficient stream between Linux and your FPGA designs&lt;/li&gt;&lt;li&gt;Speed up an application: implement algorithms in the FPGA - this is exciting: it&amp;#39;s possible to write C algorithms and convert them into FPGA designs. &lt;br /&gt;If your algorithm is processor-expensive and a candidate for this, you can speed up functions by executing them in hardware instead of CPU.&lt;br /&gt;There are examples of real time encryption/decryption and image processing.&lt;br /&gt;Works for intensive algorithms that don&amp;#39;t need OS functionality (file access, ...)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Thu, 17 Jun 2021 13:41:11 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>jc2048</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;VHDL is fairly portable at the level of the basic programmable logic. Here is Jan&amp;#39;s code moved to an Intel (Altera) device, a Max II CPLD (EPM240T100C5N). It&amp;#39;s very much less capable than the Xilinx part, with only 240 logic elements, but there&amp;#39;s enough room for something simple like this. Not having an inbuilt processor and not wanting to spend the time wiring up a real microcontroller to the CPLD, I cheated and set the duty and deadband to be fixed constants: not very useful in a real system, but fine for the illustration.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s the Quartus Lite screen after it had compiled successsfully&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x349/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/6131.contentimage_5F00_208432.png:620:349]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;here&amp;#39;s the board with the probes attached&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/600x450/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/4087.contentimage_5F00_208433.jpg:600:450]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;and here are the waveforms that are produced&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/480x234/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-19e2b967-6da5-4f5f-adb0-9122e09ee76d/7120.contentimage_5F00_208434.png:480:234]&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Mon, 14 Jun 2021 14:39:54 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>cstanton</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;For some reason I thought the code would look more obscure than it does...&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: VHDL PWM generator with dead time: the design</title><link>https://community.element14.com/technologies/fpga-group/b/blog/posts/vhdl-pwm-generator-with-dead-time-the-design</link><pubDate>Sun, 13 Jun 2021 19:33:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:19e2b967-6da5-4f5f-adb0-9122e09ee76d</guid><dc:creator>genebren</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Great PWM example code.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=11504&amp;AppID=19&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>