Author Topic: Learning how to deal with FPGAs  (Read 2272 times)

0 Members and 1 Guest are viewing this topic.

Offline prophossTopic starter

  • Contributor
  • Posts: 46
  • Country: us
Learning how to deal with FPGAs
« on: June 29, 2020, 01:51:47 am »
I am an older computer engineering student, and have a Chinese knock off FPGA dev board with a cyclone 4, some buttons, dial switch, seven seg, and some LEDs. The main problem I am having is learning how to run a program on the board its self. It does work, by that I mean the LEDs blink and the buttons seem to work, etc.... I have lit up the seven seg and used the dial switch. The thing is there is no real tutorial videos to follow like you might find for c++ programming or the like. I did find nanland which is very good but since he sells his own fpga dev board it doesn't translate exactly.

The question is would it be worth buying a cheap, but good FPGA like a tinyFPGA bx2 or ax because it is known and something that might have better documentation and might be a bit easier as I learn? 
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2812
  • Country: nz
Re: Learning how to deal with FPGAs
« Reply #1 on: June 29, 2020, 05:37:08 am »
I am an older computer engineering student, and have a Chinese knock off FPGA dev board with a cyclone 4, some buttons, dial switch, seven seg, and some LEDs. The main problem I am having is learning how to run a program on the board its self. It does work, by that I mean the LEDs blink and the buttons seem to work, etc.... I have lit up the seven seg and used the dial switch. The thing is there is no real tutorial videos to follow like you might find for c++ programming or the like. I did find nanland which is very good but since he sells his own fpga dev board it doesn't translate exactly.

The question is would it be worth buying a cheap, but good FPGA like a tinyFPGA bx2 or ax because it is known and something that might have better documentation and might be a bit easier as I learn?

If you have a constraints file, can build a HDL design, and get that to the FPGA then you are 90% of the way to the the point where a different development board doesn't really matter (unless of course it has the physical interfaces you want to use, and the other one doesn't).

Have a read through a well documented board's reference manual, and apart from pin names and exact clock speeds (e.g. is it a 50MHz or 100MHz oscillator?) most of the information will still apply.

I feel that a lot of the learning can only be done by making projects, hitting problems, and then asking questions or looking for solutions. Without the context of "how does this apply to my problem" to frame what I am reading most HDL becomes mostly meaningless.

Sometimes I set up problems so I can knock them down. For example, making a counter that increments when a switch is pushed, will show you switch bounce, forcing me to learn debouncing.

A more complex idea might be to switch between an external clock and a "single step" push-button to advance the clock. It sounds simple but gets quite complex quite quickly, requiring you to look really deeply into the FPGA's clocking resources such as clock muxs and their limitations,


Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 
The following users thanked this post: soFPG

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9932
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #2 on: June 29, 2020, 04:27:04 pm »
I wonder about video tutorials of highly technical content.  I did the two for-pay video programs at VHDLwhiz.com and it is a little cumbersome starting and stopping the video while I type the matching code.  I do have a foot pedal for this and it works well but I still don't find the videos all that easy to work with.  The commentary is the good news, the code flashing by is the bad news.  Yes, the files are available for download but that's cheating.  I learn more if I have to slow down to type the code.

Looking at NandLand, there is a lot of useful, albeit written, content.  That means I can shove the web page to a second monitor and do the work on my primary screen.  I can also copy and paste code from a written tutorial.  There is quite a bit of video content as well.

NandLand spends a lot of time on simulation so most of the tutorials don't actually require a board.  I might buy the board just to support the cause.  Patreon would be acceptable but NandLand wants to use a periodic contribution model and I have little interest in a recurring monthly fee.  I'll have to think about it...

There are a lot of good sites out there, I wouldn't get hung up on video versus written.

 

Offline prophossTopic starter

  • Contributor
  • Posts: 46
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #3 on: June 29, 2020, 05:45:36 pm »
@hamster: I had thought much the same thing but being so new I at least wanted to ask. I will see about reading through the doc for a "good: board, but I tend to get board envy pretty easy ;) and will just wind up wanting it! 

@rstofer: I have a much easier time dealing with videos than reading but that is just me. So far as nanland goes I have read the site stuff and watched several videos. He seems to be the only one who does a step by step progressive tutorial for FPGAs. I have used nanland code to program my board using Quartis 2, but have used multi-sim as well because that helps me see that the code does actually do what it is supposed to do. My dev-board has different pins but I was able to find the pin layout online and can set it up. Really it is the programming of all the different things like a debounce that I need to learn.

Thanks to the both of you for your input!
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9932
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #4 on: June 29, 2020, 07:27:28 pm »
As you know, digital systems are made up of blocks which we call components.  In general, there are very few to worry about:  MUX, decoder, counter, register and the finite state machine.  Plus a few others I forgot about.

Once you learn how to code each of the component blocks, you just chain them together to build a system.  A MUX is a MUX regardless of how it is used, a counter just counts (usually on command and possibly for a specific count) and so on.

Look at the block diagram of the LC-3 (or LC-3b) RISC processor on page 7.  You can just hear the components screaming out "code me!".  We could create a 'generic' MUX and fill in a lot of blocks.  A couple of adders and a register file complete the diagram.

http://users.ece.utexas.edu/~patt/05f.360N/handouts/360n.appC.pdf

It will occur to you that the Reg File is just dual port BlockRAM but there are two copies.  When the file is written, both copies are updated but they are read individually.  This allows operations like reg7=reg1+reg2 in a single cycle add.  Read from the A side and write to the B side - simple as that!

I found this a fun project.  There is a C compiler using LCC and an Assembler available:

http://users.ece.utexas.edu/~ryerraballi/ConLC3.html

So, basically, a complete machine ready for C code.


Look at the Finite State Machine transition diagram on page 5 - it is yelling "code me!".

This project from Patt and Patel is used at a LOT of universities and there is stuff all over the Internet.  The 2003 edition talks about the word oriented LC-3.  I assume the 2019 edition talks about the byte oriented LC-3b version but I don't know that.  When you search the Internet, be aware of the two different projects.

https://www.amazon.com/s?k=patt+and+patel&ref=nb_sb_noss_1

« Last Edit: June 29, 2020, 07:35:12 pm by rstofer »
 

Offline filssavi

  • Frequent Contributor
  • **
  • Posts: 433
Re: Learning how to deal with FPGAs
« Reply #5 on: June 29, 2020, 07:46:21 pm »
Unfortunately I Have not found a single decent FPGA resource on the web, they are either flat out bad, or way too low level, only talking about basic gates and not much more.
Unfortunately there is basically nothing about higher level architectural design, not to mention modern software development practices ( Like source controls, make files, Continuous integration etc).

My advice if you are serious is to take some university course (ether undergrad or master, depending on how your level) on digital design, unfortunately a lot of stuff is not directly applicable, as they can only be used on ASIC, however it will give you a good idea of what timing is and what problems it can give you, pipelining, etc.

If I can give you just a single advice is, take a look at the code you find online and do the exact opposite, don’t shove everything into a single giant “god module” that contains your entire design, use sensible descriptive variable names, comment often in critical area (not to often either though as 3 lines of comment for each line of comment is just annoying).


 

Offline prophossTopic starter

  • Contributor
  • Posts: 46
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #6 on: June 29, 2020, 10:01:21 pm »
I looked at the LC-3B, WOW! There is a lot there to look at. Wish I knew what all that stood for. I say that but I do get the basic idea of it.
I won't be studying MCU architecture for a bit yet. I just got through with ECET220 and c++ basics this past semester. I do however see the "Code ME!" that you are talking about! I have created a very basic mux that does work. I have not messed with memory yet.  I guess that is what I need to be aiming for though. I had figured that it would be like creating several different instances of various blocks of HDL and creating something like that LC-3B. I am tempted to spend some time doing just that even though I know it is way beyond me. I need that kind of project  and time to do it. Having a job, a family, and going school full time doesn't leave much time for projects. Still I need a goal and that might be mine!
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9932
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #7 on: June 30, 2020, 12:55:30 am »
Working, supporting a family and going to school is difficult.  BTDT
You are ahead of the game for your digital courses.

One day you will wake up and it will all make sense.

Small steps...

 

Offline prophossTopic starter

  • Contributor
  • Posts: 46
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #8 on: June 30, 2020, 01:03:30 am »
It was my intro to digital class that piqued my interest! I just had to try it and my professor and me looked up dev-boards on e-bay and he found a cheap one with lots of peripherals and I bought it when I could. Man is this so much fun! ;D 
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2812
  • Country: nz
Re: Learning how to deal with FPGAs
« Reply #9 on: June 30, 2020, 10:04:03 am »
Hi Prophoss,

Have a look at this thread:

   https://www.eevblog.com/forum/fpga/2nd-sigma-delta-digital-to-analogue-converter-(sd-dac)-in-verilog

My VHDL I posted isn't that interesting as far as code goes (actually it is pretty crass), but the results are interesting. It's not the language, it's the structures and techniques you describe in it that does.

That's the sort of thing about FPGAs and me - I've never bothered to learn about implementing 2nd Order Sigma Delta DACs. I knew they were a thing but never understood them. However for some reason that post tickled my interest, and wanted to try it. Now that I have, I'm glad I spent the time.

Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9932
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #10 on: June 30, 2020, 03:04:12 pm »
Link seems broken.  I can find the project from the top of the forum.  Interesting work!
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1763
  • Country: us
Re: Learning how to deal with FPGAs
« Reply #11 on: July 01, 2020, 10:09:00 pm »
The main problem I am having is learning how to run a program on the board its self.

The first thing you need to wrap your head around when working with FPGAs is that you don't "run programs" on them. They're not like microcontrollers or microprocessors in the sense that they don't execute a series of instructions sequentially--everything happens simultaneously in parallel. Working with FPGAs is more akin to designing hardware than it is to programming.
"That's not even wrong" -- Wolfgang Pauli
 

Offline tolpe

  • Newbie
  • Posts: 6
  • Country: se
Re: Learning how to deal with FPGAs
« Reply #12 on: July 13, 2020, 01:21:08 pm »
I have played a bit with this project:

https://hackaday.io/project/171216-jupyosys

They have a few examples that create flipflops and multiplexers using yosys from the python shell. There are kind of interactive exercises where you can modify the code and experience what yosys is turning it into, like a schematic view of gates. Hopefully they will add ICE40 support.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf