GithubHelp home page GithubHelp logo

zyedidia / firrtl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chipsalliance/firrtl

0.0 2.0 0.0 50.69 MB

Flexible Intermediate Representation for RTL

Home Page: https://www.chisel-lang.org/firrtl/

License: Apache License 2.0

Shell 0.13% C++ 0.09% Python 0.66% C 0.01% Scala 98.77% Verilog 0.04% ANTLR 0.23% SystemVerilog 0.01% Makefile 0.03% LLVM 0.05%

firrtl's Introduction

FIRRTL


Join the chat at https://gitter.im/freechipsproject/firrtl Build Status Mergify Status

Flexible Internal Representation for RTL

Firrtl is an intermediate representation (IR) for digital circuits designed as a platform for writing circuit-level transformations. This repository consists of a collection of transformations (written in Scala) which simplify, verify, transform, or emit their input circuit.

A Firrtl compiler is constructed by chaining together these transformations, then writing the final circuit to a file.

For a detailed description of Firrtl's intermediate representation, see the FIRRTL Language Specification (source).

Wiki Pages and Tutorials

Useful information is on our wiki, located here:

Some important pages to read, before writing your own transform:

To write a Firrtl transform, please start with the tutorial here: src/main/scala/tutorial. To run these examples:

sbt assembly
./utils/bin/firrtl -td regress -i regress/RocketCore.fir --custom-transforms tutorial.lesson1.AnalyzeCircuit
./utils/bin/firrtl -td regress -i regress/RocketCore.fir --custom-transforms tutorial.lesson2.AnalyzeCircuit

Other Tools

Installation Instructions

Disclaimer: The installation instructions should work for OSX/Linux machines. Other environments may not be tested.

Prerequisites
  1. If not already installed, install verilator (Requires at least v3.886)
  2. If not already installed, install yosys (Requires at least v0.8)
  3. If not already installed, install sbt (Recommend v1.6.2)
Installation
  1. Clone the repository: git clone https://github.com/freechipsproject/firrtl.git && cd firrtl
  2. Compile firrtl: sbt compile
  3. Run tests: sbt test
  4. Build executable (utils/bin/firrtl): sbt assembly
    • Note: You can add utils/bin to your path to call firrtl from other processes
  5. Publish this version locally in order to satisfy other tool chain library dependencies:
sbt publishLocal
Useful sbt Tips
  1. Run a single test suite: sbt "testOnly firrtlTests.UnitTests"
  2. Continually execute a command: sbt ~compile
  3. Only invoke sbt once:
sbt
> compile
> test
Use scalafix to remove unused import and deprecated procedure syntax
  1. Remove unused import:
sbt "firrtl/scalafix RemoveUnused"
  1. Remove deprecated procedure syntax
sbt "firrtl/scalafix ProcedureSyntax"
Using Firrtl as a commandline tool
utils/bin/firrtl -i regress/rocket.fir -o regress/rocket.v -X verilog // Compiles rocket-chip to Verilog
utils/bin/firrtl --help // Returns usage string
Using the JQF Fuzzer

The build.sbt defines the fuzzer/jqfFuzz and fuzzer/jqfRepro tasks. These can be used to randomly generate and run test cases and reproduce failing test cases respectively. These tasks are Scala implementations of the FuzzGoal and ReproGoal of the JQF maven plugin and should be functionally identical.

The format for the arguments to jqfFuzz are as follows:

sbt> fuzzer/jqfFuzz <testClassName> <testMethodName> <otherArgs>...

The available options are:

  --classpath <value>       the classpath to instrument and load the test class from
  --outputDirectory <value> the directory to output test results
  --testClassName <value>   the full class path of the test class
  --testMethod <value>      the method of the test class to run
  --excludes <value>        comma-separated list of FQN prefixes to exclude from coverage instrumentation
  --includes <value>        comma-separated list of FQN prefixes to forcibly include, even if they match an exclude
  --time <value>            the duration of time for which to run fuzzing
  --blind                   whether to generate inputs blindly without taking into account coverage feedback
  --engine <value>          the fuzzing engine, valid choices are zest|zeal
  --disableCoverage         disable code-coverage instrumentation
  --inputDirectory <value>  the name of the input directory containing seed files
  --saveAll                 save ALL inputs generated during fuzzing, even the ones that do not have any unique code coverage
  --libFuzzerCompatOutput   use libFuzzer like output instead of AFL like stats screen
  --quiet                   avoid printing fuzzing statistics progress in the console
  --exitOnCrash             stop fuzzing once a crash is found.
  --runTimeout <value>      the timeout for each individual trial, in milliseconds

The fuzzer/jqfFuzz sbt task is a thin wrapper around the firrtl.jqf.jqfFuzz main method that provides the --classpath argument and a default --outputDirectory and passes the rest of the arguments to the main method verbatim.

The results will be put in the fuzzer/target/JQf/$testClassName/$testMethod directory. Input files in the fuzzer/target/JQf/$testClassName/$testMethod/corpus and fuzzer/target/JQf/$testClassName/$testMethod/failures directories can be passed as inputs to the fuzzer/jqfRepro task.

The format for the arguments to jqfRepro are the same as jqfFuzz

sbt> fuzzer/jqfRepro <testClassName> <testMethodName> <otherArgs>...

The available options are:

  --classpath <value>      the classpath to instrument and load the test class from
  --testClassName <value>  the full class path of the test class
  --testMethod <value>     the method of the test class to run
  --input <value>          input file or directory to reproduce test case(s)
  --logCoverage <value>    output file to dump coverage info
  --excludes <value>       comma-separated list of FQN prefixes to exclude from coverage instrumentation
  --includes <value>       comma-separated list of FQN prefixes to forcibly include, even if they match an exclude
  --printArgs              whether to print the args to each test case

Like fuzzer/jqfFuzz, the fuzzer/jqfRepro sbt task is a thin wrapper around the firrtl.jqf.jqfRepro main method that provides the --classpath argument and a default --outputDirectory and passes the rest of the arguments to the main method verbatim.

Citing Firrtl

If you use Firrtl in a paper, please cite the following ICCAD paper and technical report: https://ieeexplore.ieee.org/document/8203780

@INPROCEEDINGS{8203780, 
author={A. Izraelevitz and J. Koenig and P. Li and R. Lin and A. Wang and A. Magyar and D. Kim and C. Schmidt and C. Markley and J. Lawson and J. Bachrach}, 
booktitle={2017 IEEE/ACM International Conference on Computer-Aided Design (ICCAD)}, 
title={Reusability is FIRRTL ground: Hardware construction languages, compiler frameworks, and transformations}, 
year={2017}, 
volume={}, 
number={}, 
pages={209-216}, 
keywords={field programmable gate arrays;hardware description languages;program compilers;software reusability;hardware development practices;hardware libraries;open-source hardware intermediate representation;hardware compiler transformations;Hardware construction languages;retargetable compilers;software development;virtual Cambrian explosion;hardware compiler frameworks;parameterized libraries;FIRRTL;FPGA mappings;Chisel;Flexible Intermediate Representation for RTL;Reusability;Hardware;Libraries;Hardware design languages;Field programmable gate arrays;Tools;Open source software;RTL;Design;FPGA;ASIC;Hardware;Modeling;Reusability;Hardware Design Language;Hardware Construction Language;Intermediate Representation;Compiler;Transformations;Chisel;FIRRTL}, 
doi={10.1109/ICCAD.2017.8203780}, 
ISSN={1558-2434}, 
month={Nov},}

https://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-9.html

@techreport{Li:EECS-2016-9,
    Author = {Li, Patrick S. and Izraelevitz, Adam M. and Bachrach, Jonathan},
    Title = {Specification for the FIRRTL Language},
    Institution = {EECS Department, University of California, Berkeley},
    Year = {2016},
    Month = {Feb},
    URL = {http://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-9.html},
    Number = {UCB/EECS-2016-9}
}

firrtl's People

Contributors

azidar avatar jackkoenig avatar seldridge avatar albert-magyar avatar donggyukim avatar scala-steward avatar ucbjrl avatar sequencer avatar chick avatar jackbackrack avatar ekiwi avatar ekiwi-sifive avatar albertchen-sifive avatar shunshou avatar davidbiancolin avatar aswaterman avatar colinschmidt avatar colin4124 avatar edwardcwang avatar ducky64 avatar grebe avatar jared-barocsi avatar sinofp avatar palmer-dabbelt avatar debs-sifive avatar mwachs5 avatar ingallsj avatar carlosedp avatar johnsbrew avatar alonamid avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.