<?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>Verilog PWM</title><link>/members-area/personalblogs/b/blog/posts/verilog-pwm</link><description>For an Assignment for university my class had to write a verilog program to produce a PWM output derived from the ASCII Value of our initials which can drive a servo.We were provided a sample verilog source from fpgas for fun, which was clear as mud,</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Verilog PWM</title><link>https://community.element14.com/members-area/personalblogs/b/blog/posts/verilog-pwm</link><pubDate>Fri, 06 Oct 2017 15:23:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:7e2be419-e1fc-4e1f-8d69-cca995fb620d</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;fpga4fun and KNJN are about the worst websites for learning unfortunately. Their examples all use knjn.com boards (probably a related website) which ship with no schematics, and deliberate information hiding. Plus, some of their example projects do not come with source. They are a commercial enterprise with little interest in education it seems. Definitely worth avoiding : (&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=3645&amp;AppID=293&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Verilog PWM</title><link>https://community.element14.com/members-area/personalblogs/b/blog/posts/verilog-pwm</link><pubDate>Fri, 06 Oct 2017 13:30:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:7e2be419-e1fc-4e1f-8d69-cca995fb620d</guid><dc:creator>michaelkellett</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;The original code is truly awful !&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You don&amp;#39;t mention any kind of reset - it is almost always a good thing to have a way of starting off in a known condition - hardware powers up as it likes - in FPGAs or ASICs you often need to set them up - so if this were my code there would be&amp;nbsp; away of making sure that the counters start at zero and the outputs start at off.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s a style comment - and why everyone should learn VHDL:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;ClkTick &amp;lt;= (ClkCount == ClkDiv - 2);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This may be legal in Verilog but it shouldn&amp;#39;t be !&lt;/p&gt;&lt;p&gt;ClkTick is declared as reg so I assume you mean it to be some kind of hardware signal.&lt;/p&gt;&lt;p&gt;But you are assigning the result of a logical comparison to it - why not describe what you really want:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;if (ClkCount == (ClkDiv - 2))&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ClkTick &amp;lt;= 0;&lt;/p&gt;&lt;p&gt;else&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ClkTick &amp;lt;= 1;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This is a simple example and it is clear to me what you mean, and probably clear to the compiler or Synthesizer.&lt;/p&gt;&lt;p&gt;When you get on to more complicated stuff it will bite you !&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;(The great thing about VHDL is that it never assumes anything - it is very strictly typed.)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;(You&amp;#39;ll notice that I don&amp;#39;t assume precedence of - over ==&lt;/p&gt;&lt;p&gt;Since I work in C, VHDL, Verilog (a little) and a&amp;nbsp; few other things too, I find the cost of brackets to be worth paying. &lt;span&gt;[View:/resized-image/__size/16x16/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-7e2be419-e1fc-4e1f-8d69-cca995fb620d/contentimage_5F00_1.png:16:16]&lt;/span&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Hope this is helpful and thanks for your post.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;MK&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=3645&amp;AppID=293&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>