Home
Welcome
Information


FPGA projects
Basic
Music box
LED displays
Pong game
R/C servos
Text LCD module
Quadrature decoder
PWM and one-bit DAC
Debouncer
Crossing clock domains
External contributions

Interfaces
RS-232
JTAG
I2C
EPP
SPI
PCI
PCI Express
10BASE-T

Advanced
Digital oscilloscope
Graphic LCD panel
Direct Digital Synthesis
CNC steppers
Spoc CPU core

Hands-on
A simple oscilloscope


FPGA introduction
What are FPGAs?
How FPGAs work
Internal RAM
FPGA pins
Clocks and global lines
Download cables
Configuration
Learn more

FPGA software
Design software
Pin assignment
Design-entry/HDL
Simulation/HDL
Synthesis and P&R

FPGA electronic
SMD technology
Crystals and oscillators

HDL info
HDL tutorials
Verilog tips
VHDL tips

Quick-start guides
ISE
Quartus

Site
News
FPGA links
HDL tutorials
Forum


FPGA design entry

How do you describe the hardware that you want to implement into an FPGA?

There are 2 methods:

Schematic design entry

With schematic design entry, you draw your design on your computer like you would draw it on paper, using gates and wires.

Schematic entry is nice because it documents the design in an easily readable format. But big designs quickly become difficult to maintain, the file formats are incompatibles between vendors, and HDL are easier to parameterize, so many FPGA users shy away from schematic design entry.

HDL design entry

Each vendor used to have its own proprietary languages. But some 10 years ago came 2 new languages ("Verilog" and "VHDL") high-level HDLs (hardware description languages), that quickly got popular for chip and FPGA design. FPGA vendors started supporting mainly these 2 languages.

High-level HDLs are nowadays the preferred way to create FPGA designs. They also make migrations much easier.

Learning an HDL takes an effort, and this is probably the most important thing you'll have to learn when diving into the FPGA world. This website makes things somehow easier since you can learn from the example designs. And by learning an high-level HDL, your time-investment is protected because these languages are now industry standards.

How do HDLs look?

Ok, let's implement a set of AND and OR gates, like that:

The HDL code looks like that:

VerilogVHDL
module gates(a, b, q, r);
input a, b;
output q, r;

assign q = a & b;
assign r = a | b;

endmodule
library ieee;
use ieee.std_logic_1164.all;
entity gates is
    port( a,b: in std_logic;
        q,r: out std_logic);
end;

architecture implement of gates is
begin
  q <= a and b;
  r <= a or b;
end;

As you can see, Verilog is pretty straightforward, while VHDL requires additional declarations.

Now let's look on how to create a D-flipflop:

VerilogVHDL
module d_flipflop(clk, d, q);
input clk, d;
output q;

reg q;
always @(posedge clk)
begin
  q <= d;
end

endmodule
library ieee;
use ieee.std_logic_1164.all;
entity d_flipflop is
    port( clk, d: in std_logic;
        q: out std_logic);
end;

architecture implement of d_flipflop is
begin
  process(clk)
  begin
    if clk'EVENT and clk='1' then
      q <= d;
    end if;
  end process;
end;

Here things are more complicated. To get a D-flipflop, you have to describe its behavior by saying "at each positive clock edge, please copy the 'd' input to the 'q' output". This is why these languages are called "behavioral languages". This example is synthesizable (you can directly put it into an FPGA), but behavioral languages can also produce non-synthesizable designs.

Non-synthesizable designs

Using a behavioral language, you can describe a circuit that has no hardware equivalent. This type of circuit can only be run in an HDL simulator.
For example:

module d_flipflop_2clks(clk1, clk2, d, q);
input clk1, clk2, d;
output q;

reg q;
always @(posedge clk1 or posedge clk2)
begin
  q <= d;
end

endmodule

This circuit describes a flipflop that takes 2 clocks.
Such circuit has no direct hardware equivalent (no synthesis software will be able to process it). But HDL simulators are just happy with it.



>>> NEXT: FPGA simulation >>>



This page was last updated on December 27 2007.