Skip to content

This repository contains the codebase for Virtual FPGA Lab in Makerchip contributing as a participant in Google Summer of Code 2021, under FOSSi Foundation.

License

Notifications You must be signed in to change notification settings

os-fpga/Virtual-FPGA-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual FPGA Lab

  • Develop FPGA logic in your browser!
  • Run on your own FPGA!
  • Share with others!

lcd

References

This document introduces the Virtual FPGA Lab. Separate documents will help you with:

Contents

Overview

About Makerchip

What makes the project Virtual FPGA Lab special?

FPGA Boards demonstrated

FPGA peripheral macro instantiations

Examples

Visual Debug

How to add own FPGA boards and peripherals

Steps to run in an actual FPGA

Future Scope

Contributors

Contributing

License

What are FPGAs?

New to FPGAs? Field-programmable gate arrays (FPGAs) are a hardware circuits that can be programmed to carry out logical operations. They provide a sweet spot between implementing algorithms in software and fabricating application-specific integrated circuits (ASICs). They generally provide far better performance and power-efficiency than software implementations, and they require far less time and expense to implement than ASICs. They can be reprogrammed as needed to upgrade functionality or fix bugs, even after deployment to customers (in the "field"). FPGAs are also beneficial for prototyping application-specific integrated circuits (ASICs) or processors.

Virtual Lab Overview

Though far more accessible than ASICs, FPGAs can still be a bit costly and difficult to learn for beginners and students. That's where this project comes in... and it's not just for beginners.

This project builds on all the power and ease-of-use of Makerchip IDE and adds convenience for FPGA development. In particular, we take advantage of Makerchip's Visual Debug feature to provide visualizations of FPGAs and their peripherals, thereby mimicking the physical lab experience. But better than the physical experience, you also have the benefits of simulation-based development: fast compilation (no synthesis, place-and-route, and bitstreams), full visibility of all signal values, and full control of time.

Makerchip further simplifies the experience with support for TL-Verilog in addition to Verilog/SystemVerilog. TL-Verilog features are more approachable to newcomers (not to mention the myriad benefits for experts).

In summary:

  • Easy learning: Online; no board/peripherals required (but supported); simplified by TL-Verilog and Makerchip.
  • Powerful for experts: (for open-source development) The virtual lab augments vendor tools with the benefits of Makerchip development and virtual FPGA board/peripheral integration.
  • Vendor-agnostic: You're designs work on any FPGA boards with compatible peripherals. (Though currently-supported boards are all Xilinx-based.)
  • Exportable: Code in Virtual Lab works on real FPGAs!!!
  • Open Source: MIT-licensed.

Supported FPGA Boards

  1. Zedboard Zynq-7000 ARM/FPGA SoC Development Board (Product Link)
  2. EDGE Artix 7 FPGA Development Board (Product Link)
  3. Basys 3 Artix-7 FPGA Trainer Board (Product Link)
  4. Icebreaker FPGA (Product Link)
  5. Nexys A7 (Product Link)
  6. CLEAR (Article) (no physical FPGA flow)

Currently we demonstrate using only these boards and we plan to add more boards in the future. You can very easily add your own FPGA boards. Contributions are welcome.

Development Flow

Just click here, and go! (Right-click to open in a new tab.) Instructions below will guide you.

You can also start from any of the example project here.

Alternately, especially for local FPGA use, you can use Makerchip-app to edit files on your local machine (where you can maintain your git repository and run FPGA flows).

Once you have some logic running in simulation, you'll be able to export your design to any supported physical FPGA board using these instructions.

Starting Template

\m4_TLV_version 1d: tl-x.org
\SV
   m4_include_lib(['https://raw.githubusercontent.com/BalaDhinesh/Virtual-FPGA-Lab/main/tlv_lib/fpga_includes.tlv'])
   
   m4_lab()

   // ... SystemVerilog or TL-Verilog FPGA logic goes here ...
   
\TLV
   /board
      // Board selection:
      // 0: M4_FIRST_CLAAS_ID
      // 1: M4_ZEDBOARD_ID
      // 2: M4_ARTIX7_ID
      // 3: M4_BASYS3_ID
      // 4: M4_ICEBREAKER_ID
      // 5: M4_NEXYS_ID
      // 6: M4_CLEAR_ID
      m4+board(/board, /fpga, 3, *)   // 3rd arg selects the board.
\SV

   endmodule

The m4+board(...) macro (and peripheral macros, such as m4+lcd(...), define the hardware).

m4_lab() provides a superset of signals for I/Os. Those that have corresponding components on the board or peripherals should be driven/used. These include:

logic [15:0] led;             // corresponding LEDs are lit when asserted
logic [6:0] sseg_segment_n;   // corresponding segments are lit for selected digit(s) when deasserted 

logic sseg_decimal_point_n;   // decimal point is lit for selected digit(s) when deasserted
logic [7:0] sseg_digit_n;     // corresponding digits are enabled when deasserted

You can see these signal declarations in the one-line expansion of the m4_lab() macro instantiation in the NAV-TLV tab.

Configuring and Driving the FPGA Board and Peripherals

Board

In the starting template, the 3rd argument below can be used to select the board:

// Board selection:
// 0 - 1st CLaaS on AWS F1
// 1 - Zedboard
// 2 - Artix-7
// 3 - Basys3
// 4 - Icebreaker
// 5 - Nexys
// 6 - CLEAR
m4+board(/board, /fpga, 3, *)   // 3rd arg selects the board.

Boards contain a subset of the following components,

Virtual FPGA Lab builtin peripheral modules

LED Module

// Internal to FPGA - no need to instantiate
// Signals:
// *led - led signal

Seven segment displays

// Internal to FPGA - no need to instantiate
// Signals:
// *sseg_digit_n - common anode signal
// *sseg_segment_n - seven segments
// *sseg_decimal_point_n - decimal point

Push buttons

// Internal to FPGA - no need to instantiate
// Signals:
// *push - push button signal

Slideswitches

// Internal to FPGA - no need to instantiate
// Signals:
// *slideswitch - switch signal

LCD Module

// External to FPGA - instantiated using
m4+fpga_lcd() 

// Signals:
// *out - 8-bit data/command line
// *lcd_enable - lcd enable signal
// *lcd_reset - lcd reset signal, 0 for command and 1 for data

VGA display

// External to FPGA - instantiated using
m4+fpga_vga()

// Signals:
// *vga_hsync - horizontal sync
// *vga_vsync - vertical sync
// *vga_r - red signal
// *vga_g - green signal
// *vga_b - blue signal

External and other peripherals can be instantiated uisng m4+ macros.

Examples

Here are some example you can load in Makerchip. You'll find the source code in this repository under examples. (Right-click links to open in a new tab.)

LED Module

Seven segment displays

LCD Module

VGA display

Temperature sensor

Light sensor

Push buttons

Slideswitches

RGB LED

RISC-V MYTH Core

How to Add FPGA Boards and Peripherals

Board definitions appear at the top of the fpga_includes.tlv file. It should be easy enough to interpret these parameters and add new boards by example. Be sure also to update all listings of available boards (which you can find using git grep -i zedboard).

The above steps update the virtual environment only. The physical FPGA build flow is a different matter and is platform-dependent, though open-source platform-agnostic build flows are available, and we'd love to use them.

We welcome your contributions.

Visual Debug:

Makerchip's Visual Debug feature is used to create the Virtual FPGA Lab.

You can also use Visual Deubg to visualize the logic running inside the FPGA.

Visualizing your FPGA logic

By structuring your code to define your FPGA logic in TL-Verilog (which does not preclude using pure Verilog/SystemVerilog), you can add visualization to your logic.

Here's a sample code structure.

...
\SV
   m4_lab()

\TLV my_fpga_logic(/_fpga)
   // ... Your TL-Verilog FPGA logic along with it's visualization ...

\TLV
   /board
      m4+board(/board, /fpga, 3, *, , my_fpga_logic)
...

Visual Debug documentation and examples can be found within the Makerchip IDE.

Steps to run in an actual FPGA

Detailed step-by-step instructions are provided in this link. Credit goes to Mayank Kabra for helping me build this part.

LED Demo: Link

Output in Makerchip and actual FPGA board:

led_makerchip led_artix

Future Scope

  • To support more FPGA boards and peripherals.
  • The automated shell script that converts TL-V code to run in an actual FPGA currently supports only Xilinx boards with Vivado software. So to provide scripts that target other vendors as well using open source tools. It would probably be wise to use EDAlize.

Links

A Blog Post on this Virtual FPGA Lab

Blog post

Similar Environments

In our efforts, we've come across the following related projects. (Appearance on this list is not an endorsement, just a recognition that we are not alone.) Give us a pull request with any others.

Sponsors

This work has been sponsored through the OSFPGA Foundation and Google Summer of Code (GSoC) 2021(with the Free and Open Source Silicon Foundation (FOSSi) as a GSoC umbrella organization), with mentorship from Redwood EDA, LLC, and with training support from VLSI System Design.

gsoc-logo      gsoc-logo      redwoodeda-logo      fossi-logo      vsd-logo

Contributors

Contributing

Contributions are what make the open source community such an amazing vehicle to learn, inspire, and create. Any contributions you make are greatly appreciated. Kudos for filing bugs. Deepest thanks for fixing them and for contributing new features and support for new boards.

License

Distributed under the MIT License. See LICENSE.md.

About

This repository contains the codebase for Virtual FPGA Lab in Makerchip contributing as a participant in Google Summer of Code 2021, under FOSSi Foundation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published