Author Topic: FPGA ?  (Read 9702 times)

0 Members and 1 Guest are viewing this topic.

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: FPGA ?
« Reply #25 on: April 12, 2018, 05:33:00 pm »
Personally I find it far more interesting to play with real hardware then to just simulate the HDL. You don't need to spend a lot, one of my favorite beginner FPGA dev boards is very cheap. This is just one of many different sellers that have them:

https://www.ebay.com/itm/ALTERA-FPGA-Cyslonell-EP2C5T144-Minimum-System-Learning-Development-Board/401255830236?

Most FPGAs use an external configuration ROM to load the bitstream, so the life depends on the ROM used. I've never managed to wear one out though.

 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3138
  • Country: ca
Re: FPGA ?
« Reply #26 on: April 12, 2018, 05:44:06 pm »
Normally with flash MCUs they guarantee 40 years, after that the flash might be corrupted.
How does this count for FPGA ?, are they staying good longer or do they also use flash for the programming ?
Can you also reprogram FPGA 100.000 times like a flash MCU ?

No. FPGAs don't have flash at all. They must be configured (programmed) every time they power up. Most boards have flash chips to auto-configure the FPGA, but this is not necessary. While you work on your design, it is much easier to configure it from the PC through JTAG or an MCU. Dev tools can do it for you. Configuration takes few seconds, but that is nothing compare to compile times.

Can i pick any FPGA ?, they all do the same ?

In a sense. There's less diversity in FPGAs than in MCUs, but there are differences. The biggest difference is in dev tools, which you can try before buying FPGAs. Many people use so called IPs n their designs - sort of programs which you can use (e.g. connect to the Ethernet, USB, memory etc.). The manufacturer may want big money for their IPs.

 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4943
  • Country: si
Re: FPGA ?
« Reply #27 on: April 12, 2018, 05:58:14 pm »
FPGAs are pretty similar. They all have the basic functionality of implementing logic but they differ in the extra hardware that surrounds that logic. Like having faster IO pins, better PLLs to generate clocks, internal resources for doing math faster... all the way up to having DDR3 memory controllers and ARM CPUs built in.

But the biggest difference is the manufacturer. If you buy a Altera chip you will ONLY be able to use the software from Altera. There is zero compatibility between vendors, so if you don't like the compiler, design tools, prebuilt modules etc from them then you have no other choice but to go to a different chip. There is no clear best brand here but generally Altera and Xilinx have the better software out there. On the other hand Lattice has the cheapest chips but there software is not that great.

In any case just get a cheap dev board and have at it. But be prepared for a big learning experience, any knowledge of C or other programing languages is completely useless here. These languages might have If statements and loops but they work in a completely different way than they do in all other languages (Even tho they might seam they are the same at first).
 

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: FPGA ?
« Reply #28 on: April 12, 2018, 08:23:22 pm »
A nasty trap here is that Verilog looks kind of, sort of, like C, but is in fact nothing at all like C!

The thing to remember is that FPGA fabric (if we ignore the special function stuff that varies by vendor) consists of only three things, small lookup tables, flipflops and programmable ways to hook these together. Generally there are also block memories and often some sort of ALU blocks, but details differ.

Conditional expressions (that do not involve the clock) turn into logical multiplexers that then turn into suitably programmed LUTs, conditionals that involve clock edges turn into flipflops possibly with clock enables and maybe with a LUT tacked onto the input.

Pure combinatoric logic turns into LUTs (not always in obvious ways), be careful with arithmetic here it can eat a LOT of LUTs and slow everything down, there is a reason for those vendor specific ALU blocks (You usually get anywhere from a dozen or so to a few thousand of these).

Finally the other annoyingly vendor specific thing is clock generation, there are generally PLL like things that can be configured to do useful things.

Now in addition to the HDL of choice there is another elephant in the room, the constraints file(s), these define such things as pin mappings and IO timing requirements and given a complex design can be a total can of worms.

Now the big "Traps for young players":

  • Inputs that are NOT synchronous with the clock (as well as anywhere you need to cross clock domains) suffer a risk of metastability, the cure is easy but you need to realise that you need to apply it. 
  • If there is any path thru combinatoric logic that does not set a signal value before it is used you will infer a latch, this is almost always an error.
  • Clocks are a different class of thing from normal signals, and the tools will bitch bigtime (and fail to achieve timing closure) if you mix the two. It is fine to gate a flipflop using its clock enable input, but it should be clocked from a clock. This also applies to clock pins, you can maybe sort of get things to work using a non clock pin as a clock input, but try not to need to do it.
  • Most FPGA logic clocks on the rising edge of the clock, don't try writing fall edge logic, it can be done, but you will sooner or later end up swearing.
  • FPGA vendors write huge amounts of documentation, and all of it has extensive footnotes, **THE FOOTNOTES MATTER**. Altera, looking at you, turns out a cyclone V will not come out of reset if you don't power VBatt even if not using the key memory.... Oh how we laughed.
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2765
  • Country: us
Re: FPGA ?
« Reply #29 on: April 12, 2018, 08:35:00 pm »
No. FPGAs don't have flash at all. They must be configured (programmed) every time they power up. Most boards have flash chips to auto-configure the FPGA, but this is not necessary. While you work on your design, it is much easier to configure it from the PC through JTAG or an MCU. Dev tools can do it for you. Configuration takes few seconds, but that is nothing compare to compile times.
Well, actually there are SOME that do.  The Xilinx XC3SnnnAN series are identical to the XC3SnnnA except that a flash memory chip is added inside the package.  This is the Spartan 3A series, a bit dated, but handy for this feature.  The flash only adds a few $ to the price.  The FPGA loads from the flash in a fraction of a second.

Jon
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2729
  • Country: ca
Re: FPGA ?
« Reply #30 on: April 13, 2018, 12:00:40 am »
FPGA vendors write huge amounts of documentation, and all of it has extensive footnotes, **THE FOOTNOTES MATTER**. Altera, looking at you, turns out a cyclone V will not come out of reset if you don't power VBatt even if not using the key memory.... Oh how we laughed.
I always look at how things are done on other commercially available devboards (most of them have publicly available schematics) - this helps to avoid these fine print issues.

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4943
  • Country: si
Re: FPGA ?
« Reply #31 on: April 13, 2018, 05:26:50 am »
Well, actually there are SOME that do.  The Xilinx XC3SnnnAN series are identical to the XC3SnnnA except that a flash memory chip is added inside the package.  This is the Spartan 3A series, a bit dated, but handy for this feature.  The flash only adds a few $ to the price.  The FPGA loads from the flash in a fraction of a second.

Jon

Well yes there are exceptions. Lattice has some with built in flash, Altera has there MAX series of CPLDs that are actually just FPGAs with the boot flash stuffed into it, but they can usually still boot from external memory if you tell them to do it. I meant to say that FPGAs don't contain flash inside the actual logic fabric like CPLDs do but is instead a separate block of memory that gets loaded in byte by byte on boot.

Still id recommend just getting a FPGA dev board where all of this is already taken care of.
« Last Edit: April 13, 2018, 05:32:15 am by Berni »
 

Offline JanJansenTopic starter

  • Frequent Contributor
  • **
  • Posts: 380
  • Country: nl
Re: FPGA ?
« Reply #32 on: April 15, 2018, 02:24:40 pm »
I seen Daves movie on youtube now also.



I guess you can copy anyones design with reading the configuration pin sequence.
aliexpress parachute
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: FPGA ?
« Reply #33 on: April 15, 2018, 10:15:46 pm »
I guess you can copy anyones design with reading the configuration pin sequence.

You can get only FPGA configuration bitstream which is far from design. In case one needs copy protection of their FPGA-based device, then there's solution: https://www.maximintegrated.com/en/app-notes/index.mvp/id/4594
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2729
  • Country: ca
Re: FPGA ?
« Reply #34 on: April 15, 2018, 11:39:29 pm »
You can get only FPGA configuration bitstream which is far from design. In case one needs copy protection of their FPGA-based device, then there's solution: https://www.maximintegrated.com/en/app-notes/index.mvp/id/4594
Xilinx FPGAs have built-in support for bitstream encryption which makes cloning bitstream impossible. I suspect that other vendors' chips have similar functionality.

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4943
  • Country: si
Re: FPGA ?
« Reply #35 on: April 16, 2018, 05:18:15 am »
Yep most FPGA manufacturers give you the option of encrypted bitstreams where a unique ID inside the FPGA is used as part of the decryption key for his unique bitstream.

This means that if you swapped out the FPGA on such a board the new FPGA would not boot because it will generate a different decryption key internally and will fail to decrypt the boot flash.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: FPGA ?
« Reply #36 on: April 16, 2018, 04:12:31 pm »
Not that it really matters here, a beginner or hobbyist is not going to care about encrypting their bitstream.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: FPGA ?
« Reply #37 on: April 16, 2018, 04:29:20 pm »
Not that it really matters here, a beginner or hobbyist is not going to care about encrypting their bitstream.

Anyway information about FPGA bitstream protection is much more relevant than you comment :D After all - you never know when your knowledge will be useful as well as you never know which beginner will become professional.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: FPGA ?
« Reply #38 on: April 16, 2018, 08:57:21 pm »
My point was simply that encryption is not something to worry about in the beginning, there are enough other hurdles to keep a beginner busy, encryption is not difficult to grasp later on if/when one needs it.
 

Offline JanJansenTopic starter

  • Frequent Contributor
  • **
  • Posts: 380
  • Country: nl
Re: FPGA ?
« Reply #39 on: April 17, 2018, 10:14:31 am »
All together it sounds really fun.
It should be really simple once you get the clue ?, just very verbose, i feel i have some talent for these things.

Developing blocks and copying them later without worrys, just like programming, once you spend time you get things ready for use.
Only thing is if i start SMD soldering i have more normal chips to buy wich they dont have in DIP.

I should install the software and emulator, maybe i dont need the dev board at all ?, not that 16 dollar is to much for me, only i have so many garbage already.

What would be the normal applications for FPGA ?, like they say it is overkill for a synthesizer, i want a polyfonic synthesizer so i need more power.
aliexpress parachute
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4943
  • Country: si
Re: FPGA ?
« Reply #40 on: April 17, 2018, 11:43:32 am »
Usually the FPGA development tools give you some form of simulator along with them. This is because often things are first run inside the simulator to test and debug them since troubleshooting a non working design while its running inside a real FPGA chip is difficult (It can't be stopped like a CPU hitting a breakpoint and its difficult to see whats happening inside)

I wouldn't say a big audio synthesizer is overkill to implement in a FPGA. But it does sound like something that could likely be done in a fast ARM CPU like a Raspberry Pi 3 or similar.

Tasks that a FPGA does can vary a lot, but usually a FPGA is used when you can't get an off the shelf chip to do what you need (often involving high speed). A common simple task for a small FPGA is adapting a fast interface bus into a different bus. For example turn a serial MIPI video bus into a standard parallel RGB video bus, while converting 24bit color to 18bit color with dither. Very little logic is required to do that and it doesn't even need to hold a full frame of video in memory, it can be done in a <10$ FPGA chip. There is no serious processing going on but the FPGA allows interfacing to that fast MIPI bus that might be moving its pins at 500MHz

On the other extreme are applications that require a great deal of processing power and move tons of data around. For example something like a military phased array radar system. The thing might have 1000 antennas each getting demodulated into an IQ signal sampled at 10s or 100s of MSPS, summing it up that's 100s of GB/s of data coming in. All of that data then has to be munched trough in some way like FFT done, correlated, further demodulated etc. In there you might find a $5000 FPGA chip and not one of them but an array of 10 to 100 of such chips to get enough processing power or data throughput.

As a middle between the two a FPGA might be used in a digital oscilloscope to grab data from the very fast ADC, stuff it into RAM and then generate a waveform picture from the data.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: FPGA ?
« Reply #41 on: April 17, 2018, 12:16:16 pm »
What would be the normal applications for FPGA ?, like they say it is overkill for a synthesizer, i want a polyfonic synthesizer so i need more power.
FPGAs are becoming very cheap and accessible and this trend will probably continue.  The learning curve is steep but it could fit your application if you have the time to dedicate to it. Poly-anything suits FPGAs well... you can use parallelism in hardware.
Have fun!
 

Offline JanJansenTopic starter

  • Frequent Contributor
  • **
  • Posts: 380
  • Country: nl
Re: FPGA ?
« Reply #42 on: April 17, 2018, 02:07:19 pm »
As a middle between the two a FPGA might be used in a digital oscilloscope to grab data from the very fast ADC, stuff it into RAM and then generate a waveform picture from the data.

That is a nice one i have to remember, i,m always curious how these fast scopes works, now i have to re-watch those teardown videos.
aliexpress parachute
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: FPGA ?
« Reply #43 on: April 17, 2018, 02:17:36 pm »
I wouldn't say a big audio synthesizer is overkill to implement in a FPGA. But it does sound like something that could likely be done in a fast ARM CPU like a Raspberry Pi 3 or similar.

a couple of years ago roland launched the aira series, all of which use one or more roland-labelled FPGAs (probably just relabelled parts) to create next-level virtual analog synthesizers, they called that ACB (Analog circuit behaviour)
makes sense to perform many of the calculations in parallel :)
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2729
  • Country: ca
Re: FPGA ?
« Reply #44 on: April 17, 2018, 03:07:52 pm »
What would be the normal applications for FPGA ?, like they say it is overkill for a synthesizer, i want a polyfonic synthesizer so i need more power.
FPGA is the closest you can get to designing your very own custom chip without having to spend millions of $$. So any digital circuit you can think of can be implemented inside FPGA provided that the chip you have on a board has enough resources. That said, this ultimate flexibility comes at a price, both literally (FPGAs are some of the most expensive chips out there, there are FPGAs that costs $100k+ for a single chip!) and figuratively (development tools are necessarily very complex and hard to get a grip on).

Offline JanJansenTopic starter

  • Frequent Contributor
  • **
  • Posts: 380
  • Country: nl
Re: FPGA ?
« Reply #45 on: April 17, 2018, 04:38:24 pm »
a couple of years ago roland launched the aira series, all of which use one or more roland-labelled FPGAs (probably just relabelled parts) to create next-level virtual analog synthesizers, they called that ACB (Analog circuit behaviour)
makes sense to perform many of the calculations in parallel :)

Ah nice to know, i havent had my hands on any aira synth, i hear from people the ACB sound really good compared to any other brand virtual analog.
Now i see how they made the ACB, its not magic after all.

Ok if this is the case that roland uses this for the ACB, then i definitly need to get started with this.
Aira also runs at 96K audio rate, very good, maybe i could have 192K how nice.
aliexpress parachute
 

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: FPGA ?
« Reply #46 on: April 17, 2018, 07:26:18 pm »
I hope you are **GOOD** at fixed point maths (And Z plane shenanigans generally)!

I would bet that a whole lot of that Roland thing is extensively multi rate, good non linearity normally needs a lot more then twice Nyquest.

I would probably start by getting my algorithms to run on a PC CPU possibly in matlab (They do not need to run in realtime here, have them write .wav files if need be), then graphics card, then see about an FPGA.

The graphics card, if you design your approach with an eye to ending up on an FPGA is a nice halfway step and it has a compile time a tiny fraction of that of an FPGA place and route.

This also lets you build test vectors that you can then use in your testbenches to verify the FPGA in simulation.

Regards, Dan.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: FPGA ?
« Reply #47 on: April 17, 2018, 09:37:19 pm »
If you were to ask me, here would be my rough plan for your first FPGA experiments.

It is a design of two halves - one half being the MIDI side, the other half being the audio side. They can be built independently and integrated as needed.

This link message will help with MIDI messages : https://www.midi.org/specifications/item/table-1-summary-of-midi-message

You could use a basic FPGA board from Ali Express, but I would suggest you get an entry level FPGA board from Terasic or Digilent, along with a compatible I2S DAC addon.

Anyway, on with the design:

MIDI control (can be done independently)
- Build the H/W side of the MIDI interface (Just an optoisolator with a pullup IIRC)

- Build an FPGA component to receive MIDI and display the message on the devboard LEDs.

- Enhance it to receive MIDI, filter channels, and display the message on LEDs.

- Enhance it to act on key down/key up message, and turn the LEDs into a display of active notes.

The audio design is where most of the work is needed.

First audio design

- Create an square wave oscillator (maybe tuned to A 440Hz)

- Attach it to an amp/speaker somehow - e.g resistor divider and and cap to block DC. Or maybe a R2R ladder if you want to get fancy.

- Create some way to switch it off and on, maybe use a button on the dev board

- If you have the MIDI control block, attach it to the signal on the control block that turns on when the 'A' note on MIDI message is received.

You can now play an 'A' note over MIDI or using a button.

Adding an cheap DAC

- Create a cheap and cheerfull one-bit DAC in the FPGA

- Change the oscillator to a DDS Sine wave, rather than a square wave.

- Sort out your understanding of signed vs unsigned samples, so it sounds like a sine wave :D

- Now play an 'A' as a sine wave.

- Maybe add options for more waveforms via switches.

Going polyphonic (one octave)

- Create 11 more copies of the oscillator, tuned to different notes of an octave.

- Wire each to the control section (or buttons if you haven't got that far).

- Add a simple (sum all channels) mixer, to mix the values heading into the DAC

Adding envelopes

- Create a timer for each channel

- Have it mute the note after a short period of time, or when MIDI note off is seen

- You can now play 'beep' 'beep' 'beep'

- Use the timer counter to index an envelope, and use that to multiply the oscillator output before going to the mixer

- You should now have something vaguely musical.

Add an I2S DAC

- Create an I2S transmitter

- Redesign your design to get the clocking friendly with I2S

- Have a reasonable high quality output

If you get this far, then you should have enough FPGA skills and experience to make useful judgement for your next synth project. One that actually is properly designed from the outset - e.g. rather than having an oscillator for each note you time-slice the logic between channels.

You can also look at adding DSP effects (e.g. reverb), to make it sound better.

Allow about a month of dedicated hobby time (maybe a 60-100hr project if you haven't touched HDL before).
« Last Edit: April 17, 2018, 09:40:44 pm by hamster_nz »
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: Berni

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: FPGA ?
« Reply #48 on: April 17, 2018, 10:27:37 pm »
Replying for interest to get updates and to say that hamster_nz should be nominated for a "Best EEVBlog answer" award!
 
The following users thanked this post: hamster_nz

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: FPGA ?
« Reply #49 on: April 17, 2018, 10:41:42 pm »
I dont understand how can you make a sinewave with gates ?

In a software way...

Code: [Select]
static unsigned int index; // Where we are in the lookup table, * 2^22
static unsigned int dds_step;   // How far we advance the index each cycle
static short int lookup_table[1024] = {... sine values ... };

void update_sine(void)
{
   dac_set_output(lookup_table[index>>22]);
   index += dds_step;
}

Converted to H/W that looks like a 32-bit accumulator to hold "index", a 1024 entry 16-bit memory block to hold "lookup_table", and an adder to add 'dds_step' to 'index'.

By changing the value of 'dds_step' you change how quickly you advance through the lookup table, and hence the frequency of the sine wave coming out of the DAC.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf