Tutorial series?

HDL's and logic cells!

Moderator: phalanx

Post Reply
sgrace
Posts: 5
Joined: Tue Feb 18, 2014 3:34 pm

Tutorial series?

Post by sgrace » Wed Feb 19, 2014 12:48 pm

Hi all,

Thanks to phalanx getting an FPGA forum setup for us, I was talking in the IRC channel on doing a tutorial series to go over finer points of building a design from scratch for FPGAs.

However, there are a lot of topics that can be covered in tutorials, and I'd like to stick with one until it is complete. With that said, I came up with the idea that since people have questions on UART/SPI/I2C, I figured it'd be awesome to do a series on implementing each one of these on an FPGA (basically UART/SPI/I2C converter). This will help others understand exactly what a very generic serial basic communication protocol does, plus it gives everyone a core to use in their designs!

I'd like to hear everyone's thoughts on this, because I don't want to do something people aren't interested in.

Thanks
sgrace

PS: Here's my SFE profile page: https://www.sparkfun.com/users/88029 for that don't know that I am a practicing FPGA engineer.

User avatar
phalanx
Non-SFE Guru
Posts: 1973
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: Tutorial series?

Post by phalanx » Thu Feb 20, 2014 7:08 am

I have a feeling that you will run into 2 types of people looking at this. The first are people like you and me who have varying degrees of experience with programmable logic and the second who have none whatsoever. Given the general audience of this forum, I would be targeting the latter group which will probably be lost if you start with a core implementation.

I would start with an intro to FPGA's: what it is they do, how they do it, I/O pins, clock lines, logic cells, block ram, and any other integrated hardware features.

Given how overwhelming the tool chains can be for a new user, I would then go over the basics of navigating through the ISE WebPACK or Quartus Web Edition and explain the concepts of Synthesis, Implementation, and programming file generation.

From there I would do a simple schematic capture design to do something simple like flash an LED or create a multi-bit adder and carry it through to loading it onto an actual board.

Once the basics have been covered, then I would move along to HDL's. There are lots of tutorials for VHDL and Verilog but not many cater to laypeople. Concepts like concurrent vs. sequential and behavioral vs. structural should be stressed.

After all that is covered, then I would start to introduce core creation.

This is only my 2 cents and since I'm not the one writing the tutorials, feel free to rip it apart!

-Bill

sgrace
Posts: 5
Joined: Tue Feb 18, 2014 3:34 pm

Re: Tutorial series?

Post by sgrace » Thu Feb 20, 2014 12:18 pm

Thanks for the feedback phalanx! I'll take it into consideration.

I do want to mention that a lot of the software nowadays have moved away from schematic capture due to the complexity it has in general. As the years go by, designs get bigger and more complex and schematic capture gets harder to do. However, it is a great place to start.

User avatar
phalanx
Non-SFE Guru
Posts: 1973
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: Tutorial series?

Post by phalanx » Thu Feb 20, 2014 12:35 pm

I agree about the schematic capture. I used it maybe once when I was first learning about programmable logic in college. For people not used to HDL's, it makes combinational and sequential logic much easier to visualize. Once the new user understands the schematic, you can then describe it in an HDL example to help with the learning curve.

-Bill

User avatar
TrollHammer
Posts: 65
Joined: Wed Jun 06, 2012 8:26 am

Re: Tutorial series?

Post by TrollHammer » Mon Mar 31, 2014 10:16 am

Being a very fresh member of the 'latter group' (knowing little more than a basic understanding of what an FPGA is), I figured I'd comment on what I have run into so far (in case it helps a 'getting started' tutorial).

Last night, a friend of mine handed me a couple of boards out of his Dumpster Dive and said he figured I would get more use out of them than he would. One of which was a discontinued BOB-08595, a breakout board for a Spartan 3E. I have to say that the first impression I had reading about what the chip contained was amazement. The last time I looked at any kind of programmable array was PALs and GALs in the '90s, and at that point I wasn't sure what the benefit was over just using discrete logic 7400 series DIPs (considering the high cost of a programmer to a hobbyist, and the high availability of 7400 series chips via scrap circuit boards from the 70s my dad had laying around). I lost interest. Back to today, though, when I realized I had a project that couldn't be accomplished with about anything around (a small network of several Arduinos.) It hit me that the FPGA I was handed might be a way to do it.

My quick probing on the internet and on the site returned mixed results. I found some example code (on how to make a UART on FPGA of all things), and references to how things work on the chips, but I felt as though there was a gap of understanding: How do I get either my schematic or block diagram from my head into the chip? So far, this is what I have learned (or need to learn):

-There are two main processes for "programming" or "burning" an FPGA: Schematic Capture and Hardware Descriptive Language (HDL). For me, (having a good understanding of how to create circuits from a box of components such as resistors, capacitors, diodes, transistors, gates, inverters, etc) it seems like Schematic Capture would be the way to go, but there is such an attitude of rejection of this process it is hard to find ANY information about it beyond what it is. HDL is much more widely supported and is perhaps a little friendlier for those acquainted with programming a standard processor, I guess. The two main flavors that I am finding are VHDL and Verilog. Most of the software I am coming across is propriatary and "pay" software, which really discourages a "switch" to FPGA for me. I have no problem paying for software I know I will use, but I am used to Arduino and C that have plenty of resources around so you can see if it is going to fit what you need first. (I have seen the Web version of Xilinx's ISE, but as it is 5-7GB of download it will have to wait until I can work a download to mess with it.)

-Compilers/loaders/whathaveyou seem to be proprietary. For an Arduino, you could go with an ARM development package from a variety of vendors, or the Arduino software, and I'm not sure there aren't many other ways of going about playing with them. This Xilinx FPGA appears to be locked into using Xilinx software and I'm not sure what hardware will be needed to connect to it, if I will also need to buy additional or proprietary cables, USB boards, or whatever else. I'm not expecting to get much support for an obsolete Sparkfun product, but the Spartan seems to be fairly common and out on the web I find little that doesn't direct me to Xilinx, and little information about actually using the chip.

Well, I'll add more as I learn more. I guess what I'm saying is that, after working with Arduino, it would be nice to have a specific "getting started" tutorial that lists:

-What hardware you will need to complete the tutorial (complete list, assuming nothing)
-What software you will need to complete the tutorial (complete list, with "common" alternatives if there are any)
-Step by step process to upload a (very) simple 'program', such as the 'blink LED' example I believe is on this site.
-Simple breakdown of what the example program is doing, what resources are being used on the chip, how many gates it took.
-A reference (link) to perhaps a code dictionary, similar to Arduino.cc's code library
-Notes of 'what not to do' that could ruin the device or make things really frustrating.

I think this would help me out as a beginner. Lacking a physical mentor I can ask questions, the next best way I learn is to go through the process at least once or twice. (Remembering back to when I started learning Arduino, there were so many times I got stuck with the simplest of quandries, such as, "if I upload my program, will it overwrite the bootloader and possibly lock the controller into just running THAT program?" If I had just had a walkthrough or someone there to say, 'no, the Bootloader and your program are handled seperately.' it would have saved me some stress. Bringing "simple" things up on forums these days can be frustrating, especially for beginners who don't grasp or use terminology correctly yet).

EDIT:
I will say that the tutorial link to the Mojo site for the Mojo board is pretty good. A little less scary now. Now if I can get the ISE downloaded...
Yes, I think strang... er, unconventionally.

sgrace
Posts: 5
Joined: Tue Feb 18, 2014 3:34 pm

Re: Tutorial series?

Post by sgrace » Fri Apr 04, 2014 6:58 am

Hi Trollhammer,

Thanks for the response.

The general feedback I've been getting is what you are saying. Something that will allow someone familiar with the Arduino dev process to migrate to FPGA with very little resistance.

As for getting a design from your head to the FPGA is difficult even with that knowledge. In ISE, there is a schematic capture function, but it's fairly low level (gates, flops, comparators, etc). For something like UART it is do-able, but difficult to make sure it's right. The HDL side is still by far the most useful and most stable. To get something like UART in, you can go to http://www.opencores.org which has a ton of open source IP like UART you can use. The downside is they are hard to understand/work with, plus they have their own interface protocol called Wishbone (similar to AXI). The tutorial I wrote for SFE on the Papilio Pro is up: https://learn.sparkfun.com/tutorials/pr ... apilio-pro and it is still pretty complex, but it should give you an understanding of the flow.

Sadly, the compilers HAVE to be proprietary for FPGAs. Altera, Lattice, Xilinx, etc. need it this way to have a competitive edge against each other. The free versions of their software should be more than enough to work for anyone (even if they are GBs in size).

I like some of the tutorials that Papilio and Mojo put out, but they have drawbacks that as an experienced FPGA designer like me don't like. One of them is the ability to do in-circuit debugging. It's sort of like putting a logic analyzer to pins of an Arduino, but this is all software based and on the FPGA (you can see specific signals in your design). In order to use this feature, you need JTAG. But this is another topic altogether. Lastly, the software itself is very complex, and it has to be because of how complex the FPGA is. So besides understanding the power of the FPGA, you need to understand the power of the software.

Again, thanks for the feedback. If I continue to get more interest, I'll make an outline of a tutorial series with topics I'd write about.

monkeyxpress
Posts: 12
Joined: Thu Feb 19, 2015 9:59 am

Re: Tutorial series?

Post by monkeyxpress » Fri Feb 20, 2015 6:56 am

I agree with the post so far - aim it at totally new people. It is a pretty specialised field, and not a lot of information for beginners.

However, one thing I would think carefully about is the 'why'. Arduino really made embedded popular (I mean the AVR is a very old chip) because they turned embedded from 'bearded guy explaining how a computer works' into 'you can turn your sprinklers off with a timer!' and, 'you can make a cool door bell!' etc.

If we really want people to engage with programmable logic, we really need some useful and interesting projects for them to work on that show case the unique benefits of it. Unfortunately this is sort of the problem with FPGAs - the real use cases tend to be for very specialised applications (I mean, making a GPS correlator would be a great project, but not many people are going to be able to understand what it is doing).

Maybe something like if you could make a 'brain' for a biomimicry robot or something like that. It sequences through a logic table that controls the motors/walking solenoids and they can mess with creating 'neural nets' i.e. a sensor on the front so when it hits something it modifies the step sequencer etc etc. Basically show off the ability to have parallel sections doing different things. I'm just saying what is coming into my head so don't get fixated on the merits of this example, but hopefully you get my point.

Another idea could be to make a simple B+W video sequence generator. This is a good example of programmable logic because it is easy to do with an FPGA yet hard with a micro, and if it was a shield for Arduino they could then write images into it and do a game or something. A guy at the place I first worked did this and it was pretty awesome.

soyAnarchisto
Posts: 1
Joined: Fri May 08, 2015 1:27 pm

Re: Tutorial series?

Post by soyAnarchisto » Fri May 08, 2015 1:47 pm

Why? The bar for designing for FPGAs is high - but it is not as high as designing for an ASIC. They do not make sense for every application, for sure.

For those adventurous souls willing to wade into the deeper ends of the hardware design pool, here are some high level justifications for the adventure:

#1) performance - for critical algorithms, often you are able to achieve many orders of magnitude speedup over general purpose uProcessor or even a GPU. Of course you have to know how to implement this to achieve - and works for certain applications. FPGAs are inherently highly parallel devices, where microprocessors serialize the execution of a given function. If performance or latency are more critical than cost - FPGAs are often the answer.

#2) integration - often you can incorporate many off the shelf ASIC/ASSPs into a single device (eg, soc/processor, ethernet, pcie, usb, memory controller, etc) - replace many chips with one - and lower bom cost for a smaller footprint

#3)field programmability and functionality changes - you can't redesign an asic or assp in the field - but an FPGA can be updated in the field to upgrade it or fix bugs - this can be a strong competitive advantage. With things like partial reconfiguration you can dynamically update sub-portions of the design on the fly - even more power - but of course there is increased design complexity

It would be cool if there was a 7-series Zynq device based board which has an Arm processor on it instead of the mojo spartan-class device. The tool chain for Xilinx devices is VASTLY better for 7-series and newer devices. Tools are coming to make this even easier to allow people to write in C or OpenCL using kernels that will more easily target FGPA implementation for the software developer who doesn't fully understand FGPA/ASIC design and can avoid some of the more painful aspects of learning hardware description languages (HDL) which have rather steep learning curves.

Look at the Avnet MicroZED board:

http://zedboard.org/sites/default/files ... ish%29.pdf

Post Reply