<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2022-01-02T01:23:30+00:00</updated><id>/feed.xml</id><title type="html">The tinyVision.ai Blog</title><subtitle>tinyVision.ai blog site</subtitle><entry><title type="html">Using Lattice Modelsim on Windows and Linux</title><link href="/modelsim/windows/linux/radiant/lattice/2022/01/01/Using-Lattice-Modelsim-on-Win-Linux.html" rel="alternate" type="text/html" title="Using Lattice Modelsim on Windows and Linux" /><published>2022-01-01T00:00:00+00:00</published><updated>2022-01-01T00:00:00+00:00</updated><id>/modelsim/windows/linux/radiant/lattice/2022/01/01/Using-Lattice-Modelsim-on-Win-Linux</id><content type="html" xml:base="/modelsim/windows/linux/radiant/lattice/2022/01/01/Using-Lattice-Modelsim-on-Win-Linux.html">&lt;h2 class=&quot;post_title&quot;&gt;
  Using Lattice Modelsim on Windows and Linux
  
    &lt;small&gt;, 01 Jan 2022&lt;/small&gt;
  
&lt;/h2&gt;

&lt;p&gt;I am a supporter of open source and have benefitted greatly from using open tools like verilator and Yosys. However, there are many times when its simply not possible to use these tools with a simulator like verilator since the the FPGA vendors provide IP that are encrypted for either FPGA hard macros such as the Serdes or higher level blocks like MIPI. Component vendors also provide encrypted models of their parts like memories assuming one of the closed simulators.&lt;/p&gt;

&lt;p&gt;These encrypted IP cannot be simulated on an open source toolchain. Language support also was lacking for some System Verilog constructs I liked to code with at the time (packed struct).&lt;/p&gt;

&lt;p&gt;I tend to use Lattice FPGA’s quite a bit it in my work, on things like the [UPduino][the-upduino]. This blog demonstrates how to setup your environment assuming you have already installed the Lattice Semiconductor Radiant toolchain. The Radiant tolchain is relatively small and not bloatware like the Xilinx toolchain and since it works on both Linux and Windows, enables a developer to now have access to a commercial simulation environment with minimal overhead.&lt;/p&gt;

&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;

&lt;p&gt;I prefer to use command line tools such as make for all my work and detest GUI’s as they are not automatable and require documentation to run properly and even then, subject to user errors. As such, I like to install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bash&lt;/code&gt; on my windows machine. Now, its possible to setup WSL2 as well and that should work fine too.&lt;/p&gt;

&lt;p&gt;The isntructions are pretty similar for Linux and can be modified slightly where required.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Install git bash&lt;/li&gt;
  &lt;li&gt;Add make to Git bash by following instructions &lt;a href=&quot;https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Open a new Git bash shell and type in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;make&lt;/code&gt; to check for proper &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;make&lt;/code&gt; installation&lt;/li&gt;
  &lt;li&gt;Install the &lt;a href=&quot;https://www.latticesemi.com/LatticeRadiant&quot;&gt;Lattice Radiant toolchain&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add the following to your path (depends on your Lattice tool installation) in the windows environment variables.&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\lscc\radiant\3.0\modeltech\win32loem&lt;/code&gt;&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\lscc\radiant\3.0\bin\nt64&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Point the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LM_LICENSE_FILE&lt;/code&gt; variable to the location of the license.dat file which holds your Lattice and other tool licenses by add a System Variable called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LM_LICENSE_FILE&lt;/code&gt; which in my case is: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\lscc\radiant\3.0\license\license.dat&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Type in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vlog&lt;/code&gt; and ensure that the Modelsim Verilog compiler gets called. Please note that this should be the Lattice FPGA version and not something else. This is important to have access to the pre-compiled libaries for the FPGA. If you already know about this, this limitation doesnt apply to you as you know what you’re doing. You should get the following output:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$ vlog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Model Technology ModelSim - Lattice FPGA Edition vlog 2020.3 Compiler 2021.02 Feb 11 2021&lt;/code&gt;&lt;/p&gt;

&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    /**
    *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
    *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables    */
    /*
    var disqus_config = function () {
    this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = page.title; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
    */
    (function() { // DON'T EDIT BELOW THIS LINE
    var d = document, s = d.createElement('script');
    s.src = 'https://tinyvisionai.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
    })();
&lt;/script&gt;

&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;https://disqus.com/?ref_noscript&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;</content><author><name></name></author><category term="modelsim" /><category term="windows" /><category term="linux" /><category term="radiant" /><category term="lattice" /><summary type="html">Using Lattice Modelsim on Windows and Linux , 01 Jan 2022</summary></entry><entry><title type="html">Magic Smoke and PTC’s</title><link href="/upduino/power/ptc/2021/12/31/magic-smoke-and-PTCs.html" rel="alternate" type="text/html" title="Magic Smoke and PTC’s" /><published>2021-12-31T00:00:00+00:00</published><updated>2021-12-31T00:00:00+00:00</updated><id>/upduino/power/ptc/2021/12/31/magic-smoke-and-PTCs</id><content type="html" xml:base="/upduino/power/ptc/2021/12/31/magic-smoke-and-PTCs.html">&lt;h2 class=&quot;post_title&quot;&gt;
  Magic Smoke and PTC's
  
    &lt;small&gt;, 31 Dec 2021&lt;/small&gt;
  
&lt;/h2&gt;

&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;@stevenbell teaches a course in Introductory Digital Engineering at Tufts University and has bought many &lt;a href=&quot;https://www.tindie.com/products/tinyvision_ai/upduino-v30-low-cost-lattice-ice40-fpga-board/&quot;&gt;UPduino’s&lt;/a&gt;. He suggested that the ferrite bead be replaced with a &lt;a href=&quot;https://www.digikey.com/en/products/detail/bourns-inc/MF-FSMF035X-2/2039255&quot;&gt;PTC&lt;/a&gt; as he was seeing students shorting out their boards leading to burning out the ferrite bead.&lt;/p&gt;

&lt;p&gt;If true, this is a pretty worrisome failure as the board is used by makers as well as students for introductory engineering courses, many of whom are novices and would likely end up with a similar failure.&lt;/p&gt;

&lt;p&gt;The ferrite bead is circled in red below.
&lt;img src=&quot;/assets/images/magic-smoke/upduino_ferrite_bead_schematic.png&quot; alt=&quot;UPduino Ferrite bead schematic&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This was a bit surprising to me as I had always assumed that the USB power was limited to 500mA per the spec and it was the job of the PC or USB power source to handle overcurrent and trip accordingly.&lt;/p&gt;

&lt;h2 id=&quot;verification-of-report&quot;&gt;Verification of report&lt;/h2&gt;

&lt;p&gt;The baseline design loaded into the UPduino is the tinyFPGA bootloader with a breathing blue LED. This can be clearly seen in the current consumption.
&lt;img src=&quot;/assets/images/magic-smoke/upduino_power_up_with_breathing_led.png&quot; alt=&quot;UPduino with breathing LED&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Surprise! When the 5V is shorted to ground, whe short video here shows the ferrite bead glowing like an LED and eventually burning out. This confirms Steven’s experience.
&lt;img src=&quot;/assets/images/magic-smoke/upduino_short_without_ptc.gif&quot; alt=&quot;UPduino short without PTC&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The corresponding current/power trace below shows the bead burning out over about 6 seconds.
&lt;img src=&quot;/assets/images/magic-smoke/joulescope_upduino_short_burnout.png&quot; alt=&quot;UPduino short burnout&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;usb-port-currents&quot;&gt;USB port currents&lt;/h2&gt;

&lt;p&gt;So isnt the job of a PC to protect its own USB ports? When does a port trip? Lets try shorting a superspeed USB from my desktop machine:
&lt;img src=&quot;/assets/images/magic-smoke/shorting_superspeed_usb.png&quot; alt=&quot;Shorting a superspeed USB&quot; /&gt; 
Wow! The current exceeded the limit of my measuring instrument (10A) and lasted almost 200ms, quite a bit of energy into the short circuit.&lt;/p&gt;

&lt;p&gt;Hmm, I wonder if the powered USB hub does any better. Lets try shorting its output:
&lt;img src=&quot;/assets/images/magic-smoke/shorting_USB_output_from_USB_hub.png&quot; alt=&quot;Shorting a powered USB hub (Acroname 4 port)&quot; /&gt;
Significantly less current and also very fast to trip.&lt;/p&gt;

&lt;p&gt;So it appears that USB ports arent all designed the same and we cannot rely on the USB port to limit the energy into a short circuit.&lt;/p&gt;

&lt;h2 id=&quot;bench-top-power-supply-currents&quot;&gt;Bench top power supply currents&lt;/h2&gt;
&lt;p&gt;OK, so USB ports are not reliable for trip points. UPduino’s are also connected to lab power suplies. Lets see what happens to a lab power supply under a short.&lt;/p&gt;

&lt;p&gt;Heres the power supply powering up into a short circuit. The suply is set to 0.5A current limit.
&lt;img src=&quot;/assets/images/magic-smoke/power_supply_turn_on_into_short.png&quot; alt=&quot;Power supply turning on into a short&quot; /&gt;
The supply is quite well behaved and does limit curent after a brief turn on spike within a few milliseconds.&lt;/p&gt;

&lt;p&gt;How about shorting the output? What happens to the energy in the output capacitors of the power supply?
&lt;img src=&quot;/assets/images/magic-smoke/shorting_ps_output.png&quot; alt=&quot;Shorting a 5V 0.5A power supply&quot; /&gt;
Very similar behavior as above so it appears that a lab power supply will not cause damage to the ferrite bead that we’re seeing when the UPduino is plugged into a USB port.&lt;/p&gt;

&lt;h1 id=&quot;adding-a-ptc&quot;&gt;Adding a &lt;a href=&quot;https://www.digikey.com/en/products/detail/bourns-inc/MF-FSMF035X-2/2039255&quot;&gt;PTC&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;Since we’ve proven that significant irriversible damage occurs to the ferrite bead under short circuit of the 5V when powered by a PC USB hub, we would like to fix this so its not a permanent failure. A PTC comes to mind.&lt;/p&gt;

&lt;p&gt;PTC’s are positive temperature coefficient devices, also known as self-resetting fuses. When a large current passes through the PTC, it heats up and undergoes a material phase change at a specific temperature. This new phase has a significantly higher resistance as compared to the low temperature material phase. The current passing through the PTC in this phase keeps the PTC at a high enough temperature to maintain the higher resistance phase by positive feedback.&lt;/p&gt;

&lt;p&gt;Once current is interrupted, this material cools down and changes to the lower resistance phase which is normal operation and so is self resetting assuming the current is interrupted externally.&lt;/p&gt;

&lt;p&gt;Heres what happens with the UPduino with the ferrite bead replaced by &lt;a href=&quot;https://www.digikey.com/en/products/detail/bourns-inc/MF-FSMF035X-2/2039255&quot;&gt;the PTC&lt;/a&gt;.
&lt;img src=&quot;/assets/images/magic-smoke/shorting_with_ptc.png&quot; alt=&quot;Shorting with PTC on UPduino&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Heres the zoomed in version where we see that the PTC trips within 2 ms, limiting energy going into the short circuit.
&lt;img src=&quot;/assets/images/magic-smoke/joulescope_ptc_zoom_in.png&quot; alt=&quot;PTC during short circuit&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now for final proof that the short circuit is recoverable…
&lt;img src=&quot;/assets/images/magic-smoke/upduino_short_with_ptc.gif&quot; alt=&quot;UPduino short with PTC&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;how-much-current-does-the-ptc-take-to-trigger&quot;&gt;How much current does the PTC take to trigger?&lt;/h3&gt;
&lt;p&gt;Its important to know when the PTC will trigger so that normal operation of the circuit isnt compromised. By setting the power supply soucing the USB into a constant current mode and slowly stepping up the current, we can gt an idea of when the PTC triggers.&lt;/p&gt;

&lt;p&gt;As seen below, the PTC triggers when the current through it exceeds 700mA per the spec of the PTC. Of course, this is subject to temperature variation since the PTC is strongly dependent on ambient temperatures. However, there is sufficient margin from the 500mA that the board is supposed to draw.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/magic-smoke/incrementing_current.png&quot; alt=&quot;Incrementing current into the PTC&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;A PTC is a great addition to a USB design which might be subjected to short circuits and reduces the chances of damage to circuitry.&lt;/p&gt;

&lt;h3 id=&quot;instruments-used&quot;&gt;Instruments used:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Joulescope for power measurements&lt;/li&gt;
  &lt;li&gt;Acroname 4 port powered USB hub&lt;/li&gt;
  &lt;li&gt;Siglent SPD3303X-E power supply&lt;/li&gt;
  &lt;li&gt;Custom built PC with Windows 10&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.digikey.com/en/products/detail/bourns-inc/MF-FSMF035X-2/2039255&quot;&gt;PTC&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.tindie.com/products/tinyvision_ai/upduino-v30-low-cost-lattice-ice40-fpga-board/&quot;&gt;UPduino 3.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script&gt;
    /**
    *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
    *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables    */
    /*
    var disqus_config = function () {
    this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = page.title; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
    */
    (function() { // DON'T EDIT BELOW THIS LINE
    var d = document, s = d.createElement('script');
    s.src = 'https://tinyvisionai.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
    })();
&lt;/script&gt;

&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;https://disqus.com/?ref_noscript&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;</content><author><name></name></author><category term="upduino" /><category term="power" /><category term="PTC" /><summary type="html">Magic Smoke and PTC's , 31 Dec 2021</summary></entry></feed>