<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title></title>
    <link rel="self" type="application/atom+xml" href="https://alchitry.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://alchitry.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-03-25T00:00:00+00:00</updated>
    <id>https://alchitry.com/atom.xml</id>
    <entry xml:lang="en">
        <title>Without Alchitry Labs</title>
        <published>2026-03-25T00:00:00+00:00</published>
        <updated>2026-03-25T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/references/without-alchitry-labs/"/>
        <id>https://alchitry.com/tutorials/references/without-alchitry-labs/</id>
        
        <summary type="html">&lt;p&gt;This page has reference materials for using Alchitry boards outside of &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>A Year of Updates</title>
        <published>2026-03-09T00:00:00+00:00</published>
        <updated>2026-03-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/year-of-updates/"/>
        <id>https://alchitry.com/news/year-of-updates/</id>
        
        <summary type="html">&lt;p&gt;Well, it has been over a year since I wrote a news post... A lot has happened.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Getting Started</title>
        <published>2026-02-19T00:00:00+00:00</published>
        <updated>2026-02-19T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/introduction/getting-started/"/>
        <id>https://alchitry.com/tutorials/introduction/getting-started/</id>
        
        <content type="html" xml:base="https://alchitry.com/tutorials/introduction/getting-started/">&lt;p&gt;So you want to get started working with FPGAs?
Great!
This page will go through everything you need to know to dive right in.&lt;&#x2F;p&gt;
&lt;p&gt;Not sure what an FPGA is?
Check out our &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;introduction&#x2F;why-use-fpgas&#x2F;&quot;&gt;Why Use FPGAs&lt;&#x2F;a&gt; page.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;requirements&quot;&gt;Requirements&lt;&#x2F;h1&gt;
&lt;p&gt;To get started, the only thing you really need is a computer.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs&lt;&#x2F;a&gt; lets you run interactive simulations with a virtual &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-io-v2&quot;&gt;Io element&lt;&#x2F;a&gt;.
This is enough to get through the first three &lt;a href=&quot;&#x2F;tutorials#starter-tutorials&quot;&gt;starter tutorials&lt;&#x2F;a&gt;.
That should give you an idea what programmable hardware is all about without having to spend any money.&lt;&#x2F;p&gt;
&lt;p&gt;Ideally, your computer is running Windows or Linux, however, you can get started on a Mac as well.
While Alchitry Labs runs on all three systems, the tools from the FPGA manufactures only work on Windows and Linux.&lt;&#x2F;p&gt;
&lt;p&gt;On a Mac, you have the option of using the open source tools if you have a &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-cu-v2&quot;&gt;Cu&lt;&#x2F;a&gt; or running inside a virtual machine.
While the open source tools are cool, they generally aren&#x27;t as robust as the proprietary ones.&lt;&#x2F;p&gt;
&lt;p&gt;Go ahead and download &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs&lt;&#x2F;a&gt; then start &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;starter&#x2F;your-first-fpga-project&#x2F;&quot;&gt;Your First FPGA Project&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;choosing-a-board&quot;&gt;Choosing a Board&lt;&#x2F;h1&gt;
&lt;p&gt;Assuming you&#x27;ve seen enough to want to get some real hardware, the next question is which board should you get?&lt;&#x2F;p&gt;
&lt;p&gt;Our recommendation for most people is to get an &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-au&quot;&gt;Au&lt;&#x2F;a&gt;.
The reason we recommend it over the &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-cu-v2&quot;&gt;Cu&lt;&#x2F;a&gt; is that the FPGA on the board is a modern chip from Xilinx.
The Artix 7 on the Au is supported by Xilinx&#x27;s tool called Vivado.
This tool is free for the Au&#x27;s FPGA for both commercial and personal use (you need to make an account).&lt;&#x2F;p&gt;
&lt;p&gt;The iCE40 FPGA on the Cu is an older FPGA made by Lattice and is supported by iCEcube2.
Unfortunately, Lattice decided to make iCEcube2 no-longer free.
It also hasn&#x27;t been meaningfully updated in almost a decade, so I&#x27;m not sure what the new licensing cost is covering.&lt;&#x2F;p&gt;
&lt;p&gt;They still offer a free license to &amp;quot;hobbyists, enthusiasts, community educators &amp;amp; start-up companies.&amp;quot;
To get one, you have to email them.
See the &lt;em&gt;Licensing&lt;&#x2F;em&gt; section of &lt;a href=&quot;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;iCEcube2#_12092ABF818047B59CC430396492212C&quot;&gt;this page&lt;&#x2F;a&gt; for more details.
For what it is worth, I haven&#x27;t heard of them denying anyone and they are pretty quick to get back to you.&lt;&#x2F;p&gt;
&lt;p&gt;Vivado, the tool for the Au and Pt, also has Xilinx&#x27;s IP catalog, which offers a lot of powerful blocks you can drop into your designs.
Things like digital filters, FFTs, and floating point math.&lt;&#x2F;p&gt;
&lt;p&gt;So what about the &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-pt&quot;&gt;Pt&lt;&#x2F;a&gt;?
The Pt is really just a supped-up Au.
The FPGA has about 3x the capacity of the Au, and it has almost twice the IO.&lt;&#x2F;p&gt;
&lt;p&gt;The only feature it has that isn&#x27;t just &lt;em&gt;more&lt;&#x2F;em&gt; of an Au&#x27;s feature are the GTPs.
This is a set of specialized pins that allow for up to 6.25 Gbps of data for each pair.
It&#x27;s an advanced feature.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s a table summarizing the different features for the three boards.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Board&lt;&#x2F;th&gt;&lt;th&gt;IO Pins&lt;&#x2F;th&gt;&lt;th&gt;Relative FPGA Capacity&lt;&#x2F;th&gt;&lt;th&gt;Free Tools&lt;&#x2F;th&gt;&lt;th&gt;Open Source Tools&lt;&#x2F;th&gt;&lt;th&gt;IO Voltages&lt;&#x2F;th&gt;&lt;th&gt;Differential Signals&lt;&#x2F;th&gt;&lt;th&gt;On-board DDR&lt;&#x2F;th&gt;&lt;th&gt;IP Catalogs&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Cu&lt;&#x2F;td&gt;&lt;td&gt;79&lt;&#x2F;td&gt;&lt;td&gt;1x&lt;&#x2F;td&gt;&lt;td&gt;yes*&lt;&#x2F;td&gt;&lt;td&gt;yes&lt;&#x2F;td&gt;&lt;td&gt;3.3V&lt;&#x2F;td&gt;&lt;td&gt;No&lt;&#x2F;td&gt;&lt;td&gt;No&lt;&#x2F;td&gt;&lt;td&gt;Alchitry&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Au&lt;&#x2F;td&gt;&lt;td&gt;104&lt;&#x2F;td&gt;&lt;td&gt;3x&lt;&#x2F;td&gt;&lt;td&gt;yes&lt;&#x2F;td&gt;&lt;td&gt;yes**&lt;&#x2F;td&gt;&lt;td&gt;3.3V, 2.5V, 1.8V&lt;&#x2F;td&gt;&lt;td&gt;LVDS, TMDS&lt;&#x2F;td&gt;&lt;td&gt;256MB&lt;&#x2F;td&gt;&lt;td&gt;Alchitry, Xilinx&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Pt&lt;&#x2F;td&gt;&lt;td&gt;206&lt;&#x2F;td&gt;&lt;td&gt;9x&lt;&#x2F;td&gt;&lt;td&gt;yes&lt;&#x2F;td&gt;&lt;td&gt;yes**&lt;&#x2F;td&gt;&lt;td&gt;3.3V, 2.5V, 1.8V&lt;&#x2F;td&gt;&lt;td&gt;LVDS, TMDS&lt;&#x2F;td&gt;&lt;td&gt;256MB&lt;&#x2F;td&gt;&lt;td&gt;Alchitry, Xilinx&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;* for hobbyists, enthusiasts, community educators, and start-up companies &lt;br&gt;
** &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;openXC7&quot;&gt;they exist&lt;&#x2F;a&gt; but aren&#x27;t included in Alchitry Labs yet&lt;&#x2F;p&gt;
&lt;h2 id=&quot;extra-elements&quot;&gt;Extra Elements&lt;&#x2F;h2&gt;
&lt;p&gt;In addition to your main FPGA board, you probably should pick up at least a &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-br-v2&quot;&gt;Br&lt;&#x2F;a&gt;.
I generally recommend going with the &lt;em&gt;Wide&lt;&#x2F;em&gt; version, which allows you to solder in &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;wide-br-headers&quot;&gt;headers&lt;&#x2F;a&gt; for easy access to signals.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-io-v2&quot;&gt;Io element&lt;&#x2F;a&gt; is also a great pickup for experimenting if you want to bring your simulations to life.&lt;&#x2F;p&gt;
&lt;p&gt;The other elements are highly situational.
If you need to dump a lot of data to or from your FPGA, the &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-ft-v2&quot;&gt;Ft&lt;&#x2F;a&gt; is what you need.
If you want HDMI in&#x2F;out, then the &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-hd&quot;&gt;Hd&lt;&#x2F;a&gt; has you covered.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;software-setup&quot;&gt;Software Setup&lt;&#x2F;h1&gt;
&lt;p&gt;No matter what board you have, you&#x27;ll need &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs&lt;&#x2F;a&gt;.
Even if you don&#x27;t plan to use it as an IDE, you still need it for the &lt;em&gt;Alchitry Loader&lt;&#x2F;em&gt; to get the bin file onto your board.&lt;&#x2F;p&gt;
&lt;p&gt;If you have an Au or Pt, you need to install &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;introduction&#x2F;vivado&#x2F;&quot;&gt;Vivado&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;If you have a Cu, you can use the built-in open-source tools by clicking the beaker logo and going to &lt;em&gt;Settings → Cu Toolchain → Yosys (Open Source)&lt;&#x2F;em&gt; in Alchitry Labs.
Alternatively, you can install &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;introduction&#x2F;icecube2&#x2F;&quot;&gt;iCEcube2&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tutorials&quot;&gt;Tutorials&lt;&#x2F;h1&gt;
&lt;p&gt;With everything set up, you can jump into the catalog of &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;&quot;&gt;tutorials&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;If you run into issues, have questions, or just want to talk FPGAs, head over to the &lt;a href=&quot;https:&#x2F;&#x2F;forum.alchitry.com&#x2F;&quot;&gt;forum&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Why Use FPGAs?</title>
        <published>2026-02-11T00:00:00+00:00</published>
        <updated>2026-02-11T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/introduction/why-use-fpgas/"/>
        <id>https://alchitry.com/tutorials/introduction/why-use-fpgas/</id>
        
        <content type="html" xml:base="https://alchitry.com/tutorials/introduction/why-use-fpgas/">&lt;p&gt;So you&#x27;ve heard the term &lt;em&gt;FPGA&lt;&#x2F;em&gt; and want to know what they are and why people use them?
Well, you&#x27;ve come to the right place!&lt;&#x2F;p&gt;
&lt;p&gt;First, FPGA stands for &lt;strong&gt;F&lt;&#x2F;strong&gt;ield &lt;strong&gt;P&lt;&#x2F;strong&gt;rogrammable &lt;strong&gt;G&lt;&#x2F;strong&gt;ate &lt;strong&gt;A&lt;&#x2F;strong&gt;rray.
Phew, with that mouthful out of the way, we can get into what that actually means.&lt;&#x2F;p&gt;
&lt;p&gt;FPGAs belong to a family of devices known as &lt;em&gt;programmable hardware&lt;&#x2F;em&gt;.
They let you design a digital circuit using text on a computer, similar to writing code.
However, FPGAs don&#x27;t &lt;em&gt;run&lt;&#x2F;em&gt; code. 
Instead, the text is something called a &lt;strong&gt;H&lt;&#x2F;strong&gt;ardware &lt;strong&gt;D&lt;&#x2F;strong&gt;escription &lt;strong&gt;L&lt;&#x2F;strong&gt;anguage (HDL).&lt;&#x2F;p&gt;
&lt;p&gt;These are languages specifically designed for describing digital circuits.&lt;&#x2F;p&gt;
&lt;p&gt;The tools on your computer take your HDL and turn it into a configuration file for the FPGA.
Almost like magic, once loaded onto the FPGA, the FPGA becomes the circuit you described.&lt;&#x2F;p&gt;
&lt;p&gt;Ok, ok let&#x27;s get out of the weeds and take a step back.
While this sounds cool, why bother with it when we have powerful processors we can make do whatever we want with code?&lt;&#x2F;p&gt;
&lt;h1 id=&quot;processors-vs-fpgas&quot;&gt;Processors vs FPGAs&lt;&#x2F;h1&gt;
&lt;p&gt;Let me give a quick analogy for these two systems to give you some intuition on when you might use one or the other.&lt;&#x2F;p&gt;
&lt;p&gt;Imagine you sell sandwiches.
You have a small shop with a few sandwiches on the menu, and you even allow customers to create their own custom orders.&lt;&#x2F;p&gt;
&lt;p&gt;However, you find that the majority of your customers order one of three sandwiches.
As your business grows, you have a hard time keeping up with demand of these three sandwiches.
You decide that personally creating hundreds of the exact same three sandwiches every day isn&#x27;t very efficient.&lt;&#x2F;p&gt;
&lt;p&gt;Instead, you decide to set up an assembly line.
You invest in some robots that can cut the bread, place the cheese, spray on condiments, etc.&lt;&#x2F;p&gt;
&lt;p&gt;While setting up this line was a lot more work than just making a sandwich, you can now pump out way more than you could
before very efficiently.&lt;&#x2F;p&gt;
&lt;p&gt;In this scenario, you, a sandwich master chef capable of creating any unique sandwich to order, are like a processor.
Processors are fantastic at handling a wide variety of complicated tasks and dealing with complicated control flow.
Someone wants their one sandwich cut into a star shape?
No problem, you can do that.&lt;&#x2F;p&gt;
&lt;p&gt;On the other hand, the assembly line is like an FPGA.&lt;&#x2F;p&gt;
&lt;p&gt;Each piece of the assembly line operates in tandem with every other piece.
Where you, the processor, do one task at a time, cut the bread, then place the cheese, etc., the assembly line does them all at once.
Sandwiches flow through the line continuously.
When one sandwich is having mayo dispensed on it, another is having the cheese placed, and yet another is just being started by slicing bread.&lt;&#x2F;p&gt;
&lt;p&gt;The individual pieces all work together in parallel.
This makes the throughput of the assembly line very high.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;em&gt;assembly line&lt;&#x2F;em&gt; equivalent in digital design is known as a &lt;em&gt;pipeline&lt;&#x2F;em&gt;.
You&#x27;ve likely heard that term before, and in this context it describes a circuit where each section processes some data
in some way before passing to the next section.
All the sections run in parallel with many pieces of data flowing through the pipeline at any given time in various stages of completeness.&lt;&#x2F;p&gt;
&lt;p&gt;However, while pipelines are very powerful and commonplace, FPGAs can implement any digital circuit you want, including things like processors.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;processors-and-fpgas&quot;&gt;Processors &lt;em&gt;and&lt;&#x2F;em&gt; FPGAs&lt;&#x2F;h2&gt;
&lt;p&gt;While it&#x27;s common to want to compare FPGAs to processors, it isn&#x27;t really a strictly fair comparison.
That&#x27;s because you can implement processors inside an FPGA.&lt;&#x2F;p&gt;
&lt;p&gt;Just for reference, processors inside an FPGA are often called &lt;em&gt;soft&lt;&#x2F;em&gt; processors.&lt;&#x2F;p&gt;
&lt;p&gt;You can imagine a situation on our hypothetical sandwich line where one stage is very complicated to automate or requires immense flexibility.
In that case, it might be worth hiring someone to fill that role instead.&lt;&#x2F;p&gt;
&lt;p&gt;That&#x27;s the power of being able to incorporate a processor directly into an FPGA.&lt;&#x2F;p&gt;
&lt;p&gt;Inside the FPGA, you can also scale up or down that processor&#x27;s capabilities depending on the job it needs to perform.
If all it has to do is cut the sandwich into a funny shape, it doesn&#x27;t need a PhD in astrophysics.&lt;&#x2F;p&gt;
&lt;p&gt;There are even some FPGAs that have &lt;em&gt;hard&lt;&#x2F;em&gt; processors (i.e. ones that are fixed) in them to give you both high software
performance and custom hardware flexibility.
It&#x27;s also common to see FPGAs paired with external processors.
They&#x27;re often complimentary rather than exclusive.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;fpgas-vs-asic&quot;&gt;FPGAs vs ASIC&lt;&#x2F;h2&gt;
&lt;p&gt;All the benefits I&#x27;ve said up to this point aren&#x27;t specific to FPGAs. 
Instead, they&#x27;re just benefits to creating a custom circuit.&lt;&#x2F;p&gt;
&lt;p&gt;The term ASIC, or &lt;strong&gt;A&lt;&#x2F;strong&gt;pplication &lt;strong&gt;S&lt;&#x2F;strong&gt;pecific &lt;strong&gt;I&lt;&#x2F;strong&gt;ntegrated &lt;strong&gt;C&lt;&#x2F;strong&gt;ircuit, is used to describe a custom circuit made into a custom chip.
This is the gold standard when it comes to performance (both speed and power consumption).
However, it isn&#x27;t always in reach.&lt;&#x2F;p&gt;
&lt;p&gt;There are two major downsides to having your design turned into an ASIC.&lt;&#x2F;p&gt;
&lt;p&gt;First, once you get your chip back from the fab, that&#x27;s it.
If you find you made a mistake, even a tiny one, it is baked into the design and requires new chips to be made to fix.
Second, getting them made a slow and expensive process.
Typically, you&#x27;re looking somewhere North of a million USD.&lt;&#x2F;p&gt;
&lt;p&gt;This is where FPGAs come into play.
FPGAs allow you to &lt;em&gt;make&lt;&#x2F;em&gt; your digital circuit without having to actually &lt;strong&gt;make&lt;&#x2F;strong&gt; it.&lt;&#x2F;p&gt;
&lt;p&gt;That flexibility comes at a cost.&lt;&#x2F;p&gt;
&lt;p&gt;First is the real dollars cost.
FPGAs aren&#x27;t cheap.
While today, you can get a lot for the money, the FPGA itself is rarely less than $10 for the smallest ones and high-end FPGAs
easily go into five digits with some in the six digit range.
On top of that, FPGAs generally require quite a bit of extra stuff to make them work like multiple power supplies and external memory.&lt;&#x2F;p&gt;
&lt;p&gt;The second cost is in performance.
FPGAs are both slower and more power hungry than an ASIC.
There is inherent overhead in the circuitry that makes them so flexible.&lt;&#x2F;p&gt;
&lt;p&gt;So why use them?&lt;&#x2F;p&gt;
&lt;p&gt;While their per-unit cost is terrible compared to a huge batch of ASICs, there is no NRE (non-recurring engineering) costs associated with production.
This is a game changer when you have lower volumes or your design is likely to change.
They&#x27;re also useful in prototyping designs that will later become ASICs.&lt;&#x2F;p&gt;
&lt;p&gt;FPGAs also can be reconfigured over and over again making any circuit using them &lt;em&gt;field programmable&lt;&#x2F;em&gt; (hey, that&#x27;s where the FP part of FPGA came from).
This is an incredible superpower.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;when-to-use-an-fpga&quot;&gt;When to Use an FPGA&lt;&#x2F;h1&gt;
&lt;p&gt;Given that FPGAs are more expensive and power-hungry than a typical microcontroller, you may be wondering when you should use one.
There are a handful of places, such as tons of IO, predictable latency, and high throughput, where FPGAs really excel.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;io&quot;&gt;IO&lt;&#x2F;h2&gt;
&lt;p&gt;The first is in anything IO heavy.
By IO, I mean inputs and outputs of the chip.&lt;&#x2F;p&gt;
&lt;p&gt;FPGAs often have a ton of pins to connect to the external world.
On top of that, these pins often have capabilities not seen on microcontrollers.&lt;&#x2F;p&gt;
&lt;p&gt;For example, on our &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-au&quot;&gt;Au FPGA development board&lt;&#x2F;a&gt;, most of the IO can be used
as differential input pairs capable of receiving 1.2 Gbps (1.2 BILLION bits per second).
This also happens &lt;em&gt;passively&lt;&#x2F;em&gt;.
That data simply comes into the FPGA and is fed into whatever circuit is designed to handle it.
The rest of the FPGA is free to do whatever it was designed for.&lt;&#x2F;p&gt;
&lt;p&gt;Contrast that to a microcontroller where something like a basic Arduino could spend 100% of its CPU time toggling a pin at
only around 100 thousand times per second (highly dependent on the code and the specific chip).
And that&#x27;s leaving &lt;em&gt;zero&lt;&#x2F;em&gt; time for the CPU to do anything else.&lt;&#x2F;p&gt;
&lt;p&gt;The IO on an FPGA offers unparalleled flexibility.
For example, with a typical microcontroller you&#x27;ll have a bunch of different peripherals (extra dedicated circuits) attached to the
main processors.
Usually, these include things like timers, UART (serial ports), or other communication protocols.&lt;&#x2F;p&gt;
&lt;p&gt;Using one of the built-in peripherals for sending and receiving data is basically mandatory as &lt;em&gt;bit-banging&lt;&#x2F;em&gt; it (using the 
CPU to generate all the signals) is slow and wastes a lot of CPU time.
However, you have a limited number of each peripheral, and they typically route to specific pins on the chip.&lt;&#x2F;p&gt;
&lt;p&gt;In an FPGA, for the most part, IO pins are IO pins.
If you need two of them to be a serial port, connect them to a circuit that knows how to deal with that signal.
If you need 20 serial ports, duplicate that circuit 20 times.&lt;&#x2F;p&gt;
&lt;p&gt;If you have some weird custom protocol you need to interface with, no problem!
Whip up a circuit that can handle it and attach it wherever.&lt;&#x2F;p&gt;
&lt;p&gt;Check out our &lt;a href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=dnk6_uN5UyE&quot;&gt;FPGA IO video tutorial&lt;&#x2F;a&gt; for more details!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;predictable-latency&quot;&gt;Predictable Latency&lt;&#x2F;h2&gt;
&lt;p&gt;If we go back to our sandwich shop example, when making sandwiches, you might take 3 minutes per sandwich on average.
However, sometimes in the middle of making one, the phone rings.
You answer the phone and deal with that, but now the total time for that sandwich is 8 minutes.&lt;&#x2F;p&gt;
&lt;p&gt;This is inherent with multitasking.
A CPU may be doing its main task, but then an interrupt fires and that needs to be dealt with before resuming the main task.
Usually that&#x27;s exactly what you want to happen, but in some systems that unpredictability is unacceptable.&lt;&#x2F;p&gt;
&lt;p&gt;The sandwich assembly line &lt;strong&gt;always&lt;&#x2F;strong&gt; pumps out sandwiches at the same rate.
Timing when each step happens is straightforward and performance is guaranteed by design.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;high-throughput&quot;&gt;High Throughput&lt;&#x2F;h2&gt;
&lt;p&gt;This point is probably already obvious to you at this point, but the ability to have many small dedicated portions of the 
FPGA all running in parallel lends itself to processing &lt;em&gt;a lot&lt;&#x2F;em&gt; of data.&lt;&#x2F;p&gt;
&lt;p&gt;Think things like a &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;projects&#x2F;gpu&#x2F;&quot;&gt;GPU pipeline&lt;&#x2F;a&gt; or heavy digital-signal processing (filters, Fourier transforms, etc.).&lt;&#x2F;p&gt;
&lt;p&gt;The parallel nature of an FPGA is seen in breaking down each task into parallelizable chunks and in that every task can be performed independently.
Adding some extra unrelated functionality to your design does not slow down other parts like it would in a CPU.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;how-they-work&quot;&gt;How They Work&lt;&#x2F;h1&gt;
&lt;p&gt;Being able to just load a configuration file onto the chip and have it transform into whatever digital circuit we want 
seems a bit magical.
However, at a high level, FPGAs aren&#x27;t that complicated to understand.&lt;&#x2F;p&gt;
&lt;p&gt;You don&#x27;t need to know how they work to use them, but you may still find this section interesting.
You will need some &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;background&#x2F;&quot;&gt;background&lt;&#x2F;a&gt; in digital circuits like knowing what a &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;background&#x2F;multiplexers&#x2F;&quot;&gt;multiplexer&lt;&#x2F;a&gt; is.&lt;&#x2F;p&gt;
&lt;p&gt;An FPGA has three main elements, &lt;strong&gt;L&lt;&#x2F;strong&gt;ook-&lt;strong&gt;U&lt;&#x2F;strong&gt;p &lt;strong&gt;T&lt;&#x2F;strong&gt;ables (LUT), flip-flops, and the routing matrix.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;look-up-tables&quot;&gt;Look-Up Tables&lt;&#x2F;h2&gt;
&lt;p&gt;Look-up tables are how your logic actually gets implemented. 
A LUT consists of some number of inputs and one output. 
What makes a LUT powerful is that you can &lt;em&gt;program&lt;&#x2F;em&gt; what the output should be for every single possible input.&lt;&#x2F;p&gt;
&lt;p&gt;A LUT consists of a block of RAM (memory) that is indexed by the LUT&#x27;s inputs. 
The output of the LUT is whatever value is in the indexed location in its RAM.&lt;&#x2F;p&gt;
&lt;p&gt;As an example, let&#x27;s look at a 2-input LUT.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;background&#x2F;lut2.png&quot; alt=&quot;lut2.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Since the RAM in the LUT can be set to anything, a 2-input LUT can become any logic gate!&lt;&#x2F;p&gt;
&lt;p&gt;For example, if we want to implement an AND gate the contents of the RAM would look like this.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Address (In[1:0])&lt;&#x2F;th&gt;&lt;th&gt;Value (Out)&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;00&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;01&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;It&#x27;s important to understand that the column &lt;em&gt;Value (Out)&lt;&#x2F;em&gt; could be set to anything! 
It doesn&#x27;t have to model a single logic gate. 
If the value for address 01 was a 1, then the LUT would still perform as expected, but the equivalent logic circuit would require more than one gate to implement. 
This is why the metric of equivalent gate count for an FPGA is a confusing and poor metric! 
It is tricky to specify how complicated of a circuit you can implement in a given FPGA because of all the variables.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;luts-in-the-au-and-pt&quot;&gt;LUTs in the Au and Pt&lt;&#x2F;h2&gt;
&lt;p&gt;In the Artix 7 used by the &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-au&quot;&gt;Au&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;products&#x2F;alchitry-pt&quot;&gt;Pt&lt;&#x2F;a&gt;, each LUT is a 6-input LUT. 
However, it isn&#x27;t a true 6-input LUT but rather two 5-input LUTs connected by a multiplexer (MUX).&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;background&#x2F;lut6.png&quot; alt=&quot;lut6.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The reason the LUT is designed this way is that it can either be used as a single 6-input LUT, or two 5-input LUTs. 
The only restriction is that both 5-input LUTs must share the same inputs. 
When it is configured as two 5-input LUTs, &lt;em&gt;In[5]&lt;&#x2F;em&gt; is set to 0.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;flip-flops-and-slices&quot;&gt;Flip-flops and Slices&lt;&#x2F;h2&gt;
&lt;p&gt;Each LUT&#x27;s output can be optionally connected to a &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;starter&#x2F;synchronous-logic&#x2F;&quot;&gt;flip-flop&lt;&#x2F;a&gt;. 
Groups of LUTs and flip-flops are called &lt;em&gt;slices&lt;&#x2F;em&gt;. 
In the Artix 7, a slice has 4 LUT6 and eight flip-flops. 
These flip-flops are configurable, allowing the type of reset (asynchronous vs. synchronous) and the reset level (high vs. low) to be specified. &lt;&#x2F;p&gt;
&lt;p&gt;The FPGA used by the Au has 5,200 slices in it for a total of 20,800 LUTs.
The Pt has just about tripled that with 15,850 slices and 63,400 LUTs!&lt;&#x2F;p&gt;
&lt;p&gt;All slices are not created equal, however. 
In the Artix 7 FPGAs there are two types of slices, &lt;em&gt;SLICEL&lt;&#x2F;em&gt;, and &lt;em&gt;SLICEM&lt;&#x2F;em&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;The SLICEL is the basic type of slice and just consists of the four LUT6&#x27;s and the eight flip-flops plus some extra routing resources.&lt;&#x2F;p&gt;
&lt;p&gt;A SLICEM is the same as a SLICEL except the LUTs can be used as 64 bits of RAM or a shift register up to 32 bits long. 
The breakdown of the slices is roughly SLICEL 70%, and SLICEM 30%.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-routing-matrix&quot;&gt;The Routing Matrix&lt;&#x2F;h2&gt;
&lt;p&gt;The next size block in the FPGA is the &lt;strong&gt;C&lt;&#x2F;strong&gt;onfigurable &lt;strong&gt;L&lt;&#x2F;strong&gt;ogic &lt;strong&gt;B&lt;&#x2F;strong&gt;lock (CLB) and each CLB consists of two slices. 
Each CLB connects to a &lt;em&gt;switch matrix&lt;&#x2F;em&gt; that is responsible for connecting the CLB to the rest of the FPGA. 
The switch matrix can connect the inputs and outputs of the CLB to the &lt;em&gt;general routing matrix&lt;&#x2F;em&gt; or to each other. 
That way the output from one LUT can feed into the input of another LUT without having to travel far.&lt;&#x2F;p&gt;
&lt;p&gt;The routing resources in an FPGA are pretty complicated, but they are essentially a bunch of multiplexers and wires 
that are used to define what CLBs and other FPGA resources are connected to each other. 
These connections are again defined in RAM, which is why the FPGA must be reconfigured every time the power is cycled 
(on Alchitry boards this happens automatically via the on-board persistent memory).&lt;&#x2F;p&gt;
&lt;p&gt;There are also special routing resources available on the FPGA. 
The most notable are the clock routing resources. 
When you have a clock being used in your design, it is crucial that the clock signal be distributed as evenly as possible 
throughout the FPGA so all the flip-flops will flip at roughly the same time. 
If you were to try and use the general routing resources for this, the clock signal would have large propagation delays 
from traveling through all the multiplexers. &lt;&#x2F;p&gt;
&lt;p&gt;To solve this problem, there are global and local routing resources dedicated to clocks. 
These are basically wires that connect through the entire chip (for global) or sections of the chip (for local) with 
very little propagation delay. &lt;&#x2F;p&gt;
&lt;p&gt;Only inputs from certain pins on the FPGA are allowed to drive a signal on the global clock routing resources. 
These are the MRCC&#x2F;SRCC pins on the Au and Pt and GBIN pins on the Cu.&lt;&#x2F;p&gt;
&lt;p&gt;On the Alchitry V2 headers, these are normally connected to pins 41, 42, 47, and 48 of each bank where available.
For more info on the pinout, see the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;references&#x2F;pinouts-and-custom-elements&#x2F;&quot;&gt;Pinout and Custom Elements&lt;&#x2F;a&gt; page.&lt;&#x2F;p&gt;
&lt;p&gt;All of these resources that are used in an FPGA to make them very flexible also slow things down. 
This is why you will never be able to clock an FPGA at speeds comparable to a dedicated chip.
An ASIC design can reach speeds faster than 4GHz, while an FPGA is very fast if it&#x27;s running at 450MHz (internally, IO can go faster). &lt;&#x2F;p&gt;
&lt;p&gt;This is also why FPGAs consume considerably more power than their ASIC counterparts. 
An FPGA will require an order of magnitude more power to run than an 8-bit microcontroller, like an AVR. 
However, they still have the huge advantage of being low-cost for small runs (or hobbyists) and reconfigurable virtually unlimited times.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re interested in digging into the nitty-gritty, check out the official &lt;a href=&quot;https:&#x2F;&#x2F;docs.amd.com&#x2F;r&#x2F;en-US&#x2F;ug474_7Series_CLB&quot;&gt;UG474 doc from Xilinx&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Basic CPU</title>
        <published>2025-12-11T00:00:00+00:00</published>
        <updated>2025-12-11T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/intermediate/basic-cpu/"/>
        <id>https://alchitry.com/tutorials/intermediate/basic-cpu/</id>
        
        <content type="html" xml:base="https://alchitry.com/tutorials/intermediate/basic-cpu/">&lt;p&gt;In this tutorial we will create a super basic CPU that you can write some assembly for. 
You can then go brag to all your friends about how cool you are.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-is-a-cpu&quot;&gt;What is a CPU?&lt;&#x2F;h1&gt;
&lt;p&gt;If you are reading this, there is an excellent chance you already have a decent idea what a CPU is. 
However, since we are going to be making one, we need to have a clear idea of exactly what we are going to be making.&lt;&#x2F;p&gt;
&lt;p&gt;In its most abstract form, a CPU is a circuit whose behavior is determined by the code it is fed. 
This way, the same circuit can perform a completely different task simply by changing some values in a ROM. 
In general, a CPU will also have some form of memory to perform work, and they all need a way to input and output data 
(if you don&#x27;t have any IO, you can&#x27;t do anything useful).&lt;&#x2F;p&gt;
&lt;p&gt;A CPU is some circuit that has a stream of instructions fed to it, and those instructions determine what it will do. 
But what sort of operations do we need?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;instruction-set&quot;&gt;Instruction Set&lt;&#x2F;h2&gt;
&lt;p&gt;A CPU&#x27;s &lt;em&gt;instruction set&lt;&#x2F;em&gt; is the set of instructions that the CPU understands. 
It is the language of that particular processor. 
However, many CPUs share the same, or very similar, instruction sets. 
For example, x86 is the name of Intel&#x27;s instruction set for their 32-bit processors. 
By keeping the instruction set the same between generations of processors, the exact same software can run on different 
processors without needing to be modified.&lt;&#x2F;p&gt;
&lt;p&gt;For our super basic CPU, we will be making up our own instruction set (because we are cool like that). 
Our set will be pretty minimal (16 instructions) and will consist only of the essentials.&lt;&#x2F;p&gt;
&lt;p&gt;There are two important sizes in a CPU. 
The first, and the one you hear about the most, is the data path size. 
This determines the largest values that can be operated on at any time. 
When you hear that a CPU is 8 bit, 32 bit, etc., these are the data path sizes. 
An 8-bit processor can only operate on 8 bits at a time while a 64-bit processor can operate on eight times that. &lt;&#x2F;p&gt;
&lt;p&gt;The other important size is the instruction size. 
Depending on the CPU, these may or may not be the same size, and depending on the instruction set, instructions may actually have varying lengths!&lt;&#x2F;p&gt;
&lt;p&gt;For our CPU, we are going to make it operate on 8 bit data with a 16 bit instruction size. 
This means all our instructions need to be encoded with 16 bits. 
By having a fixed instruction size, it is easy to know where the next instruction starts without having to inspect every instruction before it.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;memory&quot;&gt;Memory&lt;&#x2F;h2&gt;
&lt;p&gt;Before we dive into what our CPU will actually do, we need to figure out how data will get in and out and when it is in, how do we work with it? 
CPUs typically have a tiny bit of super-duper fast memory built into them. 
This memory is known as the CPU&#x27;s registers and serves as the working memory of the CPU. 
Our CPU will only be able to perform operations directly on its registers. &lt;&#x2F;p&gt;
&lt;p&gt;So if all the work happens on these registers, how do we process outside data? 
We need a way to load data into a register and output the value of a register. 
The interface we will use will be basically the same as the RAM interface in the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;starter&#x2F;hello-your-name-here&#x2F;&quot;&gt;Hello YOUR_NAME_HERE&lt;&#x2F;a&gt; tutorial. 
We will specify an address and data (for a write) or an address, and we will receive data (for a read). 
This will be covered a bit more later. &lt;&#x2F;p&gt;
&lt;p&gt;For now, know that we have internal memory called registers, and we will have a way to load and store values to&#x2F;from the outside world.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;operations&quot;&gt;Operations&lt;&#x2F;h2&gt;
&lt;p&gt;We now need a way to encode the instructions for our CPU. 
We are going to fit each instruction into 16 bits. 
The first four bits will be used to encode what the operation is (since we will have 16 operations), 
and the remaining 12 bits will be unique to each operation. &lt;&#x2F;p&gt;
&lt;p&gt;The four bits that encode the type of operation are known as the &lt;strong&gt;opcode&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Because some of our instructions will require three arguments, that leaves four bits for each argument. 
If each argument is the address of a register, we can have at most 16 registers without increasing our instruction size.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;nop&quot;&gt;NOP&lt;&#x2F;h3&gt;
&lt;p&gt;What is the most basic operation you can think of? 
If you thought of nothing, you win! &lt;&#x2F;p&gt;
&lt;p&gt;The &lt;em&gt;do nothing&lt;&#x2F;em&gt; instruction, or &lt;em&gt;no operation&lt;&#x2F;em&gt; (often abbreviated to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;NOP&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;), is going to be our first instruction.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;NOP&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;This instruction does nothing, so we can just fill the 12 bits with 0.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;load-and-store&quot;&gt;LOAD and STORE&lt;&#x2F;h3&gt;
&lt;p&gt;As you should recall from only a few lines above, all CPUs need some form of IO. 
If you can&#x27;t input data and output results, the CPU would be useless. &lt;&#x2F;p&gt;
&lt;p&gt;It would be like a fully paralyzed person with no senses. 
They may have fascinating thoughts, but no one would ever know. &lt;&#x2F;p&gt;
&lt;p&gt;We can then create two more instructions, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for loading a value (input) and storing a value (output) respectively.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;LOAD&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;ADDR&lt;&#x2F;td&gt;&lt;td&gt;OFFSET&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;STORE&lt;&#x2F;td&gt;&lt;td&gt;SRC&lt;&#x2F;td&gt;&lt;td&gt;ADDR&lt;&#x2F;td&gt;&lt;td&gt;OFFSET&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Since the loads and stores need to provide both a value and an address, we need two arguments. &lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; argument is the register that will get the value from a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SRC&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; argument is the register whose value will be output. &lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADDR&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; argument is the register whose value should be used as the address. &lt;&#x2F;p&gt;
&lt;p&gt;Finally, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OFFSET&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is a constant that will be added to the value of the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADDR&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; register to get the address. 
This offset can be convenient to have, but you don&#x27;t really need it. 
I added it because there were four extra bits we could do something with.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;set&quot;&gt;SET&lt;&#x2F;h3&gt;
&lt;p&gt;We will commonly need to set the value of a register to some constant. 
The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; operation will let us do that.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;SET&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;CONST&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Here &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the register that will be set and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CONST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the 8-bit value to set it to. 
Keep in mind that since we are making an 8-bit processor, the registers are 8 bits wide.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;lt-and-eq&quot;&gt;LT and EQ&lt;&#x2F;h3&gt;
&lt;p&gt;We will likely want to be able to compare two different values. 
To do any comparison, we only need two operators, less-than (&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;) and equal (&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;). 
If we then wanted to perform a &lt;em&gt;greater-than&lt;&#x2F;em&gt;, we could use less-than and flip the arguments. &lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;Less-than or equal to&lt;&#x2F;em&gt; (&lt;strong&gt;≤&lt;&#x2F;strong&gt;) can be achieved by using both.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;LT&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;EQ&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;In the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; case the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; register will be &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; if &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is less than &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; otherwise. &lt;&#x2F;p&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the same, except it checks for equality.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;beq-and-bneq&quot;&gt;BEQ and BNEQ&lt;&#x2F;h3&gt;
&lt;p&gt;Typically, a program will execute instruction after instruction. 
However, it can be really powerful to be able to control the flow. 
This is where branching instructions are useful.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;BEQ&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;CONST&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;BNEQ&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;CONST&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;If register &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is equal to the value &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CONST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; then the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instruction will skip the instruction following it. 
Otherwise, the program will continue as normal. &lt;&#x2F;p&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BNEQ&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; does the same thing but skips is they are not equal.&lt;&#x2F;p&gt;
&lt;p&gt;These instructions allow you to create &lt;em&gt;if statements&lt;&#x2F;em&gt; in your code.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;the-alu&quot;&gt;The ALU&lt;&#x2F;h3&gt;
&lt;p&gt;CPUs commonly need to manipulate the values in the registers. 
Operations like addition, AND, OR, bit shifting, etc. are all typically contained in something called the
&lt;strong&gt;ALU&lt;&#x2F;strong&gt; or &lt;strong&gt;A&lt;&#x2F;strong&gt;rithmetic &lt;strong&gt;L&lt;&#x2F;strong&gt;ogic &lt;strong&gt;U&lt;&#x2F;strong&gt;nit. These types of instructions will make up the remainder of our instruction set.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;ADD&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;SUB&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;SHL&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;SHR&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;AND&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;OR&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;INV&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;XOR&lt;&#x2F;td&gt;&lt;td&gt;DEST&lt;&#x2F;td&gt;&lt;td&gt;OP1&lt;&#x2F;td&gt;&lt;td&gt;OP2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SUB&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; add or subtract &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and store the result into &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHL&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHR&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; shift &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to the right or left by &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; bits and store the result into &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;AND&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OR&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;XOR&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; perform their respective bit-wise operations on &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and store their result into &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;INV&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; does a bit-wise inversion of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OP1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and stores the result into &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DEST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-program-counter&quot;&gt;The Program Counter&lt;&#x2F;h2&gt;
&lt;p&gt;We are going to put all the instructions for whatever program we write into a ROM. 
The ROM will need an address to know what instruction we need. 
This address will be specified by the &lt;em&gt;program counter&lt;&#x2F;em&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;For our CPU, we will use register 0 as our program counter. 
This will allow us to directly manipulate the flow of the program by messing with its value.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-cpu&quot;&gt;The CPU&lt;&#x2F;h1&gt;
&lt;p&gt;Now that we have all the pieces, let&#x27;s take a look at the actual module. 
You should create a new project using the &lt;em&gt;Base Project&lt;&#x2F;em&gt; template and create a new module named &lt;em&gt;cpu&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;short language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;global &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;NOP   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; 0 filled
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, offset  : R[dest] = M[R[op1] + offset]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; src, op1, offset   : M[R[op1] + offset] = R[src]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d3  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, const        : R[dest] = const
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d4  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;lt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d5  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] == R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d6  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; op1, const         : R[0] = R[0] + (R[op1] == const ? 2 : 1)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BNEQ  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d7  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; op1, const         : R[0] = R[0] + (R[op1] != const ? 2 : 1)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d8  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] + R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SUB   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d9  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] - R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHL   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d10 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;lt;&amp;lt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHR   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;gt;&amp;gt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;AND   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;amp; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OR    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] | R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;INV   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d14 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1          : R[dest] = ~R[op1]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;XOR   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d15 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] ^ R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; cpu &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; clock
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reset
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; write&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; CPU write request
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; read&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; CPU read request
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; address&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; read&#x2F;write address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; dout&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;],    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; write data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;27&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; din&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; read data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;28&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;29&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;30&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    .clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;),&lt;&#x2F;span&gt;&lt;span&gt; .rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;31&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;span&gt; reg&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;][&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; CPU Registers
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;32&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;33&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    instRom instRom  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; program ROM
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;35&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;36&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; op&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; opcode
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; first arg
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; second arg
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;39&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; destination arg
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;40&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; constant arg
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;41&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;42&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;43&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; defaults
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;44&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        write &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t write
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;45&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        read &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t read
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;46&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8hxx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t care
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;47&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        dout &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8hxx    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t care
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;48&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;49&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        instRom.address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reg 0 is program counter
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;50&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; increment PC by default
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;51&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;52&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        op &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; opcode is top 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;53&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        dest &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest is next 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;54&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        arg1 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; arg1 is next 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;55&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        arg2 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; arg2 is last 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;56&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        constant &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; constant is last 8 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;57&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;58&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; Perform the operation
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;59&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;case &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;op&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;60&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;61&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                read &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1                                  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; request a read
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;62&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; din                         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; save the data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;63&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; arg2              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;64&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;65&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                write &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1                                 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; request a write
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;66&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                dout &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]                        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; output the data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;67&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; arg2              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;68&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;69&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; constant                    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the reg to constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;70&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;71&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; less-than comparison
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;72&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;73&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ==&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; equals comparison
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;74&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;75&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ==&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; if R[dest] == constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;76&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                    reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next instruction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;77&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BNEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;78&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] !=&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; if R[dest] != constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;79&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                    reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next instruction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;80&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;81&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; addition
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;82&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SUB&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;83&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] -&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; subtraction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;84&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHL&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;85&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; shift left
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;86&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;87&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; shift right
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;88&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;AND&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;89&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;amp;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise AND
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;90&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;91&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] |&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise OR
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;92&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;INV&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;93&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] = ~&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise invert
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;94&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;XOR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;95&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ^&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise XOR
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;96&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;97&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;98&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The astute observer will notice that the entire CPU file is less than 100 lines long! 
It&#x27;s pretty amazing how much functionality you can get with such a simple design.&lt;&#x2F;p&gt;
&lt;p&gt;Take a look at the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;global&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; block at the beginning of the file.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;global &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;NOP   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; 0 filled
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, offset  : R[dest] = M[R[op1] + offset]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; src, op1, offset   : M[R[op1] + offset] = R[src]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d3  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, const        : R[dest] = const
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d4  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;lt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d5  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] == R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d6  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; op1, const         : R[0] = R[0] + (R[op1] == const ? 2 : 1)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BNEQ  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d7  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; op1, const         : R[0] = R[0] + (R[op1] != const ? 2 : 1)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d8  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] + R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SUB   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d9  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] - R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHL   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d10 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;lt;&amp;lt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHR   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;gt;&amp;gt; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;AND   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] &amp;amp; R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OR    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] | R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;INV   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d14 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1          : R[dest] = ~R[op1]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;XOR   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d15 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest, op1, op2     : R[dest] = R[op1] ^ R[op2]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This block allows us to define constants that can be used in any Lucid file in our project. 
This is helpful since we will be using these in our instruction ROM. 
The name you give a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;global&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; block is the &lt;em&gt;namespace&lt;&#x2F;em&gt; that its contents live in. &lt;&#x2F;p&gt;
&lt;p&gt;To access a globally defined constant, you use the syntax &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Namespace&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CONST&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;The name of a &lt;em&gt;namespace&lt;&#x2F;em&gt; needs to start with a capital and contain at least one lowercase letter.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;30&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    .clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;),&lt;&#x2F;span&gt;&lt;span&gt; .rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;31&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;span&gt; reg&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;][&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; CPU Registers
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;32&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Our CPU&#x27;s registers are nothing other than a set of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. 
We use a 2D array of 16 by 8 since we want 16 registers with a width of 8 bits.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    instRom instRom  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; program ROM
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We can&#x27;t forget our program ROM! 
We will cover the actual ROM in a bit. 
However, it has only two ports, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;address&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;inst&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;It outputs the corresponding instruction on &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;inst&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for the given &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;address&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; defaults
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        write &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t write
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;39&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        read &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t read
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;40&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8hxx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t care
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;41&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        dout &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8hxx    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; don&amp;#39;t care
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In the beginning of an &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; block, it is a good idea to assign defaults at the top so you don&#x27;t have to worry about 
assigning a value in every possible conditional branch. &lt;&#x2F;p&gt;
&lt;p&gt;In this case, by default we don&#x27;t want to perform a read or write, and if we aren&#x27;t performing a read or write, 
we don&#x27;t care what the values of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;address&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; or &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;dout&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; are.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;43&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        instRom.address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reg 0 is program counter
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;44&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; increment PC by default
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We decided to use the first register as our program counter. 
This means we are going to feed its value into the instruction ROM. &lt;&#x2F;p&gt;
&lt;p&gt;We also need to increment it each cycle so that our program continues to execute. 
Since the line to perform the increment comes before the code to execute the instruction, 
if the instruction writes to the first register, it will have precedence over the increment. 
This will allow us to manipulate the program counter with our code.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;46&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; op&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; opcode is top 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;47&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; dest is next 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;48&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; arg1 is next 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;49&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; arg2 is last 4 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;50&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; instRom.inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; constant is last 8 bits
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;These signals aren&#x27;t strictly needed, but they help make the code a bit more readable by allowing us to rename parts of the instruction.&lt;&#x2F;p&gt;
&lt;p&gt;The way we defined our instruction set, the &lt;em&gt;opcode&lt;&#x2F;em&gt; is always the four most-significant bits.
The other four signals are just the common names for the different parts of the instruction.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;52&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; Perform the operation
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;53&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;case &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;op&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;54&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LOAD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;55&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                read &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1                                  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; request a read
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;56&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; din                         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; save the data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;57&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; arg2              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;58&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;59&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                write &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1                                 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; request a write
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;60&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                dout &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]                        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; output the data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;61&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; arg2              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;62&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;63&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; constant                    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; set the reg to constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;64&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;LT&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;65&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; less-than comparison
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;66&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;EQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;67&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ==&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; equals comparison
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;68&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;69&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ==&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; if R[dest] == constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;70&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                    reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next instruction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;71&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BNEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;72&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] !=&lt;&#x2F;span&gt;&lt;span&gt; constant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; if R[dest] != constant
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;73&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                    reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] + &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next instruction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;74&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;75&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] +&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; addition
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;76&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SUB&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;77&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] -&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; subtraction
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;78&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHL&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;79&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; shift left
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;80&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SHR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;81&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; shift right
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;82&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;AND&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;83&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &amp;amp;&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise AND
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;84&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;85&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] |&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise OR
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;86&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;INV&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;87&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] = ~&lt;&#x2F;span&gt;&lt;span&gt;reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise invert
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;88&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;XOR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;89&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                reg.d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;dest&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] =&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] ^&lt;&#x2F;span&gt;&lt;span&gt; reg.q&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;arg2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; bit-wise XOR
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;90&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here we execute the instruction. 
You may be surprised how simple this is. &lt;&#x2F;p&gt;
&lt;p&gt;We use a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; statement to select what behavior we want.
When &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;op&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; matches a specific instruction, the corresponding branch of the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; statement is evaluated.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-program&quot;&gt;The Program&lt;&#x2F;h1&gt;
&lt;p&gt;Now that we have a CPU, we need to write a program for it. &lt;&#x2F;p&gt;
&lt;p&gt;Before getting deep into it, let&#x27;s get something running to make sure everything is working.&lt;&#x2F;p&gt;
&lt;p&gt;Create a new module &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;instRom&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and paste in the following.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; instRom &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; address&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;],
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; inst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;NOP&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;12b0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;case &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;address&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; begin:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R2, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; loop:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d128&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R1, 128
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; STORE R2, R1, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R1, 1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; ADD R2, R2, R1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R15, loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;6&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R0, delay
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; delay:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R11, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R12, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;9&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R13, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R1, 1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; delay_loop:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; ADD R11, R11, R1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; BEQ R11, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;27&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R0, delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;28&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;14&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; ADD R12, R12, R1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;29&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; BEQ R12, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;30&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R0, delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;31&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;17&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; ADD R13, R13, R1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;32&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;18&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; BEQ R13, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;33&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;19&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R0, delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;20&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; SET R1, 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;35&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;21&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; inst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= c{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;Inst&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;4d1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; ADD R0, R15, R1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;36&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This code will slowly increment a counter and output it to address 128. 
We will go over the details of it a bit later, but first let us hook it up to the LEDs.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; alchitry_top &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; 100MHz clock
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; rst_n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reset button (active low)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; led&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;],          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; 8 user controllable LEDs
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; usb_rx&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; USB-&amp;gt;Serial input
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; usb_tx           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; USB-&amp;gt;Serial output
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; rst                 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reset signal
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    .clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; The reset conditioner is used to synchronize the reset signal to the FPGA
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; clock. This ensures the entire FPGA comes out of reset at the same time.
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        reset_conditioner reset_cond
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        .rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            cpu cpu        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; our snazzy CPU
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;span&gt; led_reg&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; storage for LED value
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        reset_cond.in &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= ~&lt;&#x2F;span&gt;&lt;span&gt;rst_n  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; input raw inverted reset signal
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        rst &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; reset_cond.out    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; conditioned reset
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        led &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; led_reg.q         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; connect LEDs to led_reg
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;27&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;28&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        usb_tx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; usb_rx         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; echo the serial data
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;29&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;30&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        cpu.din &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8hxx          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; default to don&amp;#39;t care
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;31&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;32&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; if cpu uses address 128
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;33&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;cpu.address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;== &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;34&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;cpu.write&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;35&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                led_reg.d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; cpu.dout &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; update the LED value
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;36&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;cpu.read&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;37&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;                cpu.din &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; led_reg.q  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; let the CPU read the LED value
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;38&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;39&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;40&lt;&#x2F;td&gt;&lt;td&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;alchitry_top&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; we need to add the CPU and a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to hold the value for the LEDs. 
When the CPU writes to address &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, we can save the value in the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and connect that to the LEDs. 
This way, the CPU can directly control the LEDs by writing to this address!&lt;&#x2F;p&gt;
&lt;p&gt;Why use address &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;? 
In practice, we could have chosen any address, but the reason we used &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instead of, say &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, 
is because the first half of the address space is typically reserved for RAM. &lt;&#x2F;p&gt;
&lt;p&gt;Our CPU doesn&#x27;t currently have access to RAM, but we &lt;em&gt;could&lt;&#x2F;em&gt; hook it up to some. 
Using a memory interface like this to perform IO is known as &lt;strong&gt;memory mapped IO&lt;&#x2F;strong&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;This is how basically all CPUs perform IO. 
If you&#x27;ve ever worked with AVRs and written something like &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;PORTA &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; 0x5A&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, 
&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;PORTA&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is actually just a special memory address that instead of writing to RAM writes to the IO port (exactly what we are doing here).&lt;&#x2F;p&gt;
&lt;p&gt;Go ahead and build&#x2F;load the project to your board. 
The LEDs should now count slowly.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-assembler&quot;&gt;The Assembler&lt;&#x2F;h1&gt;
&lt;p&gt;While we could write the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;instRom&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; module ourselves to create programs, but it becomes a huge pain to edit them. 
If you want to insert an instruction, you have to renumber everything. 
It is a nightmare. &lt;&#x2F;p&gt;
&lt;p&gt;Luckily, we don&#x27;t have to! 
I wrote a basic assembler for us (you&#x27;re welcome ❤️). 
You can find the assembler code on &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;embmicro&#x2F;SkinnyAssembler&quot;&gt;GitHub&lt;&#x2F;a&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;If you just want to download the runnable JAR you can &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;embmicro&#x2F;SkinnyAssembler&#x2F;raw&#x2F;master&#x2F;skinny-asm.jar&quot;&gt;click here&lt;&#x2F;a&gt;. 
It should run on any OS with Java 1.7 or later.&lt;&#x2F;p&gt;
&lt;p&gt;I used &lt;a href=&quot;http:&#x2F;&#x2F;www.antlr.org&#x2F;&quot;&gt;ANTLR&lt;&#x2F;a&gt; to parse the assembly. 
This is an awesome library that makes writing something like this pretty easy.&lt;&#x2F;p&gt;
&lt;p&gt;To use the assembler, use the following command.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-bash &quot;&gt;&lt;code class =&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#6699cc;&quot;&gt;java&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt; -jar&lt;&#x2F;span&gt;&lt;span style=&quot;color:#6699cc;&quot;&gt; skinny-asm.jar assembly-file.asm
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It should then turn your assembly in &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;assembly&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file.asm&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; into the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;instRom&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; module, or tell you what&#x27;s wrong with your file.&lt;&#x2F;p&gt;
&lt;p&gt;Here is the assembly file I used to generate the ROM from earlier.&lt;&#x2F;p&gt;
&lt;pre data-linenos data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;begin&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:  
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R2 = 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;loop&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128         &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R1 = 128
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE R2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; M[128] = R2
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R1 = 1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD R2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R2++
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; loop       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R15 = loop, R15 is return address
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; delay       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; goto delay
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;delay&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R11 = 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R12 = 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R13 = 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R1 = 1
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;delay_loop&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD R11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R11++
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ R11&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next if (R11 == 0)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; delay_loop  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; goto delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD R12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R12++
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ R12&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next if (R12 == 0)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; delay_loop  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; goto delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD R13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R13++
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BEQ R13&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0          &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; skip next if (R13 == 0)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; delay_loop  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; goto delay_loop
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;25&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET R1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0           &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R1 = 0
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;tr&gt;&lt;td&gt;26&lt;&#x2F;td&gt;&lt;td&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD R0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; R0 = R15 (return)
&lt;&#x2F;span&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;There are two types of lines that the assembler will accept, labels and instructions. 
A label is simply a name followed by a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. 
These act as constants that will be replaced with the line number of the instruction following it. &lt;&#x2F;p&gt;
&lt;p&gt;For example, the label &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;begin&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; in the above code will have value &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; since it is before the first instruction. 
These make it easy to reference instructions without having to rely on fixed numbers (to avoid the insert problem).&lt;&#x2F;p&gt;
&lt;p&gt;Instructions consist of the name of the &lt;em&gt;opcode&lt;&#x2F;em&gt; followed by a list of comma-separated arguments. &lt;&#x2F;p&gt;
&lt;p&gt;Constants can either be a decimal number or a label. &lt;&#x2F;p&gt;
&lt;p&gt;Registers take the form &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the register number.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;writing-code&quot;&gt;Writing Code&lt;&#x2F;h1&gt;
&lt;p&gt;While our CPU only treats &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; specially (it&#x27;s the program counter), it is helpful to assign special roles to some registers for use in our programs. 
For example, for many instructions it can be handy to have a temporary register to load a constant into. 
I used &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for this purpose. The other special register I used was &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to store the return address from a function call (more on this later).&lt;&#x2F;p&gt;
&lt;p&gt;The goal of this program was to count and output the count to address &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. 
Since we have no external RAM, all our memory needs to fit in the 16 registers. 
I chose &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to store our primary counter.&lt;&#x2F;p&gt;
&lt;p&gt;The first line initializes &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, we then enter the main loop. 
The main loop starts by writing &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to address &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. 
&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is used to store the constant &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;128&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; used as the address for the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STORE&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instruction. 
We then increment &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; by one. 
Again, we use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to store the constant &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to add to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;We could simply loop here. 
However, it would count way too fast for us to see on the LEDs. 
So we need to create a delay function. &lt;&#x2F;p&gt;
&lt;p&gt;A function is just a block of code that can be called from anywhere and will return to where it&#x27;s called from. 
We use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to specify the address we want to return to. 
In our case, we cheat a little bit and set &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to the beginning of our loop instead of the instruction after the call to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;delay&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. 
This is just a little more efficient.&lt;&#x2F;p&gt;
&lt;p&gt;We can use the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SET&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instruction with &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to jump to anywhere in our program. 
This is where labels are really helpful since we don&#x27;t care what the actual instruction number is as the label will get replaced with the proper value.&lt;&#x2F;p&gt;
&lt;p&gt;The delay function uses &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R11&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R12&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R13&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to count from 0 to 16,777,215. 
This takes a decent amount of time so we can actually see the LEDs change.&lt;&#x2F;p&gt;
&lt;p&gt;Once the counter overflows, the delay function returns to the address in &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; using the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;ADD&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instruction to set &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;R15&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Try editing this code, or write your own program! 
Feel free to even swap out some instructions for your own if you can think of something more useful. 
Maybe you&#x27;d rather have an instruction for directly setting a bit instead of XOR, or maybe you would rather be able to tell if a value is even instead of shifting right.&lt;&#x2F;p&gt;
&lt;p&gt;That&#x27;s it for this tutorial. 
I hope you enjoyed making a basic CPU! 
It&#x27;s pretty awesome to write code for hardware that you designed! 
Go make something awesome!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Vivado Setup</title>
        <published>2025-07-29T00:00:00+00:00</published>
        <updated>2025-07-29T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/introduction/vivado/"/>
        <id>https://alchitry.com/tutorials/introduction/vivado/</id>
        
        <content type="html" xml:base="https://alchitry.com/tutorials/introduction/vivado/">&lt;p&gt;The first step to setting up your environment is to install Vivado. Vivado is a program provided by Xilinx (the manufacture of the FPGA on the Au) that is used to build your projects. It holds all the secret sauce that converts your text into an FPGA configuration file (bin file).&lt;&#x2F;p&gt;
&lt;p&gt;Head over to Xilinx&#x27;s website and download the &lt;a href=&quot;https:&#x2F;&#x2F;www.xilinx.com&#x2F;support&#x2F;download.html&quot;&gt;Vivado here&lt;&#x2F;a&gt;. 
Avoid version 2020.3.&lt;&#x2F;p&gt;
&lt;p&gt;I recommend downloading the &lt;em&gt;Web Installer&lt;&#x2F;em&gt; as it will save you time. 
As of 2024.1, it they only offer the &lt;em&gt;Web Installer&lt;&#x2F;em&gt;.
During installation, you get to select what gets installed saving space as well.&lt;&#x2F;p&gt;
&lt;p&gt;You will need to create an account with Xilinx to download the software. 
This is required by the U.S. government since the software falls under some export regulations.&lt;&#x2F;p&gt;
&lt;p&gt;You will also need this account during installation for the web installer to be able to download the various components.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;launching-the-installer&quot;&gt;Launching the Installer&lt;&#x2F;h2&gt;
&lt;p&gt;If you are running Windows, double-click the .exe file that you downloaded.&lt;&#x2F;p&gt;
&lt;p&gt;If you are on Linux, you may need to add execution privileges to the .bin file. 
You can do that with the following command.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#282828;color:#ffffff;&quot;&gt;&lt;code&gt;&lt;span&gt;chmod +x Xilinx_Vivado_File.bin
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You will need to change the name of the .bin file to match the on you downloaded.&lt;&#x2F;p&gt;
&lt;p&gt;You can then run it. 
You don&#x27;t need root permissions if you are installing it somewhere you already have write permissions. 
I usually install mine to &lt;code&gt;&#x2F;opt&#x2F;Xilinx&lt;&#x2F;code&gt; which I have set up to be owned by me.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;installing&quot;&gt;Installing&lt;&#x2F;h2&gt;
&lt;p&gt;The installer itself is pretty straight forward. &lt;&#x2F;p&gt;
&lt;p&gt;First, you will have to log in to your account.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;setup&#x2F;login.png&quot; alt=&quot;Installer Login&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You&#x27;ll then have to accept some terms and conditions. 
The page after that asks what product you would like to install.
Select &lt;em&gt;Vivado&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;setup&#x2F;vivado.png&quot; alt=&quot;Product Selection&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The next page asks what edition to install.
If you don&#x27;t want to pay for a license, select the &lt;em&gt;Standard&lt;&#x2F;em&gt; version.
The main difference between the two (other than cost) is the devices that are supported.
The free tier supports all the Alchitry boards.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;setup&#x2F;standard.png&quot; alt=&quot;Edition Selection&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The next page allows you to choose what you install.
The import option in our case is the &lt;em&gt;Artix-7 FPGAs&lt;&#x2F;em&gt; box under &lt;em&gt;7 Series&lt;&#x2F;em&gt; under &lt;em&gt;Devices&lt;&#x2F;em&gt;.
Nothing else is strictly required.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;setup&#x2F;artix.png&quot; alt=&quot;Install Components&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;On the next page, select where you want to install it.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;setup&#x2F;install.png&quot; alt=&quot;Install Location&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Now wack that &lt;em&gt;Install&lt;&#x2F;em&gt; button and let it do its thing.&lt;&#x2F;p&gt;
&lt;p&gt;When you go to use Alchitry Labs, you&#x27;ll need to point it to where Vivado is installed via the settings.
In my case, I pointed it to &lt;code&gt;&#x2F;opt&#x2F;Xilinx&#x2F;2025.1&#x2F;Vivado&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Register Interface</title>
        <published>2025-04-28T00:00:00+00:00</published>
        <updated>2025-04-28T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/intermediate/register-interface/"/>
        <id>https://alchitry.com/tutorials/intermediate/register-interface/</id>
        
        <summary type="html">&lt;p&gt;This tutorial will introduce you to the &lt;em&gt;Register Interface&lt;&#x2F;em&gt; component and how you can use it to easily implement
complex interfaces in your designs.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Pinouts and Custom Elements</title>
        <published>2025-02-25T00:00:00+00:00</published>
        <updated>2025-02-25T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/references/pinouts-and-custom-elements/"/>
        <id>https://alchitry.com/tutorials/references/pinouts-and-custom-elements/</id>
        
        <summary type="html">&lt;p&gt;This tutorial goes over all the information you need to create your own custom elements.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Constraints Reference</title>
        <published>2025-02-04T00:00:00+00:00</published>
        <updated>2025-02-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/references/alchitry-constraints-reference/"/>
        <id>https://alchitry.com/tutorials/references/alchitry-constraints-reference/</id>
        
        <summary type="html">&lt;p&gt;This page is a reference for Alchitry Constraints V2.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Lucid Reference</title>
        <published>2025-02-04T00:00:00+00:00</published>
        <updated>2025-02-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/references/lucid-reference/"/>
        <id>https://alchitry.com/tutorials/references/lucid-reference/</id>
        
        <summary type="html">&lt;p&gt;This page is a reference to the Lucid V2 language.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2.0.24 - Negative Indices</title>
        <published>2025-01-24T00:00:00+00:00</published>
        <updated>2025-01-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-0-24/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-0-24/</id>
        
        <summary type="html">&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs V2.0.24-BETA&lt;&#x2F;a&gt; is now out bringing many updates from the last blog post on 2.0.21.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2.0.21 - Alchitry Constraints Updated</title>
        <published>2024-12-26T00:00:00+00:00</published>
        <updated>2024-12-26T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-0-21-acf/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-0-21-acf/</id>
        
        <summary type="html">&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs V2.0.21-BETA&lt;&#x2F;a&gt; just dropped with support for the new &lt;a href=&quot;https:&#x2F;&#x2F;shop.alchitry.com&#x2F;collections&#x2F;all&quot;&gt;Alchitry V2 boards&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;To properly support the new boards, the format for Alchitry Constraint Files (ACF) was updated. </summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry V2 - Production Begins</title>
        <published>2024-12-09T00:00:00+00:00</published>
        <updated>2024-12-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-v2-design-update/"/>
        <id>https://alchitry.com/news/alchitry-v2-design-update/</id>
        
        <summary type="html">&lt;p&gt;It has been a busy couple of months and things are starting to come together!&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry V2 - All New Boards</title>
        <published>2024-11-13T00:00:00+00:00</published>
        <updated>2024-11-13T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-v2/"/>
        <id>https://alchitry.com/news/alchitry-v2/</id>
        
        <summary type="html">&lt;p&gt;It&#x27;s official, all the boards are being redesigned into a new form factor.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Platinum and Board Rework</title>
        <published>2024-10-09T00:00:00+00:00</published>
        <updated>2024-10-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-platinum-v2/"/>
        <id>https://alchitry.com/news/alchitry-platinum-v2/</id>
        
        <summary type="html">&lt;p&gt;The Alchitry Platinum (Pt), is in the early stages of design. 
This version will most likely be based on the XC7A100T-2FGG484C FPGA.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - snake_case</title>
        <published>2024-09-23T00:00:00+00:00</published>
        <updated>2024-09-23T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-snake-case/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-snake-case/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-snake-case/">&lt;p&gt;Alchitry Labs V2.0.17 just release and is a major shift from previous releases.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;snake-case&quot;&gt;snake_case&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#snake-case&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;When starting on Lucid V2, I had originally though to make &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;camelCase&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; the default style for names.
However, I think this was a poor choice for a few reasons and decided to switch to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The biggest reason to use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is because this is what is used by Verilog.
All the Xilinx tools use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; so when mixing Lucid and Verilog it is nicer to have a consistent style.&lt;&#x2F;p&gt;
&lt;p&gt;Lucid V1 was also mostly documented in &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; but the styling wasn&#x27;t super consistent.
This is what made me think to switch in the first place.
I generally prefer the aesthetics of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;camelCase&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, but writing &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;rst_n&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; as &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;rstN&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is just awful.&lt;&#x2F;p&gt;
&lt;p&gt;Adding a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;_n&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; or &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;_p&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; suffix to names is common with differential signals (as seen in the DDR3 MIG module).
Single letters are hard to discern in &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;camelCase&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and are much better in &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-changed&quot;&gt;What Changed&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#what-changed&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;In V2.0.17, all the components and example projects switched to use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for names.&lt;&#x2F;p&gt;
&lt;p&gt;Functions names also changed so &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$silentTick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; became &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$silent_tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The keyword &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;testBench&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; also changed to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;testbench&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.
It seems a bit inconsistent if the word testbench is two words or one, but it seems like it is more often seen as one.
I also thought using &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;test_bench&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; as a keyword felt weird.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;auto-migration&quot;&gt;Auto-migration&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#auto-migration&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;If you open an older project with Alchitry Labs V2.0.17 or newer, it will automatically migrate your code.
This means files will be renamed and all &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;camelCase&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; will be replaced with &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Also, in the Io constraints and examples &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;ioSel&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; became &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;io_select&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;ioSeg&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; became &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;io_segment&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for clarity.
The migration will change these names as well.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;m sorry for any inconvenience this causes to anyone already using Alchitry Labs V2, but I believe in the long run this is the better choice.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll be updating the tutorials and documentation today to reflect these changes.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>DDR3 Memory</title>
        <published>2024-09-23T00:00:00+00:00</published>
        <updated>2024-09-23T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/advanced/ddr3-memory/"/>
        <id>https://alchitry.com/tutorials/advanced/ddr3-memory/</id>
        
        <summary type="html">&lt;p&gt;In this tutorial we are going to set up an interface to the DDR3 memory with the FPGA on the Alchitry Au or Pt.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Hello YOUR_NAME_HERE</title>
        <published>2024-09-19T00:00:00+00:00</published>
        <updated>2024-09-19T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/hello-your-name-here/"/>
        <id>https://alchitry.com/tutorials/starter/hello-your-name-here/</id>
        
        <summary type="html">&lt;p&gt;In this tutorial we will be personalizing the greeter so that it first asks for your name and then prints &amp;quot;Hello NAME&amp;quot; where NAME is the name you entered.
To do this we will need some form of memory and in this case we will use a single port RAM.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>ROMs and FSMs</title>
        <published>2024-09-19T00:00:00+00:00</published>
        <updated>2024-09-19T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/roms-and-fsms/"/>
        <id>https://alchitry.com/tutorials/starter/roms-and-fsms/</id>
        
        <summary type="html">&lt;p&gt;In this tutorial we will create a project that will send &amp;quot;Hello World!&amp;quot; over the USB (serial) port when the letter &amp;quot;h&amp;quot; is received. 
This will help teach you how to use finite state machines (FSM).&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Serial Interface</title>
        <published>2024-09-19T00:00:00+00:00</published>
        <updated>2024-09-19T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/serial-interface/"/>
        <id>https://alchitry.com/tutorials/starter/serial-interface/</id>
        
        <summary type="html">&lt;p&gt;In this tutorial we will use the USB port and create a project that will echo back all the data sent to the Alchitry board.
This will teach you how to use the &lt;em&gt;Component Library&lt;&#x2F;em&gt; in your projects.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Io Element</title>
        <published>2024-09-18T00:00:00+00:00</published>
        <updated>2024-09-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/io-element/"/>
        <id>https://alchitry.com/tutorials/starter/io-element/</id>
        
        <summary type="html">&lt;p&gt;This tutorial will introduce the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;boards&#x2F;io&#x2F;&quot;&gt;Io Element&lt;&#x2F;a&gt; and walk through some basic examples to get your feet wet.&lt;&#x2F;p&gt;
&lt;p&gt;If you don&#x27;t own an Io Element, you can still follow along using the simulator.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Synchronous Logic</title>
        <published>2024-09-17T00:00:00+00:00</published>
        <updated>2024-09-17T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/synchronous-logic/"/>
        <id>https://alchitry.com/tutorials/starter/synchronous-logic/</id>
        
        <summary type="html">&lt;p&gt;In this tutorial you will be introduced to the &lt;em&gt;D flip-flop&lt;&#x2F;em&gt; and how you can use these to make an LED blink.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - Now in Beta!</title>
        <published>2024-09-16T00:00:00+00:00</published>
        <updated>2024-09-16T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-beta/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-beta/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-beta/">&lt;p&gt;Alchitry Labs V2.0.14 is now released, and with it the status of the project changes from preview to beta!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs-2.0.14-beta.png&quot; alt=&quot;Alchitry Labs V2.0.14 Beta&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You can &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;download it here&lt;&#x2F;a&gt; and help out by reporting any issues you encounter to the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;issues&quot;&gt;GitHub issues page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-s-new&quot;&gt;What&#x27;s New&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#what-s-new&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Before getting into the technical details of V2, lets look at the fun stuff, what&#x27;s new.&lt;&#x2F;p&gt;
&lt;p&gt;The first thing you&#x27;re likely to notice is the UI has been revamped. 
It is based on a modern UI toolkit that allows for easy animations, Sublime-style scroll bars, interactive virtual boards, and drag-and-drop window splitting.&lt;&#x2F;p&gt;
&lt;p&gt;Alchitry Labs V2 supports the new &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;references&#x2F;lucid-reference&#x2F;&quot;&gt;Lucid V2&lt;&#x2F;a&gt;.
See the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;news&#x2F;lucid-1-vs-2&#x2F;&quot;&gt;V1 vs V2 blog post&lt;&#x2F;a&gt; for a summary of what has changed. &lt;&#x2F;p&gt;
&lt;p&gt;Support for Lucid V2 is so much deeper than Lucid V1 ever was. 
Alchitry Labs now creates a full model of your Lucid code.
This causes plenty of errors that would just fly under the radar in V1 to be caught and reported in real-time.
It also allows for your project to be simulated.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;simulations&quot;&gt;Simulations&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#simulations&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;By clicking the little bug icon, you can launch the simulator.
It currently supports the base board (Au, Au+, or Cu) as well as the Io.&lt;&#x2F;p&gt;
&lt;p&gt;The simulator is an interactive virtual board running your design.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs-2.0.8-preview.gif&quot; alt=&quot;Alchitry Labs 2.0.8&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You can toggle the DIP switches or press the buttons by clicking on them.
PWM effects are also simulated on LEDs allowing for fade effects or multiplexing of the Io element&#x27;s 7-segment displays.&lt;&#x2F;p&gt;
&lt;p&gt;The only real catch is the simulator can&#x27;t run as fast as dedicated hardware.
By default, it runs at 1KHz which is a fair bit slower than the 100MHz clock on the real board.
However, many educational designs don&#x27;t need a fast clock.
Hopefully, the Io simulator will make learning the basics that much easier.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;test-benches&quot;&gt;Test Benches&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-benches&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Alchitry Labs V2 supports test benches.
These allow you test out Lucid modules to make sure they are doing what you expect them to do.&lt;&#x2F;p&gt;
&lt;p&gt;In a test block, you can manipulate the values feeding into a module then check their outputs.
In the event that things didn&#x27;t go according to plan, the values of every signal at every step of the simulation are saved, and you can view them after it finishes.
See the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;news&#x2F;lucid-v2-update-2&#x2F;&quot;&gt;test bench blog post&lt;&#x2F;a&gt; for more details.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;open-source-tools&quot;&gt;Open Source Tools&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#open-source-tools&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Using the open source tools (&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;YosysHQ&#x2F;yosys&quot;&gt;yosys&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;YosysHQ&#x2F;nextpnr&quot;&gt;nextpnr&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;YosysHQ&#x2F;icestorm&quot;&gt;icestorm&lt;&#x2F;a&gt;) for the Cu has never been easier.
Alchitry Labs V1 had support for some of the older open source tools, but you had to install them yourself.
V2 now comes with the open source tools so you can use them out of the box for the Cu.&lt;&#x2F;p&gt;
&lt;p&gt;This also means that you can now build projects for the Cu natively on a Mac!&lt;&#x2F;p&gt;
&lt;p&gt;Currently, the open source tools don&#x27;t support the Artix 7 used on the Au, but they are in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;gatecat&#x2F;nextpnr-xilinx&#x2F;&quot;&gt;development&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;all-the-small-things&quot;&gt;All The Small Things&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#all-the-small-things&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Alchitry Labs V2 has been in the works for over two years now.
There are way too many things to list here that has changed.&lt;&#x2F;p&gt;
&lt;p&gt;Most of the important changes are under the hood and will allow future improvements to continue in a sustainable way.&lt;&#x2F;p&gt;
&lt;p&gt;I hope you&#x27;ll head over to the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;download page&lt;&#x2F;a&gt; and check it out.
You can leave any general feedback on the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;discussions&quot;&gt;discussions page&lt;&#x2F;a&gt; and report any issues to the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;issues&quot;&gt;issues page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;why-v2&quot;&gt;Why V2&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#why-v2&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Alchitry Labs was originally the Mojo IDE. The goal of the Mojo IDE was to both create an IDE with creature comforts like real-time syntax error checking and support a new HDL, Lucid, to make programming FPGAs more accessible.&lt;&#x2F;p&gt;
&lt;p&gt;The initial Lucid support was very basic. The IDE would show any syntax errors, but nothing more in depth than that.&lt;&#x2F;p&gt;
&lt;p&gt;The focus was on creating a Lucid -&amp;gt; Verilog translator so you could even use it. 
Only later, more indepth parsing was added.&lt;&#x2F;p&gt;
&lt;p&gt;At first, only the widths of signals and expressions were checked. 
It was able to warn you if an assignment would truncate your value.&lt;&#x2F;p&gt;
&lt;p&gt;Over time, the types of errors being checked continued to grow. 
Eventually, it was doing full parsing of constant values.&lt;&#x2F;p&gt;
&lt;p&gt;This lead to the idea that the parser could be used to simulate Lucid. 
All you have to do is run it over and over right... right?
Turned out to be a tad more complicated.&lt;&#x2F;p&gt;
&lt;p&gt;When looking into how to actually turn the parser into a simulator, it was clear the pile of tech debt had grown too much to ignore any longer. 
I started writing the Mojo IDE a decade ago during my junior year of college. 
It was by far the biggest piece of software I had written and I made plenty of questionable design choices.&lt;&#x2F;p&gt;
&lt;p&gt;To make any meaningful improvements, a full rewrite looked like the only practical way forward.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;new-tools&quot;&gt;New Tools&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#new-tools&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Since things were starting over, I was able to overhaul the GUI. 
V1 was based on the aging SWT. 
V2 is based on Compose.
While I appreciated that SWT kept the look and feel of the native desktop environment, Compose is enormously more flexible.
The new interactive virtual boards would have been incredibly difficult to pull off with SWT. &lt;&#x2F;p&gt;
&lt;p&gt;The other major shift is that V2 is pure Kotlin. 
I was notoriously bad at checking for null values in the original Java based parser causing a vast number of bugs that would simply crash the IDE.
Kotlin&#x27;s built-in null safety has been incredibly helpful.&lt;&#x2F;p&gt;
&lt;p&gt;Kotlin&#x27;s other features, like coroutines, have also been instrumental for building out the simulator in an efficient manner.&lt;&#x2F;p&gt;
&lt;p&gt;The last fundamental change was in the build system.
Before V2, building distributables was a nightmare.
It was a multistep error-prone process including firing up a Windows VM to build the Windows executable and installer.
This inherently lead to infrequent updates since they were such a pain.&lt;&#x2F;p&gt;
&lt;p&gt;The new system relies on &lt;a href=&quot;https:&#x2F;&#x2F;conveyor.hydraulic.dev&#x2F;&quot;&gt;Hydraulic Conveyor&lt;&#x2F;a&gt;.
This software is awesome.
It lets me build and publish distributables for Windows, Linux, and Mac, with one click from Linux.
It is also free for open source software.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-s-next&quot;&gt;What&#x27;s Next&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#what-s-next&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;With the beta released, the next step is to update the tutorials.
I&#x27;ll be working on the first few this week.&lt;&#x2F;p&gt;
&lt;p&gt;Looking back at the V1 tutorials, I&#x27;m a bit disappointed I never got into the depth I should have.
I&#x27;m planning to rectify that with V2.&lt;&#x2F;p&gt;
&lt;p&gt;These will go hand in hand with work on the IDE.
The best place to see what&#x27;s coming is the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;issues&quot;&gt;issues page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Your First FPGA Project</title>
        <published>2024-09-16T00:00:00+00:00</published>
        <updated>2024-09-16T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/tutorials/starter/your-first-fpga-project/"/>
        <id>https://alchitry.com/tutorials/starter/your-first-fpga-project/</id>
        
        <summary type="html">&lt;p&gt;This tutorial will walk you through creating your first project in Alchitry Labs and making the onboard LED light up when you press the
reset button.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2.0.13 - Verilog Interoperability</title>
        <published>2024-08-28T00:00:00+00:00</published>
        <updated>2024-08-28T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-0-13-verilog/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-0-13-verilog/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-0-13-verilog/">&lt;p&gt;Today version &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;releases&#x2F;tag&#x2F;2.0.13&quot;&gt;V2.0.13&lt;&#x2F;a&gt; of Alchitry Labs was released!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;verilog-interoperability&quot;&gt;Verilog Interoperability&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#verilog-interoperability&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;A ton has changed&#x2F;been added since the last post about &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;news&#x2F;alchitry-labs-v2-0-8&#x2F;&quot;&gt;V2.0.8&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The biggest feature, by far, is the addition of Verilog interoperability.&lt;&#x2F;p&gt;
&lt;p&gt;You can now add Verilog modules and instantiate them from Lucid. This was an important missing feature to allow for vendor specific things to be easily integrated into Lucid projects.&lt;&#x2F;p&gt;
&lt;p&gt;For example, in a Verilog module, you can instantiate the primitives outlined in &lt;a href=&quot;https:&#x2F;&#x2F;docs.amd.com&#x2F;viewer&#x2F;book-attachment&#x2F;Lz7t3FLJuzYlv9pBdksO6Q&#x2F;ob7lIrXtxRMJLY4I6UEprg&quot;&gt;UG953&lt;&#x2F;a&gt; for the Au&#x2F;Au+. This is important for stuff like the upcoming &lt;em&gt;Alchitry Hd&lt;&#x2F;em&gt; that utilizes the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;OSERDESE2&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; primitive to output HDMI video data.&lt;&#x2F;p&gt;
&lt;p&gt;While the entire Verilog module is checked for syntax error in the editor, Alchitry Labs doesn&#x27;t look at the content inside the Verilog modules. It only ever looks at the module interface (parameters and ports).&lt;&#x2F;p&gt;
&lt;p&gt;This means that Verilog inside Alchitry Labs has a lot less guards in place and should only really be used as glue to existing Verilog.&lt;&#x2F;p&gt;
&lt;p&gt;It also has the major downside that Verilog modules are essentially ignored during simulations.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;string-indexing&quot;&gt;String Indexing&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#string-indexing&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;To make Verilog smoothly interoperate with Lucid, the indexing for strings was reverted to how it worked in Lucid V1. That is, the right-most letter is index 0 instead of the left-most.&lt;&#x2F;p&gt;
&lt;p&gt;For example, the string &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;Hello&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; in Lucid is represented as an &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;][&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; array where index &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; points to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;o&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. In V2.0.12 and earlier, index &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; pointed to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;H&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;You can use the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$reverse&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function to restore the indexing to the previous behavior.&lt;&#x2F;p&gt;
&lt;p&gt;Verilog uses the right-side indexing so it now matches. This was important for passing strings as parameters which is often done with Xilinx&#x27;s primitives. Before this change, the Verilog side would see the strings as reversed causing them not to be recognized.&lt;&#x2F;p&gt;
&lt;p&gt;While having the right side of string be index 0 seems a little strange, it does nicely match how arrays and everything else are indexed. Now, the right side is always index 0.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;build-flow&quot;&gt;Build Flow&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#build-flow&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The way projects are built underwent a huge change. Previously, when building a project, the tools would start with the top-level module and build out a tree of all instantiated modules underneath it. This has the huge benefit of knowing what all the parameter values are as they &lt;strong&gt;must&lt;&#x2F;strong&gt; be specified at this point.&lt;&#x2F;p&gt;
&lt;p&gt;The big downside of this, is that a separate Verilog translation needs to happen for every different combination of parameters on a module. For example, if you used a counter module and set it&#x27;s parameter &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;#&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SIZE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; but in another location used the counter with &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;#&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;SIZE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; then two separate Verilog modules would have been generated.&lt;&#x2F;p&gt;
&lt;p&gt;This was a fairly small downside to making all constant values calculable when converting to Verilog. However, it has the big downside of making it impossible to call a Lucid module directly from Verilog.&lt;&#x2F;p&gt;
&lt;p&gt;In the new version, each module is translated to Verilog in isolation properly using parameters. &lt;&#x2F;p&gt;
&lt;p&gt;This makes it possible for Lucid modules to be used inside Verilog modules.&lt;&#x2F;p&gt;
&lt;p&gt;It also likely helps the build tools to do things more optimally.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;&quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$isSim&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;A new function, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$isSim&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, was introduced. This function evaluates to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1b1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; if running in an interactive simulation and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1b0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; otherwise.&lt;&#x2F;p&gt;
&lt;p&gt;This is useful for dealing with the &lt;em&gt;much&lt;&#x2F;em&gt; slower clock speeds when running an interactive simulation (usually around 1,000 Hz instead of 100,000,000 Hz).&lt;&#x2F;p&gt;
&lt;p&gt;For example, providing a different &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DIV&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; parameter value to a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;multiSevenSeg&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; module with the following makes the display work well in simulation and builds.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;multiSevenSeg seg &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(#&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DIV&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$isSim&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;() ? &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;16&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Note that &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$isSim&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; evaluates to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1b0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; during test benches.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;beta-release&quot;&gt;Beta Release&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#beta-release&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Things are getting pretty close to the release of V2.1.0 which will mark the first beta release.&lt;&#x2F;p&gt;
&lt;p&gt;Check out the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;issues?q=is%3Aopen+is%3Aissue+milestone%3A%222.1.0+Beta+Release%22&quot;&gt;V2.1.0 Milestone on GitHub&lt;&#x2F;a&gt; to track the remaining features to be added before the release.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re using the preview builds and run into any issues, be sure to report them on &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;issues&quot;&gt;GitHub&lt;&#x2F;a&gt; so I can get them fixed ASAP!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2.0.8</title>
        <published>2024-05-14T00:00:00+00:00</published>
        <updated>2024-05-14T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-0-8/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-0-8/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-0-8/">&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs-2.0.8-preview.gif&quot; alt=&quot;Alchitry Labs 2.0.8&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Yesterday version 2.0.8 of &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs&lt;&#x2F;a&gt; was released.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s been a while since 2.0.7 was released, so I&#x27;ll do my best not to miss any import updates.&lt;&#x2F;p&gt;
&lt;p&gt;First off, there is now an official &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;references&#x2F;lucid-reference&#x2F;&quot;&gt;Lucid V2 Reference&lt;&#x2F;a&gt;. This page should be able to answer any questions you have about the details of Lucid V2.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;known-values&quot;&gt;Known Values&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#known-values&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;A major refactoring was done for determining if a value is &lt;em&gt;constant&lt;&#x2F;em&gt;. The old code would keep track of if a value was constant or not with a simple boolean.&lt;&#x2F;p&gt;
&lt;p&gt;This became a problem when working with &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; blocks. The issue is that the loop variable isn&#x27;t constant but it is known during synthesis and should be able to be used like a constant.&lt;&#x2F;p&gt;
&lt;p&gt;To fix this, the state of an expression is now marked as &lt;em&gt;dynamic&lt;&#x2F;em&gt;, &lt;em&gt;known&lt;&#x2F;em&gt;, or &lt;em&gt;constant&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;An important example of this is in the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;binToDec&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; component that uses the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$pow&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function with a loop variable.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; scale&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$width&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;value&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)] = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$pow&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; j&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)      &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; get the scale for the digit
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The value of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;j&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is different for each loop iteration but can be replaced with a constant during synthesis.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$pow&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function accepts arguments that are &lt;em&gt;known&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;updated-repeat-block&quot;&gt;Updated Repeat Block&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#updated-repeat-block&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; block has been modified a bit.&lt;&#x2F;p&gt;
&lt;p&gt;The old syntax was &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; was the number of times to loop and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; was the optional loop variable that would be between &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The repeat block can now take the form &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the number of loops and there is no loop variable (like before). However, it can also take the form &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; start&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; step&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; are as before (but switched positions). The parameters &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;start&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;step&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; are optional and specify the starting value and amount to increment by each loop.&lt;&#x2F;p&gt;
&lt;p&gt;If omitted they default to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;start &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;step &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Note that this is a breaking change as the form &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is now &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;component-library&quot;&gt;Component Library&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#component-library&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;The component library has been added. It can be accessed by the three box icon in the main toolbar.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;component-library.png&quot; alt=&quot;Component Library&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Components are now designated in the project tree buy the same three box icon.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;example-projects&quot;&gt;Example Projects&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#example-projects&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;In addition to the components being added, the project templates have been added as well.&lt;&#x2F;p&gt;
&lt;p&gt;This means you can easily start a project for the Io with the Io Base or Io Demo templates.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;toolchain-settings&quot;&gt;Toolchain Settings&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#toolchain-settings&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;A settings menu was added under the main drop down that is accessed by click on the Alchitry logo.&lt;&#x2F;p&gt;
&lt;p&gt;Currently, it is populated with the toolchain settings. These let you select the locations for your Vivado and iCEcube2 installs.&lt;&#x2F;p&gt;
&lt;p&gt;There is also an option to toggle between the built in Yosys toolchain or iCEcube2 when working with the Cu.&lt;&#x2F;p&gt;
&lt;p&gt;The Yosys toolchain was updated in the Linux build to not require that a specific version of Python be installed.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>iCEcube2 No Longer Free</title>
        <published>2024-04-17T00:00:00+00:00</published>
        <updated>2024-05-06T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/icecube2-no-longer-free/"/>
        <id>https://alchitry.com/news/icecube2-no-longer-free/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/icecube2-no-longer-free/">&lt;div class=&quot;callout-box callout-info&quot; &gt;
    &lt;div class=&quot;callout-icon&quot;&gt;&lt;&#x2F;div&gt;
    &lt;div class=&quot;callout-content&quot;&gt;
        &lt;p&gt;Lattice has since added a note about free licenses for &amp;quot;hobbyists, enthusiasts, community educators &amp;amp; start-up companies.&amp;quot; See the Licensing section at the bottom of &lt;a href=&quot;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;iCEcube2&quot;&gt;this page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;It appears that Lattice Semiconductors, the manufacture of the FPGA used in the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;boards&#x2F;cu&#x2F;&quot;&gt;Cu&lt;&#x2F;a&gt;, has decided to pull a fast one and silently change the license required to use &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;tutorials&#x2F;introduction&#x2F;icecube2&#x2F;&quot;&gt;iCEcube2&lt;&#x2F;a&gt; from free to an &lt;strong&gt;expensive&lt;&#x2F;strong&gt; subscription.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s unclear when exactly this change happened, but looking at the latest snapshot from &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20240224150050&#x2F;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;Support&#x2F;Licensing&quot;&gt;the wayback machine&lt;&#x2F;a&gt; on February 24th, 2024, it was still free.&lt;&#x2F;p&gt;
&lt;p&gt;On the &lt;a href=&quot;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;Support&#x2F;Licensing&quot;&gt;live site&lt;&#x2F;a&gt; iCEcube2 is now only listed as &lt;em&gt;Subscription&lt;&#x2F;em&gt; for all FPGA families it supports.&lt;&#x2F;p&gt;
&lt;p&gt;Heading over to their &lt;a href=&quot;https:&#x2F;&#x2F;www.latticestore.com&#x2F;products&#x2F;tabid&#x2F;417&#x2F;searchid&#x2F;1&#x2F;searchvalue&#x2F;lsc-sw-icecube2&#x2F;default.aspx&quot;&gt;online store&lt;&#x2F;a&gt;, I&#x27;m currently seeing pricing of &lt;strong&gt;$471.31&lt;&#x2F;strong&gt; for the first year and &lt;strong&gt;$353.15&lt;&#x2F;strong&gt; to renew each additional year.&lt;&#x2F;p&gt;
&lt;p&gt;This is insane!&lt;&#x2F;p&gt;
&lt;p&gt;iCEcube2 hasn&#x27;t had any meaningful software updates in many many years. Just take a look at the &lt;a href=&quot;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;Products&#x2F;DesignSoftwareAndIP&#x2F;FPGAandLDS&#x2F;iCEcube2#_B014C41EC7EA406C8BF8E943EABA6317&quot;&gt;versions&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The only thing that makes sense to me is that they very much do &lt;strong&gt;not&lt;&#x2F;strong&gt; want you to use it.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;contact-lattice&quot;&gt;Contact Lattice&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#contact-lattice&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;If this change bothers you as much as it does me, I highly encourage you to &lt;a href=&quot;https:&#x2F;&#x2F;www.latticesemi.com&#x2F;en&#x2F;About&#x2F;ContactUs&quot;&gt;contact Lattice&lt;&#x2F;a&gt; and let them know what you think. &lt;a href=&quot;mailto:general_inquiries@latticesemi.com&quot;&gt;Click here for their general inquiries email&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve sent them an email asking what&#x27;s going on and I&#x27;ll update this post if&#x2F;when they respond.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;a-beacon-of-hope&quot;&gt;A Beacon of Hope&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#a-beacon-of-hope&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Luckily, we have an alternative, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;YosysHQ&#x2F;icestorm&quot;&gt;Project IceStorm&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;YosysHQ&quot;&gt;Yosys&lt;&#x2F;a&gt; more generally.&lt;&#x2F;p&gt;
&lt;p&gt;The open source tools for FPGAs have continued to improve and my latest experiences with them for the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;boards&#x2F;cu&#x2F;&quot;&gt;Alchitry Cu&lt;&#x2F;a&gt; have been excellent.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;alchitry-labs&#x2F;&quot;&gt;Alchitry Labs V2&lt;&#x2F;a&gt; comes with all the necessary open source tools bundled to work with the Cu without having to compile&#x2F;install anything else.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Lucid V1 to V2</title>
        <published>2024-04-01T00:00:00+00:00</published>
        <updated>2024-04-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/lucid-1-vs-2/"/>
        <id>https://alchitry.com/news/lucid-1-vs-2/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/lucid-1-vs-2/">&lt;p&gt;This post was created for people who are already familiar with Lucid V1 to get up to speed with what&#x27;s new&#x2F;different in Lucid V2.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;style-changes&quot;&gt;Style Changes&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#style-changes&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Let&#x27;s start off with the most basic changes, those to style.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;optional-semicolons&quot;&gt;Optional Semicolons&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#optional-semicolons&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;First off, the new Lucid grammar now accepts a new line as a semicolon.&lt;&#x2F;p&gt;
&lt;p&gt;This means that as long as each expression is on a separate line, you don&#x27;t need to use semicolons at all.&lt;&#x2F;p&gt;
&lt;p&gt;This change was motivated by many modern programming languages.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;trailing-commas&quot;&gt;Trailing Commas&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#trailing-commas&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Again taking inspiration from many other languages, trailing commas in lists are now supported.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; trailingComma &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; clock
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; rst&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; reset
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; out&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; &amp;lt;- LOOK A COMMA
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt; ...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;By making trailing commas optional, it helps make it easier to re-arrange items in a list or add new items to the end without modifying previous lines.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;camel-case&quot;&gt;Camel Case&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#camel-case&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;This is fairly subtle, but camel case is now the preferred naming format for all basic names. The libraries and examples in Lucid V1 were fairly inconsistent between &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;camelCase&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;snake_case&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This is just to make things more consistent.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;struct-position&quot;&gt;Struct Position&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#struct-position&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The first breaking change is that struct sizes are now specified after the array size (or name if there isn&#x27;t an array size) instead of after the type.&lt;&#x2F;p&gt;
&lt;p&gt;For example, before when declaring a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; with an array of 8 structs with type &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;myStruct&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; you would write the following.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;myStruct&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; mySig&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;];
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is now written as the following.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; mySig&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;myStruct&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This change was made to better match how the elements in the signal are structured.&lt;&#x2F;p&gt;
&lt;p&gt;For example, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;mySig&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;.structElement&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is how you access the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;structElement&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; of the second element in the array.&lt;&#x2F;p&gt;
&lt;p&gt;In both cases, the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is an array of structs so the array index always comes first. &lt;&#x2F;p&gt;
&lt;p&gt;This also makes a bit more sense for the cases when you need to specify the width of a signal that doesn&#x27;t have a type.&lt;&#x2F;p&gt;
&lt;p&gt;For example, a struct declaration could look like this.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;struct&lt;&#x2F;span&gt;&lt;span&gt; myStruct &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    structElement&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;otherStruct&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    structArray&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;otherStruct&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt;,
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;no-more&quot;&gt;No More &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;WIDTH&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#no-more&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;Something that always felt kind of out of place to me was the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;WIDTH&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; attribute attached to &amp;quot;all&amp;quot; signals in Lucid V1.&lt;&#x2F;p&gt;
&lt;p&gt;While it worked for the most part, it had two issues I wanted to address. &lt;&#x2F;p&gt;
&lt;p&gt;First, it just didn&#x27;t seem to fit. There was nothing else like it in the language.&lt;&#x2F;p&gt;
&lt;p&gt;Second, it could only be used on full signals, not expressions or anything else.&lt;&#x2F;p&gt;
&lt;p&gt;Both of these are fixed by replacing it with the new &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$width&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function.&lt;&#x2F;p&gt;
&lt;p&gt;Simply pass in whatever you want and it&#x27;ll spit out a constant value representing the width of the signal&#x2F;expression.&lt;&#x2F;p&gt;
&lt;p&gt;This fits much better as there are plenty of other functions to calculate constant values.&lt;&#x2F;p&gt;
&lt;p&gt;The use of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;WIDTH&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; was in Lucid before there were custom Lucid functions. Otherwise, it probably would&#x27;ve been a function from the beginning.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;simplification&quot;&gt;Simplification&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#simplification&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;There are a few changes made to make things a bit simpler.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;loops&quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; Loops&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#loops&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;For loops were replaced with the new &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; loop.&lt;&#x2F;p&gt;
&lt;p&gt;Lucid V1 used &lt;em&gt;C&lt;&#x2F;em&gt; style for loop that were easy to write in a way that would be impossible to implement in hardware.&lt;&#x2F;p&gt;
&lt;p&gt;The new &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; loop has the simple syntax of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; start &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; step &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {}&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is an optional loop variable.
&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is a constant expression.
&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;start&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;step&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; are also constant expressions but are optional.
The loop will repeat &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; times and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; will be set from &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;start&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;start &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; step &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;* (&lt;&#x2F;span&gt;&lt;span&gt;count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;- &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This syntax makes it impossible to write a loop with a variable number of iterations (which hardware can&#x27;t accommodate). &lt;&#x2F;p&gt;
&lt;h2 id=&quot;no-more-1&quot;&gt;No More &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;var&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#no-more-1&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;var&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; type was always a bit weird. It was basically just a 32 bit &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; that you would use with for loops. &lt;&#x2F;p&gt;
&lt;p&gt;No for loops means you doubly don&#x27;t need it.&lt;&#x2F;p&gt;
&lt;p&gt;Anywhere you had a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;var&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; before could be replaced with a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;bye-hello&quot;&gt;Bye &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;fsm&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, Hello &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;enum&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#bye-hello&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The type &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;fsm&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; was also kind of a weird type. It was a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; with a list of constants attached.&lt;&#x2F;p&gt;
&lt;p&gt;Nothing kept you from using these constants in other places in your designs and a few times I did just that. It always felt a little wrong.&lt;&#x2F;p&gt;
&lt;p&gt;Now the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;enum&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; type lets you declare a list of constants that will have their values assigned by the tools just like &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;fsm&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; but it is separate from any storage type.&lt;&#x2F;p&gt;
&lt;p&gt;Something like &lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;fsm&lt;&#x2F;span&gt;&lt;span&gt; state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;IDLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;START_BIT&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DATA&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STOP_BIT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;};
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;state.d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;START_BIT&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;is now replaced with&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;enum &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;States &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;IDLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;START_BIT&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;DATA&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;STOP_BIT &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;span&gt; state&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$width&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;States&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)]
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;state.d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#da5a8c;&quot;&gt;States&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;START_BIT
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This makes the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; type the only storage type.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;parameter-test-values&quot;&gt;Parameter Test Values&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#parameter-test-values&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;In Lucid V1 you had to choose between better error checking and making a parameter optional.&lt;&#x2F;p&gt;
&lt;p&gt;Lucid V2 adds the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; operator during parameter declaration to allow you to specify a test value.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s an example.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; uartTx &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;#(
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CLK_FREQ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;~ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;100000000 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CLK_FREQ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; clock frequency
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BAUD &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;~ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1000000 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BAUD &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BAUD &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&amp;lt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CLK_FREQ&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;2 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; desired baud rate
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)(
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Both the parameter &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;CLK_FREQ&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#d45ada;&quot;&gt;BAUD&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; have test values specified. These values are used when the module is being checked for errors but hasn&#x27;t been instantiated.&lt;&#x2F;p&gt;
&lt;p&gt;If these values were omitted, the error checking code doesn&#x27;t know what they could be so it has to do its best to check for potential errors.&lt;&#x2F;p&gt;
&lt;p&gt;You could provided a value with &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; instead of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; but this allows the parameter to be omitted when it is instantiated.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;~&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; version provides a value for the error checker to use but still requires a value to be explicitly presented when instantiated.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;test-benches&quot;&gt;Test Benches&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-benches&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;A huge reason for the whole Alchitry Labs&#x2F;Lucid V2 rewrite was to add simulations.&lt;&#x2F;p&gt;
&lt;p&gt;These have been covered in a &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;news&#x2F;lucid-v2-update-2&#x2F;&quot;&gt;previous post&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>New Site, New Forum, New Alchitry Labs</title>
        <published>2024-03-26T00:00:00+00:00</published>
        <updated>2024-03-26T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/new-site-new-forum-new-labs/"/>
        <id>https://alchitry.com/news/new-site-new-forum-new-labs/</id>
        
        <summary type="html">&lt;p&gt;A lot has happened since the last blog post!&lt;&#x2F;p&gt;
&lt;p&gt;First lets start with the page you&#x27;re reading this on, the new website!&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2.0.5 - Simulations</title>
        <published>2024-02-06T00:00:00+00:00</published>
        <updated>2024-02-06T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-0-5-simulations/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-0-5-simulations/</id>
        
        <summary type="html">&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;Version 2.0.5-Preview&lt;&#x2F;a&gt; of Alchitry Labs is now available. It now supports simulating the main Alchitry boards as well as the Io Element.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - Update 3</title>
        <published>2024-01-15T00:00:00+00:00</published>
        <updated>2024-01-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-update-3/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-update-3/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-update-3/">&lt;p&gt;Simulations are now supported!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs-2.0.4-preview.png&quot; alt=&quot;Alchitry Labs 2.0.4 PREVIEW&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;test-benches&quot;&gt;Test Benches&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-benches&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The new update, &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;2.0.4-PREVIEW&lt;&#x2F;a&gt;, now has the first draft of the
simulation GUI.&lt;&#x2F;p&gt;
&lt;p&gt;To run a simulation you need to first create a test bench.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve covered these before when you could first run them from the command line so make sure
to &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;news&#x2F;lucid-v2-update-2&#x2F;&quot;&gt;check that out&lt;&#x2F;a&gt; if you haven&#x27;t already.&lt;&#x2F;p&gt;
&lt;p&gt;There&#x27;s been an addition to the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$print&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function though. You can still pass it a signal directly for the old behavior,
but you can now pass in a formatting string followed by the values to use.&lt;&#x2F;p&gt;
&lt;p&gt;This is similar to something like &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;printf&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; in C&#x2F;C++.&lt;&#x2F;p&gt;
&lt;p&gt;The function call looks something like &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$print&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;my value is %d&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; mySig&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;mySig&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is the signal to print in decimal
where the %d is.&lt;&#x2F;p&gt;
&lt;p&gt;The format options are &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;%d&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for decimal, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;%b&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for binary, &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;%h&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for hexadecimal, and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;%nf&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; for fixed point where
n is the number of fixed fractional bits (for example &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#77bf0a;&quot;&gt;&amp;quot;%2f&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;run-the-test&quot;&gt;Run the Test&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#run-the-test&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;In the code editor, when it detects a test, there is an arrow in the left hand gutter on the line where the test was
declared. You can click this arrow to run that test.&lt;&#x2F;p&gt;
&lt;p&gt;Alternatively, clicking the bug icon in the toolbar will run every test.&lt;&#x2F;p&gt;
&lt;p&gt;The results of the test are printed to the console and a new tab is opened displaying the resulting values captured at
each &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The waveform viewer is currently pretty basic but its enough to start messing with it.&lt;&#x2F;p&gt;
&lt;p&gt;You can use the mouse wheel to zoom and click&#x2F;drag to pan around.&lt;&#x2F;p&gt;
&lt;p&gt;The values at your cursor are show as an overlay.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - Update 2</title>
        <published>2024-01-04T00:00:00+00:00</published>
        <updated>2024-01-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-update-2/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-update-2/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-update-2/">&lt;p&gt;It&#x27;s been a while since I&#x27;ve posted an update and a lot has happened. Most of the work I&#x27;ve been putting into Alchitry Labs has been for the new GUI.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs-2.0.3-preview.png&quot; alt=&quot;Alchitry Labs 2.0.3 PREVIEW&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As I&#x27;ve mentioned in a previous blog post, this time around I&#x27;m using &lt;a href=&quot;https:&#x2F;&#x2F;www.jetbrains.com&#x2F;lp&#x2F;compose-multiplatform&#x2F;&quot;&gt;Compose Multiplatform&lt;&#x2F;a&gt; for creating the UI instead of the now very old &lt;a href=&quot;https:&#x2F;&#x2F;www.eclipse.org&#x2F;swt&#x2F;&quot;&gt;SWT&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Compose is fundamentally different from SWT and allows for a lot more freedom in creating a beautiful UI. However, since Compose for desktop is so new, there are some growing pains I&#x27;ve had to overcome.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;code-editor&quot;&gt;Code Editor&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#code-editor&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;One of the first things I did when starting the Alchitry Labs rewrite was to see if I could make a text editor perform well with Compose. The built in &lt;code&gt;TextField&lt;&#x2F;code&gt; widget is fine for small text fields but falls apart for something as complicated as a code editor.&lt;&#x2F;p&gt;
&lt;p&gt;Compose exposes various levels of abstraction you can dig into depending on what you want to accomplish. I jumped a few layers down and created my own code editor composable. &lt;&#x2F;p&gt;
&lt;p&gt;The most important difference between my code editor and the built in &lt;code&gt;TextField&lt;&#x2F;code&gt; is that my code computes the layout of each line individually instead of the entire block of text. The big upside to this is that when text is being edited I only need to compute the lines that change instead of every single line.&lt;&#x2F;p&gt;
&lt;p&gt;This makes editing text fast no matter how big the file is.&lt;&#x2F;p&gt;
&lt;p&gt;There was a lot of complexity added to make this work but the payoff was worth it.&lt;&#x2F;p&gt;
&lt;p&gt;In addition to performance, I was able to add some additional features that are nice to have for the code editor, such as the line numbers in the gutter. These are even flexible so I can potentially later add stuff like icons if needed.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;TextField&lt;&#x2F;code&gt; also doesn&#x27;t provide any way to draw a background color behind text so I had to add this custom. This allows for highlighting the token the cursor is on as well as all matching tokens. &lt;&#x2F;p&gt;
&lt;h2 id=&quot;tabs&quot;&gt;Tabs&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#tabs&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The next major UI hurdle was making the editor tabs work. I already had written a sash composable that would allow me to split a section into left and right or top and bottom resize-able areas (I needed it already for the main layout). However, I wanted to make splitting the editor be as easy as dragging a dropping the tab to where you want it.&lt;&#x2F;p&gt;
&lt;p&gt;Again, compose gives you plenty of tools to do this and I had already done something similar for a different project that I was able to steal most of the code from. With some modifications I ended up where it is now where you can not only drag and drop the tabs to rearrange them but drag them top any side of the window to split it.&lt;&#x2F;p&gt;
&lt;p&gt;This is definitely a step up from the previous version that requires you to split then window then drag the tab over.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;project-tree&quot;&gt;Project Tree&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#project-tree&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;This is something that still needs some work, but one of the new features is that file names in the tree are color coded based on their state (yellow = has warnings, red = has errors).&lt;&#x2F;p&gt;
&lt;p&gt;This was possible because the way projects&#x2F;files are checked for errors is fundamentally different than before.&lt;&#x2F;p&gt;
&lt;p&gt;When a file is changed, an error check is queued. The error check first parses all the project files for errors like syntax errors. Then starting from the top module, the project is parsed as a tree through the module instances.&lt;&#x2F;p&gt;
&lt;p&gt;This allows for a thorough check of the modules using actual parameter values. &lt;&#x2F;p&gt;
&lt;p&gt;Some of this could be improved in the future such as caching some of the results for files that haven&#x27;t changed, but even as it is now it is quite fast.&lt;&#x2F;p&gt;
&lt;p&gt;It currently doesn&#x27;t fully check modules that fall outside the project tree (in other words, modules that are in the project but not used). I&#x27;ll add this in a later update.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;labs-and-loader&quot;&gt;Labs and Loader&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#labs-and-loader&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Alchitry Labs and the Alchitry Loader now share one executable&#x2F;launcher. This was done because it isn&#x27;t possible to create two launchers with one installer on macOS.&lt;&#x2F;p&gt;
&lt;p&gt;Instead, when you open Alchitry Labs, it&#x27;ll open whatever you were using last.&lt;&#x2F;p&gt;
&lt;p&gt;To switch between Labs and the Loader, you simply click the Alchitry logo in the top left and choose &amp;quot;Switch to X&amp;quot;&lt;&#x2F;p&gt;
&lt;p&gt;I have a feeling that most people are using either one or the other and don&#x27;t often switch between the two. If this isn&#x27;t you, let me know on the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;LucidParserV2&#x2F;discussions&quot;&gt;discussion page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;test-it-out&quot;&gt;Test It Out&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-it-out&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;There is still a lot of features missing, but if you would like you can download the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;latest version here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Everything should be there to make a simple project, build, and load it to any of the Alchitry boards.&lt;&#x2F;p&gt;
&lt;p&gt;This also means you should be able to use this to build projects for the Alchitry Cu on a Mac.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;next-steps&quot;&gt;Next Steps&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#next-steps&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The code editor needs many quality of life improvements such as auto indenting&#x2F;formatting, auto-complete, support for Verilog, error checking for ACF files, support for Xilinx and Lattice constraint files, context menus (right click), and I&#x27;m sure endless more.&lt;&#x2F;p&gt;
&lt;p&gt;I need to also add in the component library, port the project templates to Lucid V2, and add back in support the Vivado&#x27;s IP catalog.&lt;&#x2F;p&gt;
&lt;p&gt;I also need to build the front end for running simulations. All the code is there to actually run it, there just isn&#x27;t currently a way to conveniently start it or view the results. This will likely be my first next step.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - Update 1</title>
        <published>2023-10-13T00:00:00+00:00</published>
        <updated>2023-10-13T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-update-1/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-update-1/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-update-1/">&lt;p&gt;Today was the first time I built a .bin file from Alchitry Labs V2!&lt;&#x2F;p&gt;
&lt;p&gt;Before we get too far ahead, there is a lot more to cover.&lt;&#x2F;p&gt;
&lt;p&gt;In the last release, I use the Compose Multiplatform Gradle plugin to create &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;JetBrains&#x2F;compose-multiplatform&#x2F;blob&#x2F;master&#x2F;tutorials&#x2F;Native_distributions_and_local_execution&#x2F;README.md&quot;&gt;native distributions&lt;&#x2F;a&gt;.
At first, this seemed like an awesome solution. However, it has one fatal flaw.&lt;&#x2F;p&gt;
&lt;p&gt;The plugin requires you to build each target on its respective platform. That means if you want to build for Windows, you need to be on Windows. If you want to build for an ARM based Mac, you need to have an ARM based Mac.&lt;&#x2F;p&gt;
&lt;p&gt;This requirement was the same issue I had before with the original Alchitry Labs but it wasn&#x27;t that bad since I only ever built for Windows and Linux X64. I was able to do everything from Linux using a Window VM.&lt;&#x2F;p&gt;
&lt;p&gt;This time around, I want to add support for more systems. Alchitry Labs runs on a JVM (Java Virtual Machine) so in theory it should run in a ton of places with minimal work.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;m hoping to target everything that Compose supports, Windows x64, Linux x64, Linux ARM, Mac x64, and Mac ARM.&lt;&#x2F;p&gt;
&lt;p&gt;When looking for solutions to this, I came across &lt;a href=&quot;https:&#x2F;&#x2F;www.hydraulic.dev&#x2F;&quot;&gt;Conveyor&lt;&#x2F;a&gt; which seems to be almost everything I was looking for. Best of all, it is free for open source projects like Alchitry Labs!&lt;&#x2F;p&gt;
&lt;p&gt;Conveyor lets you build for every target from a single system. It also deals with code signing and pushing updates.&lt;&#x2F;p&gt;
&lt;p&gt;The only downside right now is that it doesn&#x27;t support Linux AArch64 (ARM). I became a paid subscriber to get this feature onto the dev&#x27;s radar and I was told it will likely make it into the next major release.&lt;&#x2F;p&gt;
&lt;p&gt;Now that I have this all setup, I can run a single command that builds my project, creates update packages, creates an update website, and pushes it all to GitHub.&lt;&#x2F;p&gt;
&lt;p&gt;You can now download the latest version from the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;GitHub page here&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;m currently just self signing everything. This only really matters for Windows and Macs where you&#x27;ll see more security warnings when trying to install it.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll likely get everything officially signed for the next release. For the Window&#x27;s release, this means that it&#x27;ll be available from the Microsoft Store.&lt;&#x2F;p&gt;
&lt;p&gt;The Linux version is now packaged as a deb which makes installation so much easier! Installing the deb also adds an update site so that when updates for Alchitry Labs are available they show up in the package manager with everything else.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mac-support&quot;&gt;Mac Support&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#mac-support&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;As I&#x27;ve mentioned above, the new releases have Mac versions.&lt;&#x2F;p&gt;
&lt;p&gt;Before you get too excited, no, you still can&#x27;t run Vivado or iceCube 2 on a Mac. This means that you still can&#x27;t build FPGA projects using the proprietary tools.&lt;&#x2F;p&gt;
&lt;p&gt;So why bother supporting Macs? First, many people run the build tools inside of virtual machines inside a Mac. USB devices don&#x27;t always play nicely going across the VM layer so by having native support for the Alchitry Loader, we can avoid that issue.&lt;&#x2F;p&gt;
&lt;p&gt;The Mac versions of the loader are already working!&lt;&#x2F;p&gt;
&lt;p&gt;Second, there are open source tools that &lt;em&gt;can&lt;&#x2F;em&gt; run on a Mac. I&#x27;m hoping to bundle these with a later release of Alchitry Labs so that you will be able to develop for the Alchitry Cu natively on a Mac.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-new-verilog-converter&quot;&gt;The New Verilog Converter&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#the-new-verilog-converter&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The biggest update to the Alchitry Labs V2 codebase is the Verilog converter.&lt;&#x2F;p&gt;
&lt;p&gt;Continuing with the full rewrite, the new converter is much cleaner than the old one. The original converter was one of the first things I wrote back when the IDE was the &amp;quot;Mojo IDE.&amp;quot;&lt;&#x2F;p&gt;
&lt;p&gt;Back then, the converted was responsible for everything. Given some Lucid text, it had to spit out a Verilog version.&lt;&#x2F;p&gt;
&lt;p&gt;The new converted is instead given a fully parsed Lucid module instance. A lot of the complicated tasks are already done in the previous stage such as dealing with signal indexing, declarations, etc.&lt;&#x2F;p&gt;
&lt;p&gt;This, along with better coding practices, has made the new converter about 40% of the size of the original! I&#x27;m pretty excited for it.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;acf-parser&quot;&gt;ACF Parser&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#acf-parser&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;With a Lucid-&amp;gt;Verilog translator working, the next step was to add support for constraint files.&lt;&#x2F;p&gt;
&lt;p&gt;The Alchitry Constraint File format is super simple and adding a parser for it wasn&#x27;t too complicated.&lt;&#x2F;p&gt;
&lt;p&gt;I ended up modifying the format a bit from V1 though. &lt;&#x2F;p&gt;
&lt;p&gt;Keeping with the change to Lucid, semicolons are now optional. Also, clock statements are considered a special type of pin statement so you don&#x27;t need to specify both for a single pin.&lt;&#x2F;p&gt;
&lt;p&gt;It now checks that the names of the ports and pins are valid. Wildly, I apparently never checked the pin names properly for V1 so they would just show up as &amp;quot;null&amp;quot; in the converted constraint file and cause silent issues.&lt;&#x2F;p&gt;
&lt;p&gt;For now, I just have an ACF-&amp;gt;XDC converter (XDC is the Xilinx format).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;test-build&quot;&gt;Test Build&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-build&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;With all the pieces in place, I was able to get a test build running.&lt;&#x2F;p&gt;
&lt;p&gt;Once a project is open, calling &lt;code&gt;Project.build()&lt;&#x2F;code&gt; simply builds the entire project!&lt;&#x2F;p&gt;
&lt;p&gt;This only works for the Au&#x2F;Au+ right now as I still have to port the Cu builders but it is a big milestone!&lt;&#x2F;p&gt;
&lt;p&gt;Building Au projects is accessible from the command line interface now.&lt;&#x2F;p&gt;
&lt;p&gt;If you want to check out the progress, see &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&quot;&gt;the GitHub page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;You can install the &lt;a href=&quot;https:&#x2F;&#x2F;alchitry.com&#x2F;Alchitry-Labs-V2&#x2F;download.html&quot;&gt;latest version here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Loader V2</title>
        <published>2023-09-18T00:00:00+00:00</published>
        <updated>2023-09-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-loader-v2/"/>
        <id>https://alchitry.com/news/alchitry-loader-v2/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-loader-v2/">&lt;p&gt;The Alchitry Loader portion of the Alchitry Labs V2 rewrite is mostly done!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;loader-alpha.png&quot; alt=&quot;Alchitry Loader&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The new loader automatically detects connected boards and lists them in a drop down. This allows you to have more than one board connected without conflict.&lt;&#x2F;p&gt;
&lt;p&gt;Under the hood, it now also handles the D2XX driver a bit more elegantly. It first tries to load the proprietary D2XX library (libd2xx) and if it fails, it falls back to the open source libUSB driver.&lt;&#x2F;p&gt;
&lt;p&gt;On Windows, you&#x27;ll almost always be using D2XX from FTDI. However, on Linux, libUSB is the default but you can install libd2xx and it&#x27;ll be detected and used.&lt;&#x2F;p&gt;
&lt;p&gt;There are still a few weird kinks to work out but it is overall usable (and an improvement over the old one).&lt;&#x2F;p&gt;
&lt;p&gt;On Windows, I haven&#x27;t been able to figure out how to configure the installer to not install a shortcut for the command line interface version of the launcher. After running the installer, you&#x27;ll see a shortcut called &amp;quot;alchitry&amp;quot; which doesn&#x27;t seem to do anything. This is the command line interface launcher.&lt;&#x2F;p&gt;
&lt;p&gt;There seems to be a bug in &lt;code&gt;jpackage&lt;&#x2F;code&gt; that ignores the value of the &lt;code&gt;--win-shortcut&lt;&#x2F;code&gt; option and always makes shortcuts. I&#x27;ll have to dig into more eventually.&lt;&#x2F;p&gt;
&lt;p&gt;On Linux, I&#x27;ve been having a hard time getting the window&#x27;s icon to be set correctly. On Gnome, it seems to be working but on Ubuntu (22.04) it shows the default Java icon and has some kind of secondary ghost window that you can&#x27;t focus.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;installers&quot;&gt;Installers&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#installers&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;Alchitry%20Labs-2.0.0-ALPHA-1.msi&quot;&gt;Windows Installer&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs_2.0.0-ALPHA-1-1_amd64.deb&quot;&gt;Linux Installer&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2 - Command Line Interface</title>
        <published>2023-09-11T00:00:00+00:00</published>
        <updated>2023-09-11T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2-cli/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2-cli/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2-cli/">&lt;p&gt;It has been a while since I last wrote about the progress on Alchitry Labs V2 and a lot has changed.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;build-tools&quot;&gt;Build Tools&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#build-tools&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;ve spent a good amount of time working on building out the Gradle build script so that the deployment process will be much easier than it was for Alchitry Labs V1.&lt;&#x2F;p&gt;
&lt;p&gt;When I was looking for a way to create the Window&#x27;s installer, I discovered that &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;JetBrains&#x2F;compose-multiplatform&#x2F;tree&#x2F;master&quot;&gt;Compose Multiplatform&lt;&#x2F;a&gt; has a built-in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;JetBrains&#x2F;compose-multiplatform&#x2F;blob&#x2F;master&#x2F;tutorials&#x2F;Native_distributions_and_local_execution&#x2F;README.md&quot;&gt;packaging tool&lt;&#x2F;a&gt;!&lt;&#x2F;p&gt;
&lt;p&gt;It turns out that this still has the major downside of needing to be running on the OS that you want to package for. This means you can&#x27;t build an installer for Windows from Linux. Bummer, but not the end of the world.&lt;&#x2F;p&gt;
&lt;p&gt;I ran into two other issues when flushing out the build script. First, Compose&#x27;s build tools only support creating one launcher per application. I need to create two. The main one to launch Alchitry Labs and the second to launch the Alchitry Loader.&lt;&#x2F;p&gt;
&lt;p&gt;These two programs are actually the same thing with just a different argument passed to them to show a different GUI.&lt;&#x2F;p&gt;
&lt;p&gt;It turns out that jpackage, the tool used by Compose, has a way to add additional launchers but Compose currently gives no way to access it. I add the support I needed, I forked the Compose plugin and submitted a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;JetBrains&#x2F;compose-multiplatform&#x2F;pull&#x2F;3640&quot;&gt;pull request&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;For now, I&#x27;m using my local forked version of the Compose plugin, but hopefully they&#x27;ll accept the pull request or make some similar changes to allow creating additional launchers.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;command-line-interface&quot;&gt;Command Line Interface&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#command-line-interface&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Something I often get emails about is for command line support in Alchitry Labs. Well, I&#x27;m happy to announce that the command line interface for Alchitry Labs V2 will be well supported.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ve decided to get everything working via the command line before diving too much into the GUI.&lt;&#x2F;p&gt;
&lt;p&gt;Right now, the loading tools already work. So if you&#x27;ve been looking for a way to load your Alchitry boards from the command line, check out the very early releases below.&lt;&#x2F;p&gt;
&lt;p&gt;The command line is broken into a bunch of subcommands.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#282828;color:#ffffff;&quot;&gt;&lt;code&gt;&lt;span&gt;$ alchitry --help
&lt;&#x2F;span&gt;&lt;span&gt;Usage: alchitry_labs options_list
&lt;&#x2F;span&gt;&lt;span&gt;Subcommands: 
&lt;&#x2F;span&gt;&lt;span&gt;    new - Create a new project
&lt;&#x2F;span&gt;&lt;span&gt;    clone - Clone an existing project
&lt;&#x2F;span&gt;&lt;span&gt;    check - Check a project for errors
&lt;&#x2F;span&gt;&lt;span&gt;    build - Build an Alchitry Project
&lt;&#x2F;span&gt;&lt;span&gt;    load - Load a project or .bin file
&lt;&#x2F;span&gt;&lt;span&gt;    sim - Simulate a project
&lt;&#x2F;span&gt;&lt;span&gt;    labs - Launch Alchitry Labs GUI
&lt;&#x2F;span&gt;&lt;span&gt;    loader - Launch Alchitry Loader GUI
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;Options: 
&lt;&#x2F;span&gt;&lt;span&gt;    --help, -h -&amp;gt; Usage info 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you install the .deb on Linux, you&#x27;ll get access to the &lt;code&gt;alchitry&lt;&#x2F;code&gt; command.&lt;&#x2F;p&gt;
&lt;p&gt;On Windows, the &lt;code&gt;Alchitry.exe&lt;&#x2F;code&gt; executable in the installation directory can be used.&lt;&#x2F;p&gt;
&lt;p&gt;You can run &lt;code&gt;--help&lt;&#x2F;code&gt; on each subcommand for more info.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#282828;color:#ffffff;&quot;&gt;&lt;code&gt;&lt;span&gt;$ alchitry load --help
&lt;&#x2F;span&gt;&lt;span&gt;Usage: alchitry_labs load options_list
&lt;&#x2F;span&gt;&lt;span&gt;Options: 
&lt;&#x2F;span&gt;&lt;span&gt;    --project, -p -&amp;gt; Alchitry project file { String }
&lt;&#x2F;span&gt;&lt;span&gt;    --flash, -f [false] -&amp;gt; Load project to FPGA&amp;#39;s flash (persistent) 
&lt;&#x2F;span&gt;&lt;span&gt;    --ram, -r [false] -&amp;gt; Load project to FPGA&amp;#39;s RAM (temporary) 
&lt;&#x2F;span&gt;&lt;span&gt;    --list, -l [false] -&amp;gt; List all detected boards 
&lt;&#x2F;span&gt;&lt;span&gt;    --device, -d [0] -&amp;gt; Index of device to load { Int }
&lt;&#x2F;span&gt;&lt;span&gt;    --bin -&amp;gt; Bin file to load { String }
&lt;&#x2F;span&gt;&lt;span&gt;    --board, -b -&amp;gt; Board used in the project { Value should be one of [Au, Au+, Cu] }
&lt;&#x2F;span&gt;&lt;span&gt;    --help, -h -&amp;gt; Usage info 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For example, you can load a .bin file like this.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#282828;color:#ffffff;&quot;&gt;&lt;code&gt;&lt;span&gt;$ alchitry load --bin alchitry.bin -b Au+ --flash
&lt;&#x2F;span&gt;&lt;span&gt;Checking IDCODE...
&lt;&#x2F;span&gt;&lt;span&gt;Loading bridge configuration...
&lt;&#x2F;span&gt;&lt;span&gt;Erasing...
&lt;&#x2F;span&gt;&lt;span&gt;Flashing 100% │███████████████████████████████████│ 335339&#x2F;335339 (0:00:01 &#x2F; 0:00:00) 
&lt;&#x2F;span&gt;&lt;span&gt;Resetting FPGA...
&lt;&#x2F;span&gt;&lt;span&gt;Done.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you try this out, let me know what you think over at the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;discussions&quot;&gt;discussions page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;releases&quot;&gt;Releases&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#releases&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;These aren&#x27;t really a &amp;quot;release&amp;quot; as much as just something you can try and mess around with.&lt;&#x2F;p&gt;
&lt;p&gt;That being said, the loading features should be fully working.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;alchitry-labs_2.0.0-ALPHA-0-1_amd64.deb&quot;&gt;Linux Deb&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;cdn.alchitry.com&#x2F;labs-v2&#x2F;Alchitry-2.0.0-ALPHA-0.msi&quot;&gt;Windows Installer&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The Labs GUI will open but it doesn&#x27;t really do much. It is basically just a test right now for the custom text editor.&lt;&#x2F;p&gt;
&lt;p&gt;The Loader GUI doesn&#x27;t open&#x2F;exist at all yet.&lt;&#x2F;p&gt;
&lt;p&gt;The command line tools work for creating and simulating projects as well as loading .bin files.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Alchitry Labs V2</title>
        <published>2023-06-07T00:00:00+00:00</published>
        <updated>2023-06-07T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/alchitry-labs-v2/"/>
        <id>https://alchitry.com/news/alchitry-labs-v2/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/alchitry-labs-v2/">&lt;p&gt;I am now starting to work on the UI of the Alchitry Labs rewrite!&lt;&#x2F;p&gt;
&lt;p&gt;Alchitry Labs currently use UI toolkit, SWT. 
This is the UI toolkit developed and used by Eclipse.
At the time I started working on what was then the Mojo IDE, SWT was a solid choice.
It allowed me to create a single UI that worked on Windows and Linux with minimal effort, and it looked native on both
platforms.&lt;&#x2F;p&gt;
&lt;p&gt;However, it hasn&#x27;t aged super well.&lt;&#x2F;p&gt;
&lt;p&gt;I found it to be fairly limited when trying to do anything custom.
For example, I wanted the project tree on the left side of the window to stay the same size when you resized the window.
The main code editor should be the only thing that changes size to accommodate the new window size.
SWT doesn&#x27;t allow for this, and instead you specify the size of each side as a percent.
My workaround was to recalculate the percentages every time the window size changes to keep one side a fixed size.
This mostly works, but if you resize the window a lot, you may notice the divider jumps around due to rounding errors.&lt;&#x2F;p&gt;
&lt;p&gt;In newer versions of SWT, something changed&#x2F;broke that broke the tooltip window from popping up when hovering over an
error in the text editor.
I spend a stupid amount of time trying to figure out a fix for this before giving up and sticking with an old version
of the library.
This annoyingly prevents other bugs from getting fixed though.&lt;&#x2F;p&gt;
&lt;p&gt;One of the worst offenders is the undo&#x2F;redo bug in the current Alchitry Labs. 
I&#x27;ve spent days trying to get the undo&#x2F;redo function to be reliable, but for whatever reason, the way SWT handles the
edit events have prevented me from getting it to always work. V2 already has a fully reliable undo&#x2F;redo working.&lt;&#x2F;p&gt;
&lt;p&gt;TLDR, I&#x27;m moving to something else.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;jetpack-compose&quot;&gt;Jetpack Compose&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#jetpack-compose&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;If you do any UI work and haven&#x27;t tried &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;JetBrains&#x2F;compose-multiplatform&quot;&gt;Jetpack Compose&lt;&#x2F;a&gt; you&#x27;re 
missing out.&lt;&#x2F;p&gt;
&lt;p&gt;This is a declarative UI framework originally developed for use on Android, but it has since made its way onto more 
platforms including desktop.&lt;&#x2F;p&gt;
&lt;p&gt;I find it a joy to use, and it doesn&#x27;t lock you into anything allowing me to create whatever custom UI elements or 
tweaks I need.&lt;&#x2F;p&gt;
&lt;p&gt;Unfortunately, the built-in text editor (TextField) has terrible performance if you are trying to edit any decent amount
of text.
This led me to write my own custom editor that has solid performance for thousands of lines of code.&lt;&#x2F;p&gt;
&lt;p&gt;While this was a substantial amount of work, it also opens up potential in the future for doing cool tricks like 
collapsable blocks. This was impossible with SWT.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;lucid-parser&quot;&gt;Lucid Parser&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#lucid-parser&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;ve also implemented the snapshots for &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and added &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$silentTick&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; which skips the snapshot step.
The snapshots get compiled into a simulation result that holds the value of every signal in the design for every call
of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This will allow the UI to display the results of the entire simulation.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-repo&quot;&gt;The Repo&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#the-repo&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The Lucid Parser repo has been renamed to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&quot;&gt;Alchitry Labs V2&lt;&#x2F;a&gt; and now 
contains the UI and parser code. 
This is where all the progress can be found.&lt;&#x2F;p&gt;
&lt;p&gt;There is a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;Alchitry-Labs-V2&#x2F;discussions&quot;&gt;discussion page&lt;&#x2F;a&gt;, or you can 
&lt;a href=&quot;mailto:justin@alchitry.com&quot;&gt;email me&lt;&#x2F;a&gt; and let me know your thoughts.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Lucid V2 - Update 2 - Test Benches</title>
        <published>2023-06-01T00:00:00+00:00</published>
        <updated>2023-06-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/lucid-v2-update-2/"/>
        <id>https://alchitry.com/news/lucid-v2-update-2/</id>
        
        <content type="html" xml:base="https://alchitry.com/news/lucid-v2-update-2/">&lt;p&gt;Test benches are here!&lt;&#x2F;p&gt;
&lt;p&gt;I just pushed a working draft of the test bench code that has the necessities for writing quick tests for you modules!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;test-bench-example&quot;&gt;Test Bench Example&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-bench-example&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Take a look at this revolutionary counter module I created. &lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;span&gt; counter &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;input&lt;&#x2F;span&gt;&lt;span&gt; clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;output&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;dff&lt;&#x2F;span&gt;&lt;span&gt; counter&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;] (&lt;&#x2F;span&gt;&lt;span&gt;.clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        counter.d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; counter.q &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;+ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span&gt;        count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; counter.q
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I designed it so that the output &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; will increment by one on every rising edge of the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; input. However, does 
it actually work?!? There&#x27;s no way to know. Oh wait, we could test it.&lt;&#x2F;p&gt;
&lt;p&gt;Here is my test bench that does just that.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;testBench myTestBench &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0a8dbf;&quot;&gt;sig&lt;&#x2F;span&gt;&lt;span&gt; clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; signal to use as my clock
&lt;&#x2F;span&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;span&gt;    counter dut &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;.clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; device under test
&lt;&#x2F;span&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;fun&lt;&#x2F;span&gt;&lt;span&gt; tickClock&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;        clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;    
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;test&lt;&#x2F;span&gt;&lt;span&gt; simpleTest &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#969696;&quot;&gt;&#x2F;&#x2F; initialize the clock
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;100&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$print&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dut.count&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$assert&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dut.count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;==&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tickClock&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;        
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$assert&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dut.count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;== &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;100&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The insides of a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;testBench&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; are very similar to a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#faac1f;&quot;&gt;module&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; with a couple of key differences. There are no ports
or parameters and instead of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;always&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; blocks you use &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;test&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;fun&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; blocks.&lt;&#x2F;p&gt;
&lt;p&gt;On line 2, we create a signal named &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; that will act as our clock.&lt;&#x2F;p&gt;
&lt;p&gt;On line 4, we instantiate the device under test or &amp;quot;dut&amp;quot;. It is convention to call the module being tested &amp;quot;dut&amp;quot; but 
there is nothing special about the name.&lt;&#x2F;p&gt;
&lt;p&gt;Next, we have our function declaration. Functions have the same properties as tests, but they aren&#x27;t run directly. 
Instead, functions are little pieces of helper code that can be called from tests.&lt;&#x2F;p&gt;
&lt;p&gt;Here I defined the very common function of toggling the clock and called it &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;tickClock&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. This function doesn&#x27;t have any
parameters, but it could.&lt;&#x2F;p&gt;
&lt;p&gt;For example, we could give it a parameter to repeat a specified number of times.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lucid&quot; style=&quot;background-color:#282828;color:#ffffff;&quot; class=&quot;language-lucid &quot;&gt;&lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;fun&lt;&#x2F;span&gt;&lt;span&gt; tickClock&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;times&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;32&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;]) {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;times&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;        clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        clk &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;0
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Function arguments act the same as module inputs and can be multidimensional arrays or structs.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;test-bench-functions&quot;&gt;Test Bench Functions&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#test-bench-functions&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Before we move on, let me quickly go over the couple of test bench specific functions that I&#x27;m using.&lt;&#x2F;p&gt;
&lt;p&gt;The function &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is at the very core of the simulation. It initiates a simulation tick. So what is a simulation
tick? This is when the simulator publishes all signal changes and recalculates the outputs for all the pieces in the 
design whose input signals changed. Those output changes then trigger other updates if they are used as inputs. This 
continues until the results of everything stabilize.&lt;&#x2F;p&gt;
&lt;p&gt;The only time it won&#x27;t stabilize is if you have some kind of dependency loop like &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;a &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; b&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; and &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;b &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= ~&lt;&#x2F;span&gt;&lt;span&gt;a&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;. In this case, 
the simulator will quit after 1000 iterations. I chose this number as a seemingly nice upper bound, but it may change if
I find designs often need more or fewer iterations. A loop like this would result in faulty hardware, and anything 
requiring too many iterations to resolve would likely be too complicated to do in a single real clock cycle.&lt;&#x2F;p&gt;
&lt;p&gt;So back to the test bench. Before we call &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;, first we need to set a value to all signals we are using. Signals 
default to having a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;bx&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; value so bad things will happen if we call &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; before setting a real value. By bad things,
I mean that &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;bx&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; value will propagate throughout the design contaminating our counter.&lt;&#x2F;p&gt;
&lt;p&gt;With &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;clk&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; set to 0, we call &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; to initialize the design.&lt;&#x2F;p&gt;
&lt;p&gt;Next, we hit a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;font-weight:bold;color:#0abfbf;&quot;&gt;repeat&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; block that will repeat its contents 100 times and use the signal &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; as the iteration index.&lt;&#x2F;p&gt;
&lt;p&gt;The first line in the loop prints the value of &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;dut.count&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; using the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$print&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function. This function takes one
argument, the value to print. It currently outputs the value in the format &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span&gt;dut.count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;= {&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;00011100&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;} : &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a269dc;&quot;&gt;28&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; where the value
is shown in its binary form as well as its decimal value (if it has one).&lt;&#x2F;p&gt;
&lt;p&gt;The next line uses the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$assert&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; function to check that the value of the counter matches the loop iteration we are on.
The argument to &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$assert&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; can be anything, and it is treated as a boolean. That means if it is non-zero, nothing 
happens, but if it is zero, the simulation is aborted and the &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$assert&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; that caused it is called out.&lt;&#x2F;p&gt;
&lt;p&gt;This is very useful for checking values quickly without having to look back through the simulation manually to see if 
values make sense.&lt;&#x2F;p&gt;
&lt;p&gt;The last line in the loop is the call to the function &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tickClock&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; that we already defined.&lt;&#x2F;p&gt;
&lt;p&gt;Finally, we end our test by checking that the counter output is 100 after the 100 cycles.&lt;&#x2F;p&gt;
&lt;p&gt;This example is from one of the tests and can be found in the 
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;LucidParserV2&#x2F;blob&#x2F;9795d9dcea1a769be7567025b15607549c36edc3&#x2F;src&#x2F;test&#x2F;kotlin&#x2F;TestBenchTests.kt#L45&quot;&gt;repo here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;next-step&quot;&gt;Next Step&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#next-step&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The next step is to add snapshots of the entire design every time &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$tick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; is called. This will allow for the 
simulation results to be shown after it is run. Currently, it just runs discarding all intermediate values.&lt;&#x2F;p&gt;
&lt;p&gt;I also plan to have a &lt;code class =&quot;language-lucid&quot; data-lang=&quot;lucid&quot;&gt;&lt;span style=&quot;color:#1bddaf;&quot;&gt;$silentTick&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ed4343;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;code&gt; or similarly named function that does a tick without taking a snapshot. This way
you can use that when making the clock fall for most designs and avoid the overhead of an entire snapshot.&lt;&#x2F;p&gt;
&lt;p&gt;As before, there is a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alchitry&#x2F;LucidParserV2&#x2F;discussions&quot;&gt;discussion page&lt;&#x2F;a&gt; setup as part of the repo
where you can let me know your thoughts.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Lucid V2 - Update 1</title>
        <published>2023-05-30T00:00:00+00:00</published>
        <updated>2023-05-30T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/lucid-v2-update-1/"/>
        <id>https://alchitry.com/news/lucid-v2-update-1/</id>
        
        <summary type="html">&lt;p&gt;I just pushed what I believe is the last piece of the core Lucid 2 rewrite.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Lucid V2</title>
        <published>2023-05-18T00:00:00+00:00</published>
        <updated>2023-05-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Justin Rajewski
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://alchitry.com/news/lucid-v2/"/>
        <id>https://alchitry.com/news/lucid-v2/</id>
        
        <summary type="html">&lt;p&gt;A full rewrite of the Lucid parser in Alchitry Labs has been a long time coming.&lt;&#x2F;p&gt;
</summary>
        
    </entry>
</feed>
