Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Just getting started in the world of Digital Circuits

Status
Not open for further replies.

Leep

Junior Member level 3
Joined
Oct 20, 2011
Messages
27
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,678
I'm an experienced software developer (Assembly, C, C++, VB, C#, ...) and am just starting to get into the world of digital circuit design. I'm 210% fascinated by it and am learning at a very rapid pace. I wanted to start playing with breadboarding some simple circuits (adders, muliplexors, etc) using logic gate chips as a means of learning, but I know I will quickly outgrow simple breadboards. A friend suggested I look into FPGAs and so I did. They look like they may be the perfect "playground" for me to learn with, but there is an overwhelming amount of information to learn before I can decide which to get. So I guess I'm hoping for some beginners advice. Tips, suggestions, where to start, etc.

I've looked at VHDL and Verilog syntax, and even though I have a strong C style background, I'm leaning more toward VHDL. It seems (to me at least) to be closer to "circuit design" than Verilog's "c" like syntax. I've only seen a few youtube videos on both though, so it's a very un-educated assumption at this point. :)

Money isn't TOO much of a concern (I'm ok with spending several hundred on an FPGA, but I'm not willing to spend thousands). I know I'd like something with a lot of (forgive me if I have any terminology wrong, still learning rapidly) logic units, and PROM would be nice so it could retain its programming without power. I don't really know what I want for inputs/output/ports/etc... When I was originally thinking of just breadboards and Radio Shack logic gates, I was probably going to use switches and LEDs. Now I see FPGAs with VGA and HDMI out and built-in character displays and USB and PCI ports and... As I said, quite overwhelming.

Maybe it might help to know that my immediate long-term goal (was that an oxymoron?) is to make a CPU (strictly as a learning project). I've been doing a LOT of learning on the architecture of CPUS. I'm not talking about anything anywhere CLOSE to as complex as, say, an Intel I7. I'm talking 8-bit bus, simple adder, simple instruction set, probably only 1 accumulator... all as a learning process. Will probably expand on it as I learn and improve it over months/years once I get it made initially. The FPGA is the next step in that learning process, so I can start actually playing for real instead of in a simple Hardware Simulator (worked though the book The Elements of Computing Systems by Noam Nisan and Shimon Schocken... Unbelievably good book).

I'll stop rambling now. I can't wait to hear what kind of feedback I get from the community here! :)

-----
Leep
 

That sounds like a great first project. That was actually my final year project at university. We had been tought an idealised instruction set in the 3rd year, and the 4th year project was to use that as the basis of a CPU. I used a basic stratix decelopment board, but could quite easily have been done on a cyclone dev board. For what you want, a cyclone board will be the best start point.

The architecture is now pretty similar between different families, but the more expensive parts tend to have more of it, and as you increase family expense (ie. cyclone -> arria -> stratix) you also get more IOs, PLLS and other high end stuff.

Just remember as you go through all this, VHDL and Verilog are NOT programming languages. Forget everything you remember about the design of a bit of C code, and come at it from the ground up. That way, when you're comfortable with VHDL descibing your circuits, you can then bring back in your C ways as you move into verification (you can do quite a lot with non-synthesisable VHDL).

So, get yourself up and running and feel free to come back with any more questions :)
 

For a list of boards:

Cheap FPGA Development Boards | Joel's Compendium of Total Knowledge

Personally I am partial to digilent boards, since they give me good value for money. The only drawback to the Atlys board is the VHDCI connector, which was not the best choice IMO. For the rest it's a pretty nifty board. You could get the cheaper nexys 3 if you don't care about gbit ethernet, and can live with the smaller spartan-6 device.
 

I learned about HDL from that book I mentioned. It came with a hardware simulator and its own flavor of HDL that was very simple and very much like wiring logic gates outputs to other logic gate inputs, etc:


CHIP Mux
{
IN a, b, sel;
OUT out;

PARTS:
And(a=b, b=sel, out=bandsel);
Not(in=sel, out=notsel);
And(a=a, b=notsel, out=aandnotsel);
Or(a=bandsel, b=aandnotsel, out=out);
}



I would prefer not to loose track of the fact that I'm wiring circuits and start feeling like I'm writing code. Writing "if condition then action else action" type statements, while possibly making it easier to design your logic, doesn't seem (to me at least) to promote learning digital circuit design (sort of like how learning 'C' doesn't help you learn Assembly, even though it compiles down to it... ok, it compiles down to machine code, which has a fairly 1-to-1 correspondence to Assembly). Do the IDEs you use when writing VHDL or Verilog have a means to display a generated logic gate diagram so you better visualize what your "code" actually creates?

I'm still learning the terminology of the field. I think I understand IOs (inputs/outputs... pins to wire your "code" to... that you can attach external things to, or that connect to "extra" things on the FPGA like LEDS, clocks, displays, etc, right?). PLLS I'll have to look up. :) I assume I can interface an FPGA to external devices, like if I have a external 7-segment display with like 10 7-segment displays, I could (somehow) connect its pins to the FPGA's pins and interact with it?
 

Xilinx and Altera have different viewers - the RTL viewer shows all of the circuit in higher level elements (adders, gates, multipliers etc) while the map view will show it down to the basic element level. If you want you can even view a floorplan of the FPGA (and you can usually switch between views, finding RTL elements in the floorplan and vice-versa). They are also very good (and getting better) at infering elements from behavioural code. Quartus tends to be better than XST at this (with quartus being more up to date with VHDL standards).

I would steer clear of any HDL that isnt VHDL or Verilog. They probably wont be supported in your synthesisor and definatly not in your simulator. A good example of this is AHDL (altera HDL). AHDL is to VHDL/Verilog what Assembler is to C almost (but a bit higher level than that).But dont bother with it.

You can write HDL how you want - you can write it in a structural style (like wiring things together on circuit board) or more abstract and behavioural (register transfer level or RTL code). The latter is usually the more portable code as structural usually requires vendor specific primitives, but you have to be aware of the subtle differences between the manufacturers.

FPGAs are great for interfacing external devices. Most of their IO pins (ranging from 10s to 100s, depending on device) can connect to almost anything anything. And the beuty is because it's an FPGA, you can control them all in parrallel. A PLL is a Phase lock loop, and is used for deriving other clocks from a single source clock, as well as tidying them up and setting the phase relationships. try to minimise your clock domains though - getting data across domains can be a pain.
 
Try DE2 cyclone board by altera.I learnt on this one, then moved on to stratix etc. It has quite a lot of features. Else try spartan of xilinx. I heard its good.

Altera DE2 Board Resources

You might have to be careful sometimes as some outputs are current outputs(mostly dac) and most of them are voltage outputs (most of the pins).
 

There's even 'simpler' devices called CPLD's, these can contain up to the equivalent of a few hundred gates or several dozen 74xxx parts for the smaller devices. You can buy boards based on these very cheap (for example Digilent C-Mod), and they're adequate to learn the basics.

But as soon as you want more, you're looking at FPGA's. So you might as well forget about CPLD's and get a FPGA board right away.

Altera and Xilinx entry-level devices (and boards) are both good to get into programmable logic. There are other manufacturers, but devices & boards are more difficult to find, and less well supported in terms of free (as in: no-cost) software support. Also far fewer people will be using these for learning purposes and therefore you'd have a harder time finding examples, or solutions if you get stuck somewhere.

There are a number of cheap FPGA boards (for eg. Papilio One, or have a look around on eBay) that leave it up to you to construct I/O (LEDs, switches, displays, card readers, VGA, etc, etc). Coming from a software POV, that may not be suitable for you & you'll probably do better to spend some more money on a board that has a number of I/O options onboard.

Maybe it might help to know that my immediate long-term goal (was that an oxymoron?) is to make a CPU (strictly as a learning project).
Definitely! Most simple 8-bit CPU's are in the order of 10-20K logic gates. And if you want to put together a SoC (system-on-chip), count on a number of times that. So a 'low-end' FPGA like a Xilinx XC3S50 (comparable with Altera FPGA of say, 2~3K LE's?) might be enough to implement a small CPU, but fall short when you want to do anything interesting with that CPU.

Also you'd want to use memory with that CPU, so it's useful if board has some SRAM or DRAM on it. Once you get to a point of running software on that softcore, an SD card reader comes in handy. And you'd want a decent number of I/O's so that you have the option to hook up things like old homecomputer peripheral chips. Therefore some good choices might be:
  • Xilinx Spartan-3 starter board
  • Xilinx Spartan-3E starter board
  • Nexys2 Spartan-3E board
  • Altera DE0 development board
  • Altera DE1 development board
  • Altera DE0-Nano board (if you don't mind some DIY to hook up peripherals)
For specific applications, there may exist boards with a more useful set of peripherals than Xilinx or Altera starter boards (for example the Arcade Replay board). Given the application(s) you have in mind, I'd go for something that has at least 100K gates (Xilinx) or 10K LE's (Altera). More is nice, much more is overkill & just costs you more.

As for circuit design: you could start using schematic entry, I myself have done some small projects that way. Once designs exceed a certain size, schematic entry becomes impractical and Verilog or VHDL is the way to go.
 
Last edited:

@RetroTechie,

I considered CPLD's to start with and quickly realized I would out grow them too quickly. You mentioned the Xilinx Spartan-3 series boards as "good choices"... what about the Spartan-6? I've been looking at the . How would you say that compares with the boards you mentioned? The site says it has "6,822 slices each containing four 6-input LUTs and eight flip-flops" which I *THINK* I understand... LUT means Look Up Table, right? So basically MUX implemented truth tables. So it has 6822 * 4 LUTs and 6822 * 8 flip-flops? How does that equate to "number of gates"?
 

Hard to answer - most FPGA's use 4-input LUTs if I'm not mistaken. So 6-input LUTs would mean that one LUT can implement a more complex logic function, one that would require multiple LUTs on other FPGA. For some designs that might not help much, for other designs that might mean a more efficient implementation.

It's really comparing apples & oranges. But if you take price, IC package & board I/O options as indicators, it looks like this is a bigger device than what you'd find on a low-end Spartan-3(E?) board.

Nothing wrong with more, or Spartan-6 FPGAs (I have my own idea of what 500K gates is worth to me vs. 200 or 100K gates). But given your description of what you'd use the board for, I don't see what the extra $$ for this Atlys board would buy you. Besides: if you put a design together in a decent manner, it's not like it would be a helluvalot work to move it to another board, once that becomes necessary.

How much time you think will pass before a board with say, 200K gates equivalent becomes too small for your projects? If you buy a board that's got 10X more capacity than you'll use in years to come, that would mean wasting $$ on things you don't use anyway all that time. Fast forward a few years & something like that Atlys board will be much cheaper.

Analogy: if you want to play First Person Shooters, a 3D card probably is a must. But if those First Person Shooters are 'just Doom, Quake and games based on same engines', what would a current, high-end 3D card buy you? Exactly: nothing (only high electricity bill :wink:).
 

I'm now looking at these three boards. I'm trying VERY hard to resist the urge to just buy anything to start playing with it knowing I might eventually decide to get something else. :)


Spartan 3E Development Board
Spartan 3E-1600 Development Board

They're all around the same price range and have a good number of "gates" (the 3E-1600 boasts 1600K gates). I like the fact that these have VGA on them, but I'm unclear on how it works... Some of the documentation made it look like I had to directly control the R/G/B signals and vary them with time in sync with the vertical/horizontal refresh rate of the monitor (or something like that). Am I understanding that correctly? Is the resolution/color depth it can handle simply a matter of my circuit design (and the monitor's capabilities of course), or are there inherit limits in the VGA that comes on these (or other) FPGAs? I guess my only experience is from buying VGA cards for PCs (the card regulates the resolutions/colors it can do) and I'm trying to ignore that experience because I suspect it might not apply here.
 

yes, you will have direct control over the RGB and timing signals in the RGB output. You will either need to write your own controller, or get an ip block (there is probably one on opencores.org). Controlling video signals is fairly straight forward. You just run a couple of counters (pixel and line counts) at an appropriate frequency and generate the timing signals. The RGB could come from anywhere - a test pattern generator, memory, an input.

Its all up to you.
 

I would prefer not to loose track of the fact that I'm wiring circuits and start feeling like I'm writing code. Writing "if condition then action else action" type statements, while possibly making it easier to design your logic, doesn't seem (to me at least) to promote learning digital circuit design (sort of like how learning 'C' doesn't help you learn Assembly, even though it compiles down to it... ok, it compiles down to machine code, which has a fairly 1-to-1 correspondence to Assembly). Do the IDEs you use when writing VHDL or Verilog have a means to display a generated logic gate diagram so you better visualize what your "code" actually creates?
You can enter the design as a "normal" schematic using primitives as inverters, gates etc. You can also design blocks that you use in another schematic page. You don't have to think about LUT's etc.
The schematic entry is just an alternative way to describe the function you want. The tool will then "compile" it and map the design to the resources in the selected chip.
 

That's very nice to know. If you enter your design in "schematic mode", can it show it as VHDL/Verilog code, and if you enter it as VHDL/Verilog code can it show it as a schematic? Would be very handy for learning how one "translates" into the other...

---------- Post added at 12:55 ---------- Previous post was at 12:54 ----------

I'm still a little foggy (ok, a LOT foggy, but less foggy than yesterday) on the VGA. Let's take the Digilent Spartan 3E Starter Kit board. Its User Manual states "Each color line has a series resistor, with one bit each for VGA_RED, VGA_GREEN, and VGA_BLUE." and "The Spartan-3E Starter Kit board uses three bits per pixel, producing one of the eight possible colors shown in Table 6-1".

Is this "three bits per pixel" a limitation of the hardware (I'm assuming there's some kind of "onboard" VGA controller?), or would it be possible to design a system using the FPGA that used 3 bits for red, 3 bits for green and 2 bits for blue (8 bits per pixel) or 8 bits for each R, G and B (24 bit pixels)?

In other words, when comparing different FPGA boards to decide which one I want to get, should I be concerned with these "limits", or just whether or not it has VGA? I've seen some that say 3-bits/pixel and some that said 8-bits/pixel. If I can write my own contoller to use higher color depth, then those limits don't bother me as much.
 

If you enter your design in "schematic mode", can it show it as VHDL/Verilog code,

No.

... and if you enter it as VHDL/Verilog code can it show it as a schematic?

sortof .. ish.

You can get an RTL view and a technology view after you have synthesized the design.

---------- Post added at 21:24 ---------- Previous post was at 20:54 ----------

Analogy: if you want to play First Person Shooters, a 3D card probably is a must. But if those First Person Shooters are 'just Doom, Quake and games based on same engines', what would a current, high-end 3D card buy you? Exactly: nothing (only high electricity bill :wink:).

The high end 3d card would buy me a nice CUDA number cruncher ... and highly detailed zombies to shoot. :p
 

I'm still a little foggy (ok, a LOT foggy, but less foggy than yesterday) on the VGA. Let's take the Digilent Spartan 3E Starter Kit board. Its User Manual states "Each color line has a series resistor, with one bit each for VGA_RED, VGA_GREEN, and VGA_BLUE." and "The Spartan-3E Starter Kit board uses three bits per pixel, producing one of the eight possible colors shown in Table 6-1".
In schematic you can see that can see that VGA connector is wired up with hsync, vsync, and for each of red /green / blue, a single FPGA output pin with series resistor (which gives desired output level when loaded with 75 Ohm on monitor side, as is usual for analog video signals). IIRC that's also the case for the bigger Spartan 3E-1600 board.

So for each pixel you can turn individual RGB levels off, or full brightness. Which gives you 8 different combinations (colors). Pretty basic, but it means you can produce color VGA signal (and using very few I/O's to do it). If I'm not mistaken the Nexys3 board uses 3+3+2 bits for R/G/B respectively (so nothing like truecolor, but still a wide color palette).

Is this "three bits per pixel" a limitation of the hardware
Yes. But better read that as "a limition of the hardware as it gets delivered to you". Nothing says that you can't take some general purpose I/O pins, add some resistors & thus rewire that onboard VGA port. Or wire up another VGA connector to some of the general purpose I/O pins. Or whatever audio/video connector you want.

(I'm assuming there's some kind of "onboard" VGA controller?)
No there isn't. The idea is you use the FPGA to generate those R/G/B bits + hsync/vsync signals. How you do that, is totally up to you. But for example OpenCores will have some simple VGA controller project(s) that you could use as a building block.

or would it be possible to design a system using the FPGA that used 3 bits for red, 3 bits for green and 2 bits for blue (8 bits per pixel)
With that Nexys3 board you'd have that already.

or 8 bits for each R, G and B (24 bit pixels)?
Yep, just takes I/O pins & some resistors, wires + VGA connector (if you want to keep things simple). Higher color depth -> more bits (I/O pins) per color.

In other words, when comparing different FPGA boards to decide which one I want to get, should I be concerned with these "limits", or just whether or not it has VGA?
Neither. Like I wrote before: onboard I/O options are not so much 'limitation', but rather convenience items. If you just need a single on/off button & there's one on board, you can simply use it. If there isn't, you have to wire up a switch to an I/O pin - which is extra, boring work.

There is no 'perfect' FPGA board for you to find in this sense: if it had everything you could ever want onboard, there'd be nothing left for you to design / add. So by definition you'll have to build some things from scratch. Onboard peripherals are just things that allow you to not waste time adding simple things like a few pushbuttons, LEDs etc. If you really have a specific application in mind, go get a board that's specialized for that purpose. Like one with onboard touchscreen if you're into embedded media devices, or that Arcade Replay board if you're into arcade gaming (which given your budget, might be a nice option for you btw). Or one with Ethernet and Bluetooth if you're into networking applications.

Just make sure to read manual and/or schematic carefully before buying, so that you have a good idea what you're getting & whether or not it suits your needs.
 
Last edited:

Thanks for the reply! Very good information. I was coming to the same conclusion about the VGA. Found a YouTube video where someone had taken a Digilent board and, even though it had the 3-bit/pixel VGA already, they wired their own VGA connector to it to get 5/5/5 RGB. That made the light come on for me about what you were saying. The "extra" devices on the board are simply for convenience. You can use them, or not, or "Breadboard" your own to interface with.

BTW, I think I've about decided on the Digilent Nexys3. I want to think/research a little more before committing to the purchase. I wish I could find a local store that I could buy it from, but Radio Shack said they didn't carry FPGAs and the only other electronics store (mom-n-pop) in my area said they would have to special order it. So, no "instant gratification" for me once I finalize the decision. :)
 

As you already found out, you can add more resistors. What makes sense and what doesn't will also depend on what kind of resolution you are aiming for. Both the nexys2 (spartan-3e) and the nexys3 (spartan-6) have the 3/3/2 resistor vga. The atlys has hdmi, which will get you 24-bit at 720p at least. And as I recall also 1080i, but not 1080p. But judging by your "I think I've about decided on the Digilent Nexys3" I gather your project requires only moderate resolution, in which case Nexys 3 certainly makes sense.

Edit ... Forgot to mention: you can forget about 24-bit high resolution with the resistor array, since you will run into RC time constants (putting a limit on your pixel clock) and resistor mismatch (putting a limit on color number of effective bits). Mostly the pixel clock is the limit, because if you reaaaally want to you can hand pick resistors.
 
Last edited:

I ordered the Nexys3 yesterday. I figure the 3/3/2 vga would be sufficient for anything I wanted to do for a quite a while, and I can add more resistors/connectors/hardware in the future should I want. As for project, the only project I have is to learn digital circuit design with the design of a CPU being my (current) long-term goal. I just wanted to make sure I got an FPGA board with as nice a "playground" as I could. I knew I would want to play with graphics (I miss the old days of memory-mapped graphics and setting pixels by calculating bit positions... [CoCo I,II,III, 8088] ...) and mouse/keyboard for input, and have lots of memory available.

I'm sure I'll have plenty more questions once I get the Nexys3 in my hands and start playing with it. :)
 

Just wanted to follow up here... I got the Nexys 3 board about a week ago. Continued my digital circuit/vlsi studies (watching over 100 hours of lectures from **broken link removed**) a bit before playing with the board. Last night I successfully made a couple of very small circuits (flip 3 switches in binary format (0-7) to turn on 7 LEDs, make a number show up on one of the 7-segments, etc) and got them synthesized, and to the board and they worked. I've definately settled on Verilog for a language. At first I was going to go with VHDL because I didn't want to be "lulled" into a false feeling of "coding" when I'm actually wiring circuits (Verilog was too "C" like), but then I realized I'm just more comfortable with the "C" likeness of Verilog and it was easier to learn because of that.

Now I'm going to start playing with the VGA (3/3/2), usb, ethernet, memory, etc. Basically I'm learning how to interact with the playground surrounding the Spartan 6 chip. Once I get familiar enough with that, I'll start working on my CPU design. Lots of fun (and learning!) ahead.

Can anyone suggest a good repository of sample Verilog code (specifically for the Nexys 3 preferably, but any would be nice)? I did a quick Google search and couldn't find any Verilog VGA examples (didn't do a very extensive search though, it was 3am). Specifically I'm looking for examples of how to interact with the external hardware (external to the Spartan 6, but on the board), which is why I mentioned that examples specifically for the Nexys 3 would be nice, but any would be very helpful.

Thanks for all the help I've gotten so far! I'm glad I found this community and I'm excited to be a part of it now! :)
 

Last night I successfully made a couple of very small circuits (flip 3 switches in binary format (0-7) to turn on 7 LEDs, make a number show up on one of the 7-segments, etc) and got them synthesized, and to the board and they worked.
On 1st try? Congrats, not bad at all. :-D

Can anyone suggest a good repository of sample Verilog code (..)
I suggest you dowload a tutorial (+code samples) that goes with ISE from Xilinx website, if you work through that you get a decent overview of how the Xilinx tools work, that is: what program does what, where to set things like timing constraints etc etc.

Next: register @ OpenCores. As far as I know, it's the place for open source FPGA projects (& a few open design boards & more). You need to be registered there in order to download projects, but for an idea you can browse the project index to see what's available.

Btw: you don't need Verilog code necessarily - it's possible to create modules in other language like VHDL (or even schematic), assign some named input/output signals, and then use that as a 'plug-in' in your own code / top level schematic. So even though it helps if you can read / understand that module's source, you could just grab a simple CPU coded in VHDL, and only worry about what goes in & what comes out.

And for use on your development board, the only important thing is to properly assign pins - I assume a board like Nexys 3 comes with a constraint file (*.ucf) that helps you match I/O's to your board.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top