Learning path for FPGA

Discussion of developmental aspects of the MiSTer Project.
Bas
Top Contributor
Posts: 518
Joined: Fri Jan 22, 2021 4:36 pm
Has thanked: 60 times
Been thanked: 225 times

Learning path for FPGA

Unread post by Bas »

Hey all. I've been thoroughly loving my MiSTer setup for months now but would like to be able to dabble with it some more. I'm coming more from a home computer conservation angle than a gamer. As such a core that faithfully implements an IBM XT would interest me, even though AO486 is probably already mostly compatible. My feeling is that much of what is needed for such derived cores (for lack of a better word) is already mostly available, it just needs effort to bring together. I'd like to try and see what I'd be capable of myself, cobbling parts together.

My big problem is that I'm a software dev (started in the 80's on 6502 ASM) and am having trouble finding a good place to pick up the learning path towards hardware and FPGA.

I know this is a specialism all its own and I won't be productive anytime soon. Any help in where to start would be much appreciated. Stuff like books or an outline of the curriculum you pro FPGA gurus used to follow in university (I presume) would help.
robinsonb5
Posts: 129
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 57 times

Re: Learning path for FPGA

Unread post by robinsonb5 »

I think I'd start with something simple - maybe take the MemTest core, learn to built it in Quartus, then figure out how to change the background colour and text colour. (My first project was on the Turbo Chameleon 64 cartridge - I took the hardware diagnostic core and used the graphics primitives and PS/2 mouse component to implement a simple "Pong" game.)

You're going to encounter both VHDL and Verilog - both languages have their pros and cons. VHDL will throw a compilation error for the tiniest of mistakes. Verilog will quite often march straight past the most blatantly wrong code and silently produce a non-working core as a result! For this reason, I tend to consider VHDL the better language for learning, at least until you have the base concepts secure.

The most important thing is to understand what type of logic is being described by your code, understand the difference between combinational logic and registers, and understand the difference between blocking and non-blocking assignments.

Would there be wider interest in some tutorials at some point?
User avatar
jimmystones
Core Developer
Posts: 216
Joined: Sun Nov 22, 2020 1:26 pm
Location: Reading, UK
Has thanked: 32 times
Been thanked: 248 times
Contact:

Re: Learning path for FPGA

Unread post by jimmystones »

I second the above comments. Personally I started by copying a feature (NVRAM save/load) from one core to another. Looking at the git diff for the changes made to implement a single feature helped me understand what was related to what. Trying to understand an entire core + framework from the start was too much for my brain to handle!

Also I found this site https://hdlbits.01xz.net/ useful for getting Verilog concepts straight in my head.
User avatar
Alkadian
Top Contributor
Posts: 721
Joined: Thu May 28, 2020 9:55 am
Has thanked: 289 times
Been thanked: 116 times

Re: Learning path for FPGA

Unread post by Alkadian »

robinsonb5 wrote: Sun Feb 21, 2021 11:32 am I think I'd start with something simple - maybe take the MemTest core, learn to built it in Quartus, then figure out how to change the background colour and text colour. (My first project was on the Turbo Chameleon 64 cartridge - I took the hardware diagnostic core and used the graphics primitives and PS/2 mouse component to implement a simple "Pong" game.)

You're going to encounter both VHDL and Verilog - both languages have their pros and cons. VHDL will throw a compilation error for the tiniest of mistakes. Verilog will quite often march straight past the most blatantly wrong code and silently produce a non-working core as a result! For this reason, I tend to consider VHDL the better language for learning, at least until you have the base concepts secure.

The most important thing is to understand what type of logic is being described by your code, understand the difference between combinational logic and registers, and understand the difference between blocking and non-blocking assignments.

Would there be wider interest in some tutorials at some point?
@robinsonb5,

I have just found your post and I would really appreciate if you could share some tutorials whenever you get a chance. For the reasons you have rightly mentioned here, I have been thinking to go down the route of VHDL or at least for now. Indeed my goal would be to learn the basics of VHDL, Quartus and Mister framework and try to help others with their existing cores and as such try and give my little tiny contribution if I will ever reach a decent level. At least I have got a lot willingness to start with as I really feel I want to help! I understand it will take time to digest it all but again I feel ready :mrgreen:

Anyway I have already started looking at different online resources that have been kindly advised in other threads in the forum as a starting point. But 'proper' tutorials will definitely help.

Also books wise, would someone please be so kind as to advise between these two books:

https://www.amazon.co.uk/dp/0983497354/

https://www.amazon.co.uk/dp/1119282748/

Shall I start with the first book and then move to the second one? Or shall I invest directly on the second one?

I know I know..I can hear you and guess what..you are right I am confused :lol:

Thanks a lot!
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

The first one is mostly a description of the language, without much information on how to put it to use.
The second one should be pretty good, but uses a Xilinx board (additional expense) and Xilinx software.

The skills are transferrable but may not be exactly one-for-one when transferring to DE10-Nano.
I think that author also had an Altera-focused book, maybe check to see if it’s still available.
User avatar
Alkadian
Top Contributor
Posts: 721
Joined: Thu May 28, 2020 9:55 am
Has thanked: 289 times
Been thanked: 116 times

Re: Learning path for FPGA

Unread post by Alkadian »

dshadoff wrote: Sun Mar 21, 2021 3:24 pm The first one is mostly a description of the language, without much information on how to put it to use.
The second one should be pretty good, but uses a Xilinx board (additional expense) and Xilinx software.

The skills are transferrable but may not be exactly one-for-one when transferring to DE10-Nano.
I think that author also had an Altera-focused book, maybe check to see if it’s still available.
Thanks for your feedback, much appreciated. Would you mind comfirming that the book below is the one you were referring to?

https://www.amazon.co.uk/Embedded-SoPC- ... 111800888X

Thanks a lot!
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

Yes, this looks like the one I was referring to. It's a bit old - referring to DE1 and DE2 boards - but it's Altera- and Quartus-based.

Altera likes to push their "NIOS processor" which is effectively a CPU implemented in FPGA logic, as a means of performing sequential operations... They still do this, so those skills aren't out-of-date. However, you should know that MiSTer does not use NIOS, as the DE10-Nano includes its own ARM processor implemented in hardware. So don't get hung up on the NIOS-specific aspects. It might be useful on other FPGA boards at some other time, but not in MiSTer.

In general, when starting out, I would suggest that the major points of learning won't be Verilog versus VHDL - these are really just syntaxes - but rather, a method of thinking about how to design things in FPGA logic, using clocks, sequential logic, and combinational logic.

You will be getting a lot of feedback from the "compiler"/developer software, so it is important to become accustomed to one of them first (later, once understood, these are transferrable skills to other FPGA systems and development software as well).

Major aspects of the dev software you should get accustomed to are:
- The overall process of compilation
- why clocks are special
- how to prepare testbenches/simulations
- how to use the built-in logic analyzers (SignalTap on Altera chips)
- when and how to invoke specialized hardware (i.e. "megafunctions" on Altera)

Most beginner books don't spend even a moment introducing these concepts, which is why a proper course-like textbook is useful. Unfortunately, most are written for Xilinx FPGAs... and while the skills are transferrable, the boards they suggest to use are in the $300 range... plus the book itself.

Since you (probably) already have the DE10-Nano, you should start by looking at the documents supplied by the maker, such as "My First FPGA" and the "DE10-Nano User Manual" here:
https://www.terasic.com.tw/cgi-bin/page ... 6&PartNo=4

And just remember that we use version 17.0.x of Quartus for MiSTer cores, so get that version when you download Quartus.
Bas
Top Contributor
Posts: 518
Joined: Fri Jan 22, 2021 4:36 pm
Has thanked: 60 times
Been thanked: 225 times

Re: Learning path for FPGA

Unread post by Bas »

Love the discussion.. an additional point from this sysadmin/devops type IT geek: which foundational works on EE would be useful? While code is familiar enough, I feel like I'm sorely lacking in the EE department.
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

Um... that's a big subject. Analog electronics can really be thought of as a separate things from digital. Perhaps - unless you want to work on audio and CRT repairs - you might want to look at digital. I don't think I can really offer a good starter book though.
ExCyber
Posts: 217
Joined: Sun May 24, 2020 3:33 pm
Has thanked: 11 times
Been thanked: 66 times

Re: Learning path for FPGA

Unread post by ExCyber »

For MiSTer-type FPGA work, the most relevant topic within electrical engineering is probably "digital design", and there are various introductory textbooks about it that are HDL-oriented. Some of the older ones probably have more of an emphasis on techniques that are only relevant for ASIC designs and not so much for FPGA. I personally mostly learned the fundamentals in an academic sense from a combination of these, although I wouldn't necessarily describe them as "foundational":
  • Computer Organization and Design: The Hardware/Software Interface; Patterson/Hennessy
  • Digital Design; Mano/Ciletti
  • Advanced Digital Design with the Verilog HDL; Ciletti
User avatar
Alkadian
Top Contributor
Posts: 721
Joined: Thu May 28, 2020 9:55 am
Has thanked: 289 times
Been thanked: 116 times

Re: Learning path for FPGA

Unread post by Alkadian »

dshadoff wrote: Sun Mar 21, 2021 5:08 pm Yes, this looks like the one I was referring to. It's a bit old - referring to DE1 and DE2 boards - but it's Altera- and Quartus-based.

Altera likes to push their "NIOS processor" which is effectively a CPU implemented in FPGA logic, as a means of performing sequential operations... They still do this, so those skills aren't out-of-date. However, you should know that MiSTer does not use NIOS, as the DE10-Nano includes its own ARM processor implemented in hardware. So don't get hung up on the NIOS-specific aspects. It might be useful on other FPGA boards at some other time, but not in MiSTer.

In general, when starting out, I would suggest that the major points of learning won't be Verilog versus VHDL - these are really just syntaxes - but rather, a method of thinking about how to design things in FPGA logic, using clocks, sequential logic, and combinational logic.

You will be getting a lot of feedback from the "compiler"/developer software, so it is important to become accustomed to one of them first (later, once understood, these are transferrable skills to other FPGA systems and development software as well).

Major aspects of the dev software you should get accustomed to are:
- The overall process of compilation
- why clocks are special
- how to prepare testbenches/simulations
- how to use the built-in logic analyzers (SignalTap on Altera chips)
- when and how to invoke specialized hardware (i.e. "megafunctions" on Altera)

Most beginner books don't spend even a moment introducing these concepts, which is why a proper course-like textbook is useful. Unfortunately, most are written for Xilinx FPGAs... and while the skills are transferrable, the boards they suggest to use are in the $300 range... plus the book itself.

Since you (probably) already have the DE10-Nano, you should start by looking at the documents supplied by the maker, such as "My First FPGA" and the "DE10-Nano User Manual" here:
https://www.terasic.com.tw/cgi-bin/page ... 6&PartNo=4

And just remember that we use version 17.0.x of Quartus for MiSTer cores, so get that version when you download Quartus.
Awesome, thanks for confirming. I will go ahead then.

Also thank you very much for your additional points. Very useful indeed!

Yes I have got the DE10-Nano and a free copy of Quartus as well. Well, time to study! :mrgreen:

Thanks again!
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Learning path for FPGA

Unread post by jca »

User avatar
Alkadian
Top Contributor
Posts: 721
Joined: Thu May 28, 2020 9:55 am
Has thanked: 289 times
Been thanked: 116 times

Re: Learning path for FPGA

Unread post by Alkadian »

jca wrote: Sun Mar 21, 2021 8:00 pm Interesting Lecture:
https://opencores.org/usercontent/doc/1262707254
Thanks for that! That looks a good source indeed!
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Learning path for FPGA

Unread post by jca »

I am a semi-noob in regard to FPGA and being able to compile existing cores is a good start.
But I have a question: this weekend I was looking at the Vectrex core and compiled it, it works but its size is different from the official one although I used the latest release and used Quartus 17.0.2. Is this normal or should I get the exact same size?
Official one: 3,708,364.
Mine: 3,722,624.
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

I wouldn't worry about the exact sizes.
There are a number of factors, including the fact that you are almost certainly using the Lite version whereas the official release usually comes from the Standard version of the tool.

As long as:
- you are using the official sources
- the compile is successful and
- timing issues aren't pointed out during compilation
...you should get the same results as the official core
Lightwave
Posts: 231
Joined: Sun May 24, 2020 10:06 pm
Has thanked: 110 times
Been thanked: 68 times

Re: Learning path for FPGA

Unread post by Lightwave »

dshadoff wrote: Sun Mar 21, 2021 5:08 pm Most beginner books don't spend even a moment introducing these concepts, which is why a proper course-like textbook is useful. Unfortunately, most are written for Xilinx FPGAs... and while the skills are transferrable, the boards they suggest to use are in the $300 range... plus the book itself.
The strange thing is, we keep hearing that the DE-10 is targeted towards education (and is partially subsidized for that purpose), therefore you would think there would be a wealth of learning materials available for it if this is the case.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Learning path for FPGA

Unread post by jca »

dshadoff wrote: Mon Mar 22, 2021 9:12 pm I wouldn't worry about the exact sizes.
There are a number of factors, including the fact that you are almost certainly using the Lite version whereas the official release usually comes from the Standard version of the tool.

As long as:
- you are using the official sources
- the compile is successful and
- timing issues aren't pointed out during compilation
...you should get the same results as the official core
Thanks.
Previously I compiled some cores which worked but never paid attention to the size.
This time I wanted to be more meticulous and noticed the difference. The core seems to work properly so I was not really worried, just curious.
And yes I am using the Lite version.
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

Lightwave wrote: Mon Mar 22, 2021 9:23 pm
dshadoff wrote: Sun Mar 21, 2021 5:08 pm Most beginner books don't spend even a moment introducing these concepts, which is why a proper course-like textbook is useful. Unfortunately, most are written for Xilinx FPGAs... and while the skills are transferrable, the boards they suggest to use are in the $300 range... plus the book itself.
The strange thing is, we keep hearing that the DE-10 is targeted towards education (and is partially subsidized for that purpose), therefore you would think there would be a wealth of learning materials available for it if this is the case.
There is hardly a wealth of materials for any FPGA in terms of textbooks. Each vendor creates some initial startup material for people though. And because of the nature and complexity of these devices, they are expected to be used in a University setting, where many professors create their own materials.

And of course, they aren't really mainstream yet. It looks like that day will come though.

In the meantime, one can always read datasheets and application notes from the vendors - but those often assume that you are already familiar with concepts.
bellwood420
Core Developer
Posts: 48
Joined: Fri Dec 11, 2020 2:39 pm
Has thanked: 3 times
Been thanked: 32 times

Re: Learning path for FPGA

Unread post by bellwood420 »

jca wrote: Mon Mar 22, 2021 9:31 pm Previously I compiled some cores which worked but never paid attention to the size.
This time I wanted to be more meticulous and noticed the difference. The core seems to work properly so I was not really worried, just curious.
And yes I am using the Lite version.
I'm curious, too.
As @dshadoff saying, there will be no problem in functionality as long as we don't get any timing issues, though.

In my environment(version 17.0.2.602 Lite edition), Quartus outputs rbf of 3,708,364 bytes.
The size are the same as officially released one but its content is not exactly the same.
I can understand this difference may be due to different edition(Lite/Standard).
But why isn't mine the same as @jca's?

Recently, I made a little fix on Arcade-MoonPatrol and provided the rbf on this forum.
At the same time, someone built a rbf including my fix and provided it on discord.
Two rbf files were exactly the same.

I'm assuming that the same sources, same qsf, same version, same edition will generate the same binary.
Am I wrong?

-----
EDIT:

The result shown above were done on Windows.
I tried building on Ubuntu with Quartus version 17.0.2.602 Lite edition.
I got rbf in different size(3,709,408 bytes) and content.

-----
EDIT:

I noticed that auto generated string(BUILD_DATE in build_id.v) is included in rtl source.
This can change fitter initial routing and make binary different.

I got different rbf by tweaking system date.
It must be the main reason ;) So, rbf can change every day.

In other words, it can be said that we get the same rbf on the same day with the same sources, same OS, same Quartus version, same Quartus edition.
dshadoff
Core Developer
Posts: 534
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 19 times
Been thanked: 141 times

Re: Learning path for FPGA

Unread post by dshadoff »

There is an element of randomness required during the fitting operation, which could provide varied results.
You may also find that certain cores have slightly different timings for the same code, same computer, same Quartus, but two different executions (this would certainly be due to different arrangements of the elements, which would end up with different binary outputs).

I suggest not to get hung up on it.
bellwood420
Core Developer
Posts: 48
Joined: Fri Dec 11, 2020 2:39 pm
Has thanked: 3 times
Been thanked: 32 times

Re: Learning path for FPGA

Unread post by bellwood420 »

dshadoff wrote: Tue Mar 23, 2021 4:47 am There is an element of randomness required during the fitting operation, which could provide varied results.
Of course the fitting operation requires randomness, but I don't think it's completely random. It is pseudo random.
If we have exactly the same sources, the same Quartus, the same settings, and the same seed value, we should get the same result, I think.
As I added to my earlier post, build date is embedded in source, so the source changes from day to day.
As a result, the behavior of fitter will change even if the sources in /rtl /sys directory and emu module have not been modified.

EDIT:
I confirmed that I got the same binary as official release 20210303 with the same BUILD_DATE string("210303").
So edition does not matter at least.
I understand it is meaningless to pursue binary sameness, though :)
robinsonb5
Posts: 129
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 57 times

Re: Learning path for FPGA

Unread post by robinsonb5 »

bellwood420 wrote: Tue Mar 23, 2021 5:17 amOf course the fitting operation requires randomness, but I don't think it's completely random. It is pseudo random.
It is indeed pseudo-random - and you can even tweak the seed if you wish!
(Assignments -> Settings -> Compiler Settings -> Advanced Settings (Fitter)... -> Initial Placement Seed.)
If you have a codebase which misses timing closure by a whisker, or fails to fit by a whisker, it can be useful in a last-resort kind of way to tweak this seed and re-roll the dice. As you've already noticed, though, the tiniest, most trivial change in the codebase will re-roll them, too - I have a hunch that the actual seed is some kind of hash of the Synthesis results, combined with the user-specified seed.
User avatar
MISTerMark
Posts: 13
Joined: Thu Sep 17, 2020 3:28 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Learning path for FPGA

Unread post by MISTerMark »

Not sure if its any good but I've seen Nandland mentioned a few times on reddit when beginners are asking to get started.

https://www.nandland.com/
hking0036
Posts: 7
Joined: Sat Apr 08, 2023 7:40 pm
Has thanked: 4 times
Been thanked: 2 times

Re: Learning path for FPGA

Unread post by hking0036 »

Thanks all for this info! I am a software eng by trade, but I half got the MiSTer as a learning tool and half as an emulator box...

For those who are also just getting started, I found a series of more "MiSTer oriented" videos in the form of someone developing a core from scratch in a number of videos: https://www.youtube.com/watch?v=qxgM9NPrhqw

I don't want to put the cart before the horse, but I do want to get an okay grip on the fundamentals and then start looking at the framework. Is there documentation for the MiSTer framework living out there someplace that I can turn to as well?

jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Learning path for FPGA

Unread post by jca »

Same here: software by profession, passionate with electronics (digital and RF). I never dared to look into FPGA until I found the site of Grant Searles and his multicomp project on a tiny FPGA board ($20-$30). After playing with it I realized that FPGA was not as hard as I thought but still not that easy. I looked for a developer board, had hard time deciding. When I found video on this MISTer project I decided to go with it: if I don't succeed learning FPGA I can put to good use.
In the end I decided that it was not such a good idea to learn as you not only have to learn HDL but also communication with the ARM. Result: it became a MISTer only device (no regrets) and I got myself a DE1, no longer available but I got a good deal on ebay. More than enough to learn: SRAM, SDRAM, FLASH, SD card, sound chip, switches and buttons, LEDs, 7-seg LED display, VGA, PS/2, Serial and still 2 40-pin connectors with a bunch of GPIO pins.
As for the framework: may be one day but at the moment I have chicken feet.

aileron
Posts: 2
Joined: Mon Jul 04, 2022 9:03 pm
Been thanked: 2 times

Re: Learning path for FPGA

Unread post by aileron »

I'm using an Upduino v3.1 board for 30 bucks and following along with the Digikey videos which uses an IceStick.

Upduino board: https://www.tindie.com/products/tinyvis ... pga-board/
DigiKey Video Series: https://www.youtube.com/playlist?list=P ... NmQ_9CIKhb

The Upduino uses an opens source tool chain (Apio) and I'm on linux so its pretty simple to get going.

BUT and this is important- You have to breadboard, your own LEDS, buttons, 7 Segment Displays, etc. Basically a bit of Electronics background and Digital Logic. Like ohms law, how not to fry your LEDs, or your Board, etc.

The problem I've had so far is you have to learn how to use the internal 48Mhz clock. Otherwise you'll want to solder the two pins to allow the external 12 Mhz OSC to be used. Outside of that, SO FAR its all transferable to any Lattice iCE40 tutorials which Digikeys video series using the IceStick is one. Nandlands website mentioned above sells a board there and its also an iCE40 chipset so the tutorials should work with the Upduino. I'm gonna give that a try soon.

Also to get my feet wet with Verilog I used this website: https://www.asic-world.com/verilog/veritut.html

But Nandlands website again has an intro to Verilog. https://nandland.com/learn-verilog/

You really do have to wrap your head around the language which even though the Digi-key vids are great its going so fast I was missing stuff and reading helped.

The Upduino comes with roughly 5k LUTs so (if what I've heard is true) you could do a 6502 chip in it with tons of room to spare. So I'm thinking after I go through Digikeys videos and Nandland tutorials. I'm gonna try to do Mister Retro Wolf's video series also mentioned above on the Upduino and see if its possible. Probably more pain than its worth... but ya never know.

Well as Long as I don't get distracted. Its a lot to take in. But very interesting.

Post Reply