Program lattice semiconductor's FPGA's using 100% free software tools from the IceStorm Project.
Size: 811.56 KB
Language: en
Added: Mar 12, 2016
Slides: 32 pages
Slide Content
FPGA hacking with Free Software Tools
Pramode C.E
http://pramode.net
March 12, 2016
What is this?
Pramode C.E FPGA hacking with Free Software Tools
From NAND to Tetris
Pramode C.E FPGA hacking with Free Software Tools
Can you build the Nand2Tetris CPU on real h/w without having to
wire up hundreds of gates on prototyping boards?
Pramode C.E FPGA hacking with Free Software Tools
Field Programmable Gate Arrays (FPGA's)
Pramode C.E FPGA hacking with Free Software Tools
How does an FPGA work?
Pramode C.E FPGA hacking with Free Software Tools
Programming an FPGA
Circuit is described using Verilog / VHDL
Simulated to ensure correct operation
Synthesized to a netlist
Place-and-route
Send the "bitstream" to the FPGA
Pramode C.E FPGA hacking with Free Software Tools
Programming an FPGA
Simulation can be done using purely free software tools
(example: iverilog)
Proprietary tools required for generating the "bitstream" which
will congure the FPGA.
Pramode C.E FPGA hacking with Free Software Tools
The IceStorm Project
Home Page: cliord.at/icestorm
Target: Lattice Semiconductor's ICE40 FPGA's
Main Tools: yosys (synthesis), arachne-pnr (place and
route),icepack(le format conversion),iceprog(device
programming)
Pramode C.E FPGA hacking with Free Software Tools
Hello, World!
A simple Verilog model:
module And2(input a, b, output c);
assign c = a & b;
endmodule
Pramode C.E FPGA hacking with Free Software Tools
A NAND Gate
module Nand2(output c, input a, b);
assign c = ~(a & b);
endmodule
Pramode C.E FPGA hacking with Free Software Tools
A NAND Gate - by combining modules
module Nand2(output c, input a, b);
wire f;
and G1(f, a, b);
not G2(c, f);
endmodule
Pramode C.E FPGA hacking with Free Software Tools
But where is the hardware??
The Lattice IceStick evaluation board
Pramode C.E FPGA hacking with Free Software Tools
LED On!
Put on LED1 on the IceStick board. A le with pin-mappings for
LED1,LED2 etc is needed for proper operation.
module Led(output LED1, LED2, LED3, LED4, LED5);
assign LED1 = 1;
assign LED2 = 0;
assign LED3 = 0;
assign LED4 = 0;
assign LED5 = 0;
endmodule
Pramode C.E FPGA hacking with Free Software Tools
LED On!
Here is the build script for the previous program(led.v is the verilog
source and led.pcf is the pin mapping):
yosys -p "synth_ice40 -blif led.blif" led.v
arachne-pnr -d 1k -p led.pcf led.blif -o led.asc
icepack led.asc led.bin
iceprog led.bin
Pramode C.E FPGA hacking with Free Software Tools
LED On!
And here is led.pcf:
set_io LED1 99 # red
set_io LED2 98 # red
set_io LED3 97 # red
set_io LED4 96 # red
set_io LED5 95 # green
Pramode C.E FPGA hacking with Free Software Tools
Concurrency and Hardware
y = (a or b) and (c or d) implemented on an FPGA:
Pramode C.E FPGA hacking with Free Software Tools
Concurrency and Hardware
y = (a or b) and (c or d) evaluated by a microprocessor(note:
output produced by gcc -S):
movl a, %edx
movl b, %eax
movl %edx, %ecx
orl %eax, %ecx
movl c, %edx
movl d, %eax
orl %edx, %eax
andl %ecx, %eax
Pramode C.E FPGA hacking with Free Software Tools
A NAND Gate - in real Hardware!
PMOD1 and PMOD2 are pins 1 and 2 on the "PMOD" connector
of the IceStick board.
module Nand2(input PMOD1, PMOD2,
output LED1,LED2,LED3,LED4,LED5);
// Nand gate o/p is on LED1 only
assign LED1 = ~(PMOD1 & PMOD2);
assign LED2 = 0;
assign LED3 = 0;
assign LED4 = 0;
assign LED5 = 0;
endmodule
Pramode C.E FPGA hacking with Free Software Tools
WhoAmIAgain? The Answer!!
Pramode C.E FPGA hacking with Free Software Tools
More demos!
Rotating LED's
Random bit generation using a Linear Feedback Shift Register
A UART transmitter
A full CPU running a FORTH system!
Pramode C.E FPGA hacking with Free Software Tools
Random bitstream using an LFSR
Pramode C.E FPGA hacking with Free Software Tools
A UART Transmitter
Pramode C.E FPGA hacking with Free Software Tools
Some other languages/frameworks available for hardware
description
MyHDL - uses Python
Chisel - uses Scala
Clash - uses Haskell
HardCaml - uses Ocaml
PSHDL - a beginner level tool which generates VHDL
IceStudio - Verilog code from block diagrams!
Pramode C.E FPGA hacking with Free Software Tools
The Future
The IcoBoard
Pramode C.E FPGA hacking with Free Software Tools
The Future
The IceZum
Pramode C.E FPGA hacking with Free Software Tools
The Future
Check out icoboard.org for more exciting news!
Pramode C.E FPGA hacking with Free Software Tools