Fpga

526 views

Published on

Program lattice semiconductor's FPGA's using 100% free software tools from the IceStorm Project.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
526
On SlideShare
0
From Embeds
0
Number of Embeds
175
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Fpga

  1. 1. FPGA hacking with Free Software Tools Pramode C.E http://pramode.net March 12, 2016
  2. 2. What is this? Pramode C.E FPGA hacking with Free Software Tools
  3. 3. From NAND to Tetris Pramode C.E FPGA hacking with Free Software Tools
  4. 4. 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
  5. 5. Field Programmable Gate Arrays (FPGA's) Pramode C.E FPGA hacking with Free Software Tools
  6. 6. How does an FPGA work? Pramode C.E FPGA hacking with Free Software Tools
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. 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
  11. 11. A NAND Gate module Nand2(output c, input a, b); assign c = ~(a b); endmodule Pramode C.E FPGA hacking with Free Software Tools
  12. 12. 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
  13. 13. But where is the hardware?? The Lattice IceStick evaluation board Pramode C.E FPGA hacking with Free Software Tools
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. Concurrency and Hardware y = (a or b) and (c or d) implemented on an FPGA: Pramode C.E FPGA hacking with Free Software Tools
  18. 18. 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
  19. 19. 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
  20. 20. WhoAmI? module WhoAmI(input PMOD1,PMOD2,PMOD3, output LED1,LED2,LED3,LED4,LED5); // only LED1 is significant wire f1,f2,f3,f4; assign f1 = (~PMOD1) PMOD2 (~PMOD3); assign f2 = (~PMOD1) PMOD2 PMOD3; assign f3 = PMOD1 (~PMOD2) PMOD3; assign f4 = PMOD1 PMOD2 PMOD3; assign LED1 = f1 | f2 | f3 | f4; //assign LED2,3,4,5 to 0 ... lines not shown. endmodule Pramode C.E FPGA hacking with Free Software Tools
  21. 21. WhoAmI? module WhoAmI(input PMOD1,PMOD2,PMOD3, output LED1,LED2,LED3,LED4,LED5); // only LED1 is significant always @(*) begin if(PMOD1 == 0) LED1 = PMOD2; else LED1 = PMOD3; end //assign LED2,3,4,5 to 0 ... lines not shown endmodule Pramode C.E FPGA hacking with Free Software Tools
  22. 22. WhoAmI? The Answer!! Pramode C.E FPGA hacking with Free Software Tools
  23. 23. WhoAmI, again! module WhoAmIAgain(input PMOD1,PMOD2, output LED1,LED2,LED3,LED4,LED5); always @(posedge PMOD1) begin LED1 = PMOD2; end assign LED2 = 0; assign LED3 = 0; assign LED4 = 0; assign LED5 = 0; endmodule Pramode C.E FPGA hacking with Free Software Tools
  24. 24. WhoAmIAgain? The Answer!! Pramode C.E FPGA hacking with Free Software Tools
  25. 25. 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
  26. 26. Random bitstream using an LFSR Pramode C.E FPGA hacking with Free Software Tools
  27. 27. A UART Transmitter Pramode C.E FPGA hacking with Free Software Tools
  28. 28. 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
  29. 29. The Future The IcoBoard Pramode C.E FPGA hacking with Free Software Tools
  30. 30. The Future The IceZum Pramode C.E FPGA hacking with Free Software Tools
  31. 31. The Future Check out icoboard.org for more exciting news! Pramode C.E FPGA hacking with Free Software Tools
  32. 32. Thank You! Questions welcome! Pramode C.E FPGA hacking with Free Software Tools

×