Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:58 03 Dec 2021 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : FPGA - General discussion

Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 05:20pm 15 Oct 2021
Copy link to clipboard 
Print this post

There's an introduction to FPGAs and VHDL here. It's not specific to the little board that I ordered so I've kept it out of that thread.

Here's a free book on VHDL.

EDIT:
I've been having a read of that Freerange book and can highly recommend it. It assumes that you know a bit of a procedural language and a bit about logic gates, but apart from that it's a true beginners book. It doesn't attempt to completely cover VHDL, leaving out most of the complex stuff, but it appears to get you to the stage where you can write usable (and readable!) VHDL. Note that it's in no way specific to any FPGA and leaves out some of the complex modules that you might find in them.

Another free book here, this time dealing with digital design. It includes the use of VHDL in later chapters so it's reasonably on topic here. :) It's also by Bryan Mealy and IMHO looks very good indeed.

You really do have to think a bit laterally with these things...
Your VHDL tells the system how to create & interconnect gates, memory & blocks. It has nothing to do with the order in which things happen or how fast they happen (other than if you are creating a clocked system). Once it's in the FPGA your entire "program" happens virtually instantly, with everything happening simultaneously and in parallel - just like a big board of logic chips. You have to unlearn the concept of normal programming to some extent.
.
.
Edited 2021-10-16 22:55 by Mixtel90
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Cyber

Senior Member

Joined: 13/01/2019
Location: Ukraine
Posts: 139
Posted: 04:05am 18 Oct 2021
Copy link to clipboard 
Print this post

  Mixtel90 said  You really do have to think a bit laterally with these things...
Your VHDL tells the system how to create & interconnect gates, memory & blocks. It has nothing to do with the order in which things happen or how fast they happen (other than if you are creating a clocked system). Once it's in the FPGA your entire "program" happens virtually instantly, with everything happening simultaneously and in parallel - just like a big board of logic chips. You have to unlearn the concept of normal programming to some extent.

Thank you for sharing your experience.
I know the basics of FPGA concept, but I never tried to mess with it.
I think that programming an FPGA should feel very close to designing and assembling actual electric circuit. Does it?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 07:02am 18 Oct 2021
Copy link to clipboard 
Print this post

It seems to be very much like that. VHDL is a language to describe various functions e.g.

--this is a comment line describing an AND gate
out <= in1 AND in2 AND NOT in3

If I understand correctly, this is a 3-input AND gate with one input inverted.

What you see as a gate is, in actual fact, a whole block of logic on the die. Your code programs that block to act as a logic gate, flip-flop or whatever (there are loads of these LEs - Logic Elements - on the chip). Because of this it doesn't matter what order the instructions are in the program flow, they all happen at the same time - all the LEs are active all the time, just like physical logic would be.

It's possible (though rather hard work) to use Quartus to write your program from a logic diagram. You drag & drop logic symbols into the workspace and wire them up. It's pretty, but rather pointless on anything more than a few gates. VHDL looks like it will be quicker once you get into it. You can also use Verilog. I've not seen that, but I'm told it's more similar to C.
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Cyber

Senior Member

Joined: 13/01/2019
Location: Ukraine
Posts: 139
Posted: 12:25pm 18 Oct 2021
Copy link to clipboard 
Print this post

Interesting. Thank you for sharing!
 
zeitfest
Senior Member

Joined: 31/07/2019
Location: Australia
Posts: 212
Posted: 09:02pm 18 Oct 2021
Copy link to clipboard 
Print this post

Intriguing.
I can see they would be great at processing many logic conditions in parallel, I am wondering is math or sequential logic included easily ?
Christmas holiday project : write an interpreter that runs on a FPGA. Why ? Because it's there ...
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 07:10am 19 Oct 2021
Copy link to clipboard 
Print this post

Good question. One I'm not sure about at all. :)
I think you'd have to write math routines, although there are some small on-chip multipliers IIRC. On some of the bigger FPGAs there is a microprocessor core that you can connect to. Those would probably be a better option.

Having said all that, it's not insurmountable. What got me interested originally is running a Nascom 2 on a Cyclone II FPGA, which is very basic. It includes the BASIC interpreter, which obviously has math routines in it. You do need to attach a SRAM chip though as the FPGA hasn't got enough.

Grant Searle has a "kit" of "bits" for you to "build" a home computer on the Cyclone II board!
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 09:30am 19 Oct 2021
Copy link to clipboard 
Print this post

  zeitfest said  Intriguing.
I can see they would be great at processing many logic conditions in parallel, I am wondering is math or sequential logic included easily ?
Christmas holiday project : write an interpreter that runs on a FPGA. Why ? Because it's there ...


You can implement sequential logic on FPGA through FSM state machines. I'll copy below an example that iteratively computes the nth Fibonacci number.

Basic blocks exist for adding, multiplying, dividing. More complex math can be implemented on FPGA using the CORDIC algorithm. This article describes how to implement sine and cosine on FPGA using CORDIC:

https://zipcpu.com/dsp/2017/08/30/cordic.html

The FSM approach doesn't really scale to implementing complete SW programs in FPGA logic, however. There exist tools that can compile C or some Higher Level Language to FPGA logic, but I don't know how well those work. Whenever the topic comes up on reddit r/fpga, people seem to be rolling their eyes.
The paradigms just don't match. FPGA (or ASICs) are good at doing stuff in parallel or in a pipeline, but are very clumsy when it comes to executing arbitrary sequential recipes. Processors are much better at that. You can of course instantiate a processor on an FPGA and then run an interpreter on that processor.


// Listing 6.3
module fib
  (
   input  logic clk, reset,
   input  logic start,
   input  logic [4:0] i,
   output logic ready, done_tick,
   output logic [19:0] f
  );

  // fsm state type
  typedef enum {idle, op, done} state_type;

  // signal declaration
  state_type state_reg, state_next;
  logic [19:0] t0_reg, t0_next, t1_reg, t1_next;
  logic [4:0] n_reg, n_next;

  // body
  // FSMD state & data registers
  always_ff @(posedge clk, posedge reset)
     if (reset)
        begin
           state_reg <= idle;
           t0_reg <= 0;
           t1_reg <= 0;
           n_reg <= 0;
        end
     else
        begin
           state_reg <= state_next;
           t0_reg <= t0_next;
           t1_reg <= t1_next;
           n_reg <= n_next;
        end
  // FSMD next-state logic
  always_comb
  begin
     state_next = state_reg;
     ready = 1'b0;
     done_tick = 1'b0;
     t0_next = t0_reg;
     t1_next = t1_reg;
     n_next = n_reg;
     case (state_reg)
        idle: begin
           ready = 1'b1;
           if (start) begin
              t0_next = 0;
              t1_next = 20'd1;
              n_next = i;
              state_next = op;
           end
        end
        op: begin
           if (n_reg==0) begin
              t1_next = 0;
              state_next = done;
           end
           else if (n_reg==1)
              state_next = done;
           else begin
              t1_next = t1_reg + t0_reg;
              t0_next = t1_reg;
              n_next = n_reg - 1;
           end
        end  
        done: begin
           done_tick = 1'b1;
           state_next = idle;
        end
        default: state_next = idle;
     endcase
  end
  // output
  assign f = t1_reg;
endmodule

Epsilon CMM2 projects
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 10:49am 19 Oct 2021
Copy link to clipboard 
Print this post

I've been interested in FPGAs for some time but the prospect of learning on a dead part with an old version of the development environment doesn't appeal.

Is anyone aware of a current FPGA dev board available at a sensible price with free development environment or does such a thing not exist. The uP world now seems to recognise that cheap dev environments with freely available quality IDEs is the way to sell more product but the same doesn't seem to be the case (yet?) for FPGA
 
nutson
Newbie

Joined: 01/07/2019
Location: Netherlands
Posts: 13
Posted: 11:09am 19 Oct 2021
Copy link to clipboard 
Print this post

May I offer some (unsollicited) advice? After my retirement I developped an interest in FPGA's and worked my way up with boards from FPGA4FUN, the Elektuur project from 2007 and later TERASIC boards.
My warning: the learning curve is steep. Before mastering the whole development chain: design entry, simulation, download, debug You will have spend many many hours in the dvelopment software, be it Quartus or Vivado.
My advice: forget about cheap boards, the only boards you want are those that come with plenty support: documentation, sample projects. The way I learned FPGA was by taking  a working design and modify it in little steps. Thats why I use only Terasic boards now, and consequently Quartus and Verilog, because thats what Terasic supports.
The DE0-nano is an exellent board to start learning, with lots of projects and support.

Regards

Nico Hattink
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 11:16am 19 Oct 2021
Copy link to clipboard 
Print this post

Personally I'm not bothered about the part being out of date. It doesn't matter whether I learn VHDL on that or on the latest chip, it just has less facilities on it. It also matters less if the magic smoke escapes. :) The method of programming and the sequence you go through to transfer the prog onto the chip remain the same. I had a particular reason for choosing this cheap board.

Have a look at Xilinx FPGAs and software. I think their stuff might be the most reasonable at the moment. Digilent make a little one. At Farnell
Edited 2021-10-19 21:22 by Mixtel90
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 11:37am 19 Oct 2021
Copy link to clipboard 
Print this post

On the Altera side, the DE0-nano and the DE10-nano are good options. The DE0-nano is an easier device to get started on. DE10-nano on the other hand is a bigger, more complex device so you'll get more mileage out of that one. The DE10-nano is also what Mister FPGA uses.

On the Xilinx side, I have an Arty A7 35T. It's a great board to start out with, big enough to hold simple SoCs, but I already wish I had its bigger brother, the Nexys-A7, which is what Mega65 uses. It has more on-chip memory and more peripherals (e.g. USB ports for keyboard and mouse that present themselves to the FPGA through some wizardry as PS/2, which is much easier to deal with).
Epsilon CMM2 projects
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 01:23pm 19 Oct 2021
Copy link to clipboard 
Print this post

  Quote  On the Altera side, the DE0-nano and the DE10-nano are good options.


QED re pricing

Altera FPGA EP4CE6E22C8N as on the DE0-nano GBP12.42 at RS
DE0-nano dev board GBP106.61 at RS

STM32H743VIT6  GBP12.75 at RS
Nucleo-H743ZI2 dev board GBP28.26 at RS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 02:09pm 19 Oct 2021
Copy link to clipboard 
Print this post

You have to watch the software too. Some of it (like Quartus) is subscription only for the later versions.

There is a bit of FOSS stuff for FPGA, but not all of it is fully functional and the range of supported FPGAs is limited. Symbiflow
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
nutson
Newbie

Joined: 01/07/2019
Location: Netherlands
Posts: 13
Posted: 02:37pm 19 Oct 2021
Copy link to clipboard 
Print this post

Quartus lite edition is totally free https://fpgasoftware.intel.com/?edition=lite and supports all Cyclone IV and V FPGA's. For older cyclone variants you can download Quartus lite version 13.0 or 13.1. Fact is that since Intel bought Altera support for new families as Cyclone-10GX is only available in the subscription version (and innovation only seems to happen in ultra expensive families)
 
Fingerhoff

Newbie

Joined: 21/01/2021
Location: Germany
Posts: 11
Posted: 07:52am 22 Oct 2021
Copy link to clipboard 
Print this post

  Quote  On the Xilinx side, I have an Arty A7 35T. It's a great board to start out with, big enough to hold simple SoCs, but I already wish I had its bigger brother, the Nexys-A7, which is what Mega65 uses. It has more on-chip memory and more peripherals (e.g. USB ports for keyboard and mouse that present themselves to the FPGA through some wizardry as PS/2, which is much easier to deal with).

I recently also started to dig a little into the FPGA-Topic. Quite fascinating, I have to say...
I got myself a Nexys A7-50T with all the peripherals you mentioned. That was just because I got a gread deal for a 2nd-hand model, though. Otherwise I would have gone with the Arty A7-35T, aswell. BTW, shouldn't it be fairly easy to add the mentioned peripherals with Xilinx's PMOD system?
The Arty 7 has four or five connectors, if I recall correctly
Edited 2021-10-22 18:15 by Fingerhoff
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 52
Posted: 09:43am 22 Oct 2021
Copy link to clipboard 
Print this post

  matherp said  I've been interested in FPGAs for some time but the prospect of learning on a dead part with an old version of the development environment doesn't appeal.

Is anyone aware of a current FPGA dev board available at a sensible price with free development environment or does such a thing not exist. The uP world now seems to recognise that cheap dev environments with freely available quality IDEs is the way to sell more product but the same doesn't seem to be the case (yet?) for FPGA


Aside from the big players, take a look at the Efinix Titanium series, and more specifically the Ti60-F100 because it has 256Mb built-in RAM. They give license for their IDE when you buy a dev kit, and those are quite cheap on Digikey.
Similar options with Gowin chips, and those even come in QFP package.
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 11:12am 22 Oct 2021
Copy link to clipboard 
Print this post

  Fingerhoff said  I got myself a Nexys A7-50T with all the peripherals you mentioned. That was just because I got a gread deal for a 2nd-hand model, though. Otherwise I would have gone with the Arty A7-35T, aswell. BTW, shouldn't it be fairly easy to add the mentioned peripherals with Xilinx's PMOD system?
The Arty 7 has four or five connectors, if I recall.


I have PMODs for VGA, audio, SD and PS/2.
There is no USB HID to PS/2 PMOD however. That adapter is unique to the Nexys A7. I (and a few other people) have asked Digilent if they could provide such a PMOD, or at least release the design they have used on the Nexys, but that's not going to happen.

Also, the PS/2 PMOD appears to assume that the peripheral will work at 3V3, even though PS/2 Vcc is supposed to be 5V. I haven't been able to get mine to work yet. I think the old PS/2 keyboard I have really requires 5V. I'm checking if with some jumper changes I can make the PMOD work at 5V.

Another advantage of your Nexys A7 is that you can run the Mega65 on it. That's not an option for the Arty.
Epsilon CMM2 projects
 
Fingerhoff

Newbie

Joined: 21/01/2021
Location: Germany
Posts: 11
Posted: 11:42am 22 Oct 2021
Copy link to clipboard 
Print this post

  Quote  I have PMODs for VGA, audio, SD and PS/2.
There is no USB HID to PS/2 PMOD however. That adapter is unique to the Nexys A7. I (and a few other people) have asked Digilent if they could provide such a PMOD, or at least release the design they have used on the Nexys, but that's not going to happen.


Oh, sry to hear. I had a quick glance at digilent's PMOD collection a few days ago, but didn't really check, if they had those. I guess, you could probably convert the 3V3 to 5V for your keyboard somehow, but on the other hand, it would be nice if it just worked out of the box .

You're certainly right, when it comes to the MEGA65 project. Make sure, however, to get the 100T model of the Nexys A7 (or the older Nexys4DDR) then. The 50T model doesn't seem to be compatible. At least that's what I've read somewhere.
BTW, I played around with the MEGA65 core on an older Nexys4-Artix7 a while back. It worked beautifully.
Edited 2021-10-22 21:44 by Fingerhoff
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2021