Author Topic: Getting started with FPGA from scratch  (Read 2737 times)

0 Members and 1 Guest are viewing this topic.

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Getting started with FPGA from scratch
« on: October 27, 2022, 04:44:12 am »
If you can bear with me please give me some really starter instructions on how to approach the FPGA system development/programming.
Honestly saying for me FPGA at the moment is just a fancy name with not much information behind it.
I found a budget board based on Spartan 6. Here it is: https://aliexpress.com/item/32890953742.html

I'll ask some basic questions:

- Since that's a bare board what periferals I can/need_to connect to it to make it minimally functional? Please consider this question as if I was asking about a microcontroller. I hope I can treat the FPGA as a micrcontroller in the first approximation (purists please be patient). Oh, mind you I perfectly understand this might me a completely wrong approach but I would rather start from the analogy since I can hardly understand the nature of the 'Field Programmable Gate Array' at the moment. I'll learn along the way.

- Apart from the board itself which apparently has nothing on it to confirm its functionality what minimum additional hardware do I need? A JTAG serial SPI is a must to upload the code, I know. I also need to connect at least some LEDs to the board to start with.

- As far as I understand the Software Development suite that is meant for XILINX FPGAs including Spartan-6 is Vivado. Do I need any specific knowledge of what version to download for this development board?

Anyway, please just help me out. The more information you can provide the better. Please remember you all started some day from scratch perhaps in the University environment under good supervision. I have no one to help me with this apart from you my friends on this forum.

I downloaded a dozen of books on FPGA but books will help me later and now I just need to get it going.
(I've watched a bunch of videos about FPGA on YT but they don't explain much apart from the general theoretic definitions of what FPGAs are on the most fundamental level.)

If you ask me about what do I need it for or otherwise what I want to do with it you better think of it the other way round: You've got an FPGA and you try to find out what you can do with it.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: Getting started with FPGA from scratch
« Reply #1 on: October 27, 2022, 05:18:20 am »
Hi, the board you found is a nice one to play with, but indeed needs things connected to it do do something meaningful, but that just depends on what you want it to do for you.

It has some LED's and buttons on the board you can do some first tests with. You might get some example programmings with the board on how to use these.

For as far as I know you need the older development tools (ISE) for the spartan-6 series. Vivado is for 7 series and up.

In some way a FPGA is far more then a microcontroller, but also less. A FPGA is a blank slate of a series of gates that can be connected to each other in many ways. It can become a microcontroller to some extend. What is less then a microcontroller is it might not have build in bits like an analog to digital converter. (There are FPGA's that do have them)

What this means is that you create hardware when programming a FPGA.

There are plenty of modules available for connecting to a FPGA, that include ADC's, DAC's, cameras, displays, etc.

Take a look at my repository here: https://github.com/pecostm32/Lichee_Nano
I'm using a different FPGA board there combined with a Lichee Nano F1C100s board and a DAC module, but it can give you an idea of the possibilities.

Edit: Link to the ISE suite: https://www.xilinx.com/products/design-tools/ise-design-suite.html
« Last Edit: October 27, 2022, 05:30:29 am by pcprogrammer »
 
The following users thanked this post: VSV_electron

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6710
  • Country: ro
Re: Getting started with FPGA from scratch
« Reply #2 on: October 27, 2022, 07:58:51 am »
I hope I can treat the FPGA as a micrcontroller

No you can not.  That's the worst, most damaging start.  Microcontrollers and FPGA are unrelated.  And their "programming language" does not describe a program, HDL code describes a schematic.  That's why the language is called HDL (Hardware Description Language).  Notice the Hardware Description words in the name, that means schematic, not program.

The Verilog or VHDL "code" is a text that describes a schematic with logic gates and flip-flops and such, it does not describe a programming algorithm.  The instruction lines in HDL are not executed sequential, one after another, like in the most other programming languages.

Try this place as a starting point:
https://www.fpga4fun.com/FPGAinfo1.html
and again, leave microcontrollers out of this, HDL is about digital schematics, not about programming.



AFAIK Xilinx Vivado only supports series 7 and later of their FPGAs.
For Spartan 6 you'll need to download and install Xilinx ISE 14.7

The board manufacturer often might recommend a specific version/license + their tutorials.  Use those at first.  IIRC the Xilinx ISE WebPACK is free.  Find the documentation corresponding to the Spartan-6 devboard you have, and follow the install instructions from there.  But read first from the intro link above, or else the Xilinx ISE toolchain won't make any sense.
« Last Edit: October 27, 2022, 08:30:24 am by RoGeorge »
 
The following users thanked this post: VSV_electron

Offline Ice-Tea

  • Super Contributor
  • ***
  • Posts: 3163
  • Country: be
    • Freelance Hardware Engineer
Re: Getting started with FPGA from scratch
« Reply #3 on: October 27, 2022, 08:08:52 am »
I would suggest getting another dev board like per example

https://nl.farnell.com/terasic-technologies/p0082/e22f17c6n-de0-nano-dev-kit/dp/2076463

It has a lot more features, all well documented and debugged. There are code examples. Like that you know you are starting from a working system and won't be spending time figuring out whether you're seeing a HW ghost or have a code issue.

Oh, and don't approach it like a uC. Not even to get started.
 

Offline dietert1

  • Super Contributor
  • ***
  • Posts: 2375
  • Country: br
    • CADT Homepage
Re: Getting started with FPGA from scratch
« Reply #4 on: October 27, 2022, 08:28:53 am »
As far as i remember i got a used Digilent board from ebay to learn FPGA, Spartan II at the time. It had some LEDs, some buttons and even a small LCD display. If you can afford a new one, even better.
You need a reasonable workstation, too. Modern EDA software is huge. Although one needs less than 1 % of it at the beginning, as far as i remember there was no "beginners" setup.

Regards, Dieter
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #5 on: October 27, 2022, 09:37:44 am »
Be aware that ISE 14.7 doesn't work on Win 10 (and presumably Win 11) due to a SmartHeap issue.  Xilinx has an official workaround that incorporates a VM and some pushups.  The other way is described in this page as 'ISE 14.7 64-bit - Turning off SmartHeap:'

https://support.xilinx.com/s/article/62380?language=en_US

I have been using 14.7 on Win 10 for a long time so I know it works.  It's even better if you have a Win 7 machine and don't have to solve this problem.

Vivado is a far superior toolchain but it only works on Artix 7 devices and up.  I just don't know about any inexpensive boards.

Although I am a Xilinx fan, the GoBoard (based on Lattice FPGA) is attractively priced with lots of tutorials:

https://nandland.com/the-go-board/

 
The following users thanked this post: VSV_electron

Offline CaptDon

  • Super Contributor
  • ***
  • Posts: 1997
  • Country: is
Re: Getting started with FPGA from scratch
« Reply #6 on: October 27, 2022, 02:57:58 pm »
You will learn to hate Xilinx in a hurry. Their fabric is o.k. but their software tools eat up tons of space and are quirky and behave like bandaids on already poor coding. Many broken links on their websites, just the kind of things to ruin your productive day. Try posting in the FPGA forum by the way.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 
The following users thanked this post: VSV_electron

Offline funhobby

  • Newbie
  • Posts: 4
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #7 on: October 27, 2022, 04:28:53 pm »
I am really a beginner, but let me share what I found useful in case some of it will be helpful.

I started by building 6502 based computer (by stumbling upon Ben Eater youtube videos: )
Then I wanted to add a VGA based video card and a keyboard. While this could be build with basic logic chips, it seemed too repetitive and limiting (you can only fit so much on breadboards and breadboards have their own issues). So I figured that I should do it with FPGA.

I got Cmod A7 and started watching videos and making small implementations. https://digilent.com/reference/programmable-logic/cmod-a7/reference-manual?redirect=1

It only has few LEDs on the board, but I can add external buttons, LEDs and adapters for VGA, PS2, HDMI and so on.

I recommend watching a series of videos starting with this one:
Digi-Key has a nice series as well, starting with:

P.S. Yeah I already dislike some things about Xilinx. :-) Download alone is ridiculously slow.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #8 on: October 27, 2022, 05:35:57 pm »
So, how many times are you going to download Vivado?  What difference does it make how long it takes, let it run overnight.  Also, Gb Ethernet helps.  For ISE, Xilinx used to provide a DVD, I have forgotten whether there was a nominal charge.

For Lattice you have 3 separate tools to use:  ModelSim (simulation), iCEcube2 (editor/compiler) and Diamond (programmer), with Vivado, everything is integrated.  And let's not overlook the Vivado Integrated Logic Analyzer that lets you debug your project in real-time on the actual hardware.

I'll concede that it took a while to transition from ISE to Vivado constraints files.  It's best if you can find a published file that matches the manufacturer's board.  Digilent supplies them and they have some tutorials as well.

I had been using ISE for about 10 years before transitioning to Vivado.  I wasn't a happy camper.  Over the last few years, I have made peace with Vivado.  Somehow, I'm still fond of the ISE user interface...

If you plan to use VHDL and Lattice, vhdlWhiz.com might be a great resource.  I did a couple of the 'for pay' projects just for giggles.  Actually, I wanted to learn more about simulation.  Early versions of ISE didn't include a free simulator so I never learned that aspect of FPGA development.

https://vhdlwhiz.com/

 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #9 on: October 27, 2022, 05:40:17 pm »
The best book I found for learning FPGA development is also free, it's called "Free Range VHDL"

Definitely do not treat the FPGA like a microcontroller. Actually I think existing programming experience hinders rather than helps. HDL *looks* like programming but it is actually a language to describe a schematic, it is not a program.
 
The following users thanked this post: VSV_electron

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: Getting started with FPGA from scratch
« Reply #10 on: October 27, 2022, 06:10:52 pm »
The construct of verilog is much closer to C, but you do have to alter your mind set from sequential programming to parallel handling of signals.

It is thinking in terms of logic and signals. For instance to display something on a monitor you have to build your own "video card" by setting up memory, address counters and what more is needed to do this.

There is another thread started in the FPGA section where I refer to a lot of sites that you can visit to learn more about this all.

https://www.eevblog.com/forum/fpga/first-fpga-system/msg4487518/#msg4487518

There are some new comers to the FPGA market like Gowin, Anlogic and others like Lattice, Altera/Intel, Xilinx/AMD and probably some more to choose from, and lots of boards to be found on Aliexpres that can be used to play with. Unfortunately the prices have gone up the last couple of years, and availability is poor.

The Spartan-6 is an oldie but still quite a nice one to do things with. Another one is the Cyclone IV range from Altera/Intel. And then there are also FPGA's with an embedded processor. Gowin has some with an ARM cortex in them. Xilinx/AMD has the Zynq line, Altera/Intel the Cyclone V range.

In the end it all depends on what it is you plan to do with FPGA's as to which one to choose.

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #11 on: October 27, 2022, 09:26:41 pm »
You may find projects at https://opencores.org useful.  They vary in quality but they do provide some insight.

I particularly like the T80 core.  It is a Z80 CPU that I have used to build a fast CP/M machine and, more importantly, a PacMan game.  You need to deal with the interrupt input.  Left floating, the CPU is constantly interrupting itself.  There's a reason I know this.

https://opencores.org/projects/t80

I remember the days of CP/M on a 2 MHz 8080 (Altair 8800) and then the fantastic upgrade to a 6 MHz Z80 (CompuPro).  At 12.5 MHz on a Spartan 2 FPGA board, CP/M is fairly responsive.  Of course, the current production 50 MHz Ez80 chip is a LOT faster.  With care and the proper FPGA, the T80 core can run up to 100 MHz.  That's pretty quick.
 
The following users thanked this post: VSV_electron

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #12 on: October 27, 2022, 10:06:32 pm »
I particularly like the T80 core.  It is a Z80 CPU that I have used to build a fast CP/M machine and, more importantly, a PacMan game.  You need to deal with the interrupt input.  Left floating, the CPU is constantly interrupting itself.  There's a reason I know this.

That seems like a strange choice, it would have been trivial to write the core such that the default state of the interrupt line is inactive. I always assign values to unused inputs when I instantiate though. The T80 core is nice, and the T65 as well which is a 6502 core I've used in a lot of projects.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #13 on: October 28, 2022, 01:53:18 pm »
I particularly like the T80 core.  It is a Z80 CPU that I have used to build a fast CP/M machine and, more importantly, a PacMan game.  You need to deal with the interrupt input.  Left floating, the CPU is constantly interrupting itself.  There's a reason I know this.

That seems like a strange choice, it would have been trivial to write the core such that the default state of the interrupt line is inactive. I always assign values to unused inputs when I instantiate though. The T80 core is nice, and the T65 as well which is a 6502 core I've used in a lot of projects.

I don't think there was a choice of level on the Non-Maskable Interrupt (compatibility) but almost certainly a PULLUP or PULLDOWN attribute could have been added.  I just looked at the .ucf file that came with the project and no such attributes are declared for any signal.  The file date is Dec 2004 so that was around the time I first started with FPGAs - I wasn't experienced enough to know the intricacies of constraints.  I'm pretty sure the transition looked like:  First, blink an LED.  Second, build a CP/M machine.  Third, build an entire minicomputer with all of the peripherals that would run all of the factory software.
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: bt
Re: Getting started with FPGA from scratch
« Reply #14 on: October 28, 2022, 02:42:08 pm »
The best way to "start" is to find a moderate proven living design (a repo with all project files required) which is ready to be build in a specific IDE ("a single click approach") and which runs fine on a specific FPGA board. Messing with FPGAs is quite difficult and time consuming. I own about 20 boards from 384 to 150k LUTs (Actel, Lattice, Altera, Xilinx) and when I see something interesting to "try fast" the boards/IDEs always do not fit  :D .. (Murphy law perhaps)..

Therefore find yourself a well working proven "living" project/design, with some nice people around the project who can, and are willing to help you (important!!!), and buy the exact board and programmer they recommend. Then slowly start with your changes, improvements in the existing working design. Porting an existing design from a board_A to a board_B is pretty difficult exercise for a beginner, imho.

PS: messing with "microprocessors" inside an FPGA leads always to a heavy and complex development "environment", consisting of dozens of properly installed languages, packages, scripts and tools, usually under linux and with open source initiatives - except hdl (verilog/VHDL) you have to learn how to create that "dev environment" for building up the final FPGA bitstream, and that is a complex exercise too (unless you get a detailed updated precise step by step guide how to do it)..
« Last Edit: October 28, 2022, 03:46:05 pm by imo »
Readers discretion is advised..
 
The following users thanked this post: VSV_electron

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #15 on: October 28, 2022, 03:48:46 pm »
The best way to "start" is to find a moderate proven living design (a repo with all project files required) which is ready to be build in a specific IDE ("a single click approach") and which runs fine on a specific FPGA board. Messing with FPGAs is quite difficult and time consuming. I own about 20 boards from 384 to 150k LUTs (Actel, Lattice, Altera, Xilinx) and when I see something interesting to "try fast" the boards/IDEs always do not fit  :D .. (Murphy law perhaps)..

Which probably makes the case for Nandland.com and the GO board:

https://nandland.com/the-go-board/
https://nandland.com/lots-more-vhdl-and-verilog-modules/

The FPGA 101 modules seem interesting.

 

Offline dietert1

  • Super Contributor
  • ***
  • Posts: 2375
  • Country: br
    • CADT Homepage
Re: Getting started with FPGA from scratch
« Reply #16 on: October 28, 2022, 05:48:13 pm »
Just found this eevblog video:


Not everybody is born to become a FPGA designer! Many tried but finally went back to do what can be done with MCUs.

Regards, Dieter
 
The following users thanked this post: VSV_electron

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #17 on: October 28, 2022, 07:49:48 pm »

Not everybody is born to become a FPGA designer! Many tried but finally went back to do what can be done with MCUs.

Regards, Dieter

At the hobby level, I think this is true.  There has to be a reason for migrating to FPGAs and it better be compelling because you ultimately have to get down to the bare flop level of programming.  And there are going to be thousands of flops.  Sure, we can declare a 32 bit register with a line of code but it still takes 32 flops.

My only interest in FPGAs revolves around CPUs.  Trivial CPUs or complete systems but still CPUs.  I started programming FORTRAN on an IBM1130 back in '70 and I wanted one - a fully functional work-alike that would run the 27 pass FORTRAN compiler.  I made a microprogrammed attempt back around '74 but the 2102 static RAM wasn't readily available.  AFAIK the microcode worked but a CPU with no RAM is pretty useless.  I guess I wasn't up to dynamic RAM...

The project sat on the back burner until I retired and had the time to work on it.  It wasn't as bad as it seems,  Once you learn how to structure registers, counters,  MUXes and Finite State Machines the rest is just interconnecting the blocks.  Wire wrap with just a simple sentence.

I spent my undergrad and postgrad efforts on digital design.  Of course I ate this stuff up.  No more Karnaugh maps and no more wire-wrap.  I could have a million gates in a single chip - a virtual dumpster load of logic!  What a playground.

But it was always a hobby.

Here's a project: 

https://people.cs.georgetown.edu/~squier/Teaching/HardwareFundamentals/LC3-trunk/docs/LC3-uArch-PPappendC.pdf

It is nicely documented in books and all over the Internet.  Unlike many other projects, this one doesn't include the HDL, that's up to the builder.  In fact, the authors designed the machine for microcode.  That's a perfectly viable approach even in an FPGA.  It would be kind of fun to do.
 
The following users thanked this post: VSV_electron

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: bt
Re: Getting started with FPGA from scratch
« Reply #18 on: October 28, 2022, 08:14:44 pm »
If you are into mainframes  :D you may try this

https://pdp2011.sytse.net/wordpress/pdp-11/

I tried with it this spring and it works as advertised, it is almost a turn-key solution (a couple of config switches have to be set in the VHDL and it builds straight then), provided you get lucky owning the right board(s). It is a complete PDP-11/XY midrange on the chip, with system disk on an sd-card.

Mine is PDP-11/70 on the DE1 Cyclone-II altera board (the minimum is at least 20k cells and 2MB dram to be happy, but there are examples with smaller fpgas and srams as well). With a larger fpga (like 30-50k) you can enable VGA output and PS2 keyboard and you get a complete PDP-11 system (otherwise you work via an external terminal). As a bonus the 64bit FPU (yes, it is there on the chip) fits luckily in mine fpga as well, all supported with a ready to use BSD2.11 UNIX disk image (with latest patches) prepared by Sytse, the author (active on the PiDP groups). It runs 10MHz cpu clock and 160MHz dram clock, giving aprox 50% more speed than the original.

PS: the other DEC OSes are supported as well..
« Last Edit: October 28, 2022, 08:54:01 pm by imo »
Readers discretion is advised..
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #19 on: October 28, 2022, 08:23:50 pm »
My interest in FPGAs is in recreating vintage hardware. I'm much better with hardware than I am programming and FPGAs are cool. It's like having an enormous breadboard and an infinite pile of free components.
 
The following users thanked this post: VSV_electron

Offline Bud

  • Super Contributor
  • ***
  • Posts: 7096
  • Country: ca
Re: Getting started with FPGA from scratch
« Reply #20 on: October 28, 2022, 08:51:50 pm »
In relation to vintage hardware recreation - I do not have sympaty to FPGA. It does not have the warm and fuzzy feeling to me for some reason, no matter what cool things they produce. Would use low level logic chips any time of day instead.
Facebook-free life and Rigol-free shack.
 
The following users thanked this post: VSV_electron

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #21 on: October 28, 2022, 08:55:36 pm »
In relation to vintage hardware recreation - I do not have sympaty to FPGA. It does not have the warm and fuzzy feeling to me for some reason, no matter what cool things they produce. Would use low level logic chips any time of day instead.

Yeah, well I've got better things to do than hand wire a ~16"x12" arcade PCB with dozens of TTL chips, some of which are hard to come by. With an FPGA I can publish my designs and anybody can play with them. I've recreated a bunch of early games using what was at the time a $13 FPGA board. Without the FPGA I never would have bothered.

https://github.com/james10952001
 
The following users thanked this post: iMo

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: Getting started with FPGA from scratch
« Reply #22 on: October 29, 2022, 01:05:00 am »
Then there is the PiDP11/70 based on a simulation running on a Raspberry Pi.  It runs faster than the original and BSD Unix works well.  It's kind of fun to play with the original C compiler and the PDP11 Macro Assembler.  Networking does what you would expect from BSD Unix.  I have two of the machines...

https://obsolescence.wixsite.com/obsolescence/pidp-11

A few years back I built an FPGA PDP-11 based on a project out of Germany.  The professor said I was the only success story outside of academia.  The project wasn't necessarily ready for prime time but it did work and it was fun!

FPGAs give people an opportunity to play with hardware that no longer exists.  I wonder if I could do a CDC 6400 or an IBM 360/370...  The nice thing about IBM documentation is that it usually includes a "Functional Characteristics" manual that describes literally everything.  Very handy...

http://media.ibm1130.org/E0006.pdf

More at:

http://ibm1130.org/

A lasting relationship for over 50 years!



« Last Edit: October 29, 2022, 01:09:19 pm by rstofer »
 

Offline bidrohini

  • Regular Contributor
  • *
  • Posts: 201
  • Country: bd
Re: Getting started with FPGA from scratch
« Reply #23 on: October 29, 2022, 02:49:08 pm »
You can follow this video if you already have not:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf