Giter Club home page Giter Club logo

petr4's Introduction

Build Status

Petr4

The Petr4 project is developing the formal semantics of the P4 Language backed by an independent reference implementation.

POPL'21 artifact

See https://verified-network-toolchain.github.io/petr4/ or check out the gh-pages branch for information on the Petr4 artifact.

Getting Started

Installing Petr4

  1. Install OPAM 2 following the official OPAM installation instructions. Make sure opam --version reports version 2 or later.

  2. (on Linux) Install external dependencies:

    sudo apt-get install m4 libgmp-dev
    
  3. (on MacOS) Install external dependencies:

    brew install m4
    brew install gmp
    

Installing from source

You can use the scripts to install Petr4. Alternatively, follow theses steps:

  1. Check the installed version of OCaml:

    ocamlc -v
    

    If the version is less than 4.14.0, upgrade:

    opam switch create <name> ocaml-base-compiler.4.14.0
    
  2. Install p4pp from source.

    opam pin add p4pp https://github.com/cornell-netlab/p4pp.git
    
  3. Install Coq and Bignum.

    opam install coq
    opam install bignum
    

    If this doesn't work, install the dependencies manually. This step shouldn't be needed.

    opam install ANSITerminal alcotest bignum cstruct-sexp pp ppx_deriving ppx_deriving_yojson yojson js_of_ocaml js_of_ocaml-lwt js_of_ocaml-ppx
    
  4. Build bundled dependencies.

    opam repo add coq-released https://coq.inria.fr/opam/released
    opam pin add coq-vst-zlist https://github.com/PrincetonUniversity/VST.git
    opam install . --deps-only
    
  5. Use dune to build and install petr4.

    dune build
    dune install
    
  6. [Optional] Run tests

    make test
    
  7. [Optional] Install helper packages

    opam install utop ocaml-lsp-server ocamlformat ocamlformat-rpc
    
  8. [Optional] Run one of the following commands dune utop OR dune utop -p petr4. Check if you can run the following command in the toplevel. It should return an empty string.

    Petr4.P4info.to_string Petr4.P4info.dummy;;   
    

Running Petr4

Currently petr4 is merely a P4 front-end. By default, it will parse a source program to an abstract syntax tree and print it out, either as P4 or encoded into JSON.

Run petr4 -help to see the list of currently-supported options.

Contributing

Petr4 is an open-source project. We encourage contributions! Please file issues on Github.

Credits

See the list of contributors.

License

Petr4 is released under the Apache2 License.

petr4's People

Contributors

alaiasolkobreslin avatar alexchang8 avatar amandashoe avatar bcip avatar calvin-s avatar ericthewry avatar hackedy avatar hyunny94 avatar jnfoster avatar jsarracino avatar lennartberinger avatar liujed avatar mollydream avatar natalieisak avatar nigusu-allehu avatar nikaido-shinku avatar pataei avatar pdimens avatar qinshiwang avatar rudynicolop avatar stp59 avatar sundararajan20 avatar tobiaskappe avatar txyyss avatar xclerc avatar zachary-kent 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.