option and then reselect the Default.wcfg
window. Select the View->Zoom->To Full View
menu item and you should now be able to view
the results of the Test Bench (Screenshot 4). As
you can see, our implementation of the 2-to- 4
line decoder with Enable works as advertised.
Okay, time for the fun part. Let’s load the
Mojo V3 and test the hardware! Close ISim and
go back to the Implementation view. Select
binary_decoder and in the Processes tree,
double-click on Generate Programming File. It
takes a surprising amount of time to generate
the binary file for the FPGA, so be patient.
Once it is complete, you should find the
binary_decoder.bit file in the syn sub-directory
of your root project directory. Following
Embedded Micro’s Creating a Project tutorial,
connect your Mojo V3 and program the FPGA.
To test the circuit, I wired up an eight-pin
DIP switch with 10K pull-down resistors to easily
toggle the inputs. Position “1” corresponds to
A0 and position “ 2” corresponds to A1. As you
can see in Photo 2, with an input of A = 11, the
output is D = 1000 as expected! Photo 3 is the
same value of A with EN tied to ground,
therefore disabling the output.
To learn more, I recommend the book
FPGA Prototyping By Verilog Examples by Dr.
Pong P. Chu. This is the book I am currently
working through myself, and it is very easy to
follow. In fact, the example circuit we wrote in
this article is one of the first suggested exercise
experiments by the author.
While the book is written for an older
Digilent Spartan-3A development board, it is
fairly easy to port them over to the Mojo V3 or
any other FPGA board you might be using. You
may have to supply some extra hardware, but
you probably have most of it lying around your
junk box. Of note, if VHDL is your thing, Dr.
Chu has an identical book written for that
So, you may be asking yourself, “What else
can I do besides combinational logic?” The
answer is ... virtually anything in the digital world!
Want to generate VGA or NTSC signals? No
problem (with the help of some digital-to-analog
conversion, of course). How about a custom
microcontroller core? Yup. An entire recreation
of the Nintendo Entertainment System? It’s been
done! An IBM PC or Apple II? Absolutely!
The learning curve is steep — especially if
you are accustomed to procedural programming
and microcontrollers. However, once you wrap
your mind around how the FPGA operates, its
parallel structure, and have an understanding of
digital logic, the possibilities are truly endless!
July 2015 39
If you don’t want to manually type in the code presented here,
it is available at the article link.
Ryan Clarke graduated from Worcester Polytechnic Institute (WPI) in 2003 with a B.S. in Electrical Engineering,
concentrating in Signals and Communication. While at WPI, he was inducted into Eta Kappa Nu (HKN), the IEEE
electrical engineering honor society. Ryan also holds an Amateur Extra FCC amateur radio license. Upon graduation,
he commissioned into the US Navy as an Ensign and is currently a Naval Aviator flying F/A-18F Super Hornets.