Giter VIP home page Giter VIP logo

mcircuit's Introduction

mcircuit

A library of types for working with boolean & arithmetic circuits

View on docs.rs

Features

  • : Circuit type
  • : I/O extraction
  • : Translations
  • : Plaintext Evaluation
  • : Import/Export

Distribution

This research was developed with funding from the Defense Advanced Research Projects Agency (DARPA) under Agreement No. HR001120C0084.

The views, opinions, and/or findings expressed are those of the author(s) and should not be interpreted as representing the official views or policies of the Department of Defense or the U.S. Government.

DISTRIBUTION STATEMENT A: Approved for public release, distribution unlimited.

mcircuit's People

Contributors

lisaoverall avatar jleightcap avatar woodruffw avatar artemdinaburg avatar ehennenfent avatar

Stargazers

Charlie B avatar  avatar Peter A. avatar STYLIANOS IORDANIS avatar Gontse Kekana avatar Jevin Sweval avatar ebigram avatar

Watchers

Fredrik Dahlgren avatar Jevin Sweval avatar James Cloos avatar feliam avatar  avatar David Pokora avatar Nick Selby avatar Trent Brunson avatar Alex Useche avatar  avatar Kelly Kaoudis avatar Tarun Bansal avatar Priyanka Bose avatar David Coursey avatar Broccolirob avatar Greg Otto avatar Gabrielle Beck avatar Marc Ilunga avatar alan avatar Talley Amir avatar Alan Chang avatar Damilola Edwards avatar Jaime Iglesias avatar  avatar

Forkers

stjordanis

mcircuit's Issues

Equivalent ingest of yosys-generated `.blif` and `.json`

For right now, our pipeline is required to pass though a tiny86.blif. BLIF compilation places reasonable constraints on the input HDL, is useful for CI verification, and as a common "interchange format". However, JSON ingestion is preferred for debugging because it includes source information, e.g.:

# ...
"syscall_x": {
  # ...
  "instr_len": {
    # ...
    "attributes": {
      "src": "circuit/tiny86.v:69.6-69.17",
      # ...
    }
  }
}
# ...

If ingesting yosys-produced JSON parses to the same impl Parser<T: WireValue>, this could feasibly be used to propagate Verilog source-level information to lower pipeline artifacts.

Refactor: numbered wires should be newtyped

Right now, the internal representation of our gates/operations is a big enum, with value variants that look like this:

/// Defines the individual logic gate operations we can support
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, VariantCount)]
pub enum Operation<T: WireValue> {
    /// Read a value from input and emit it on the wire
    Input(usize),
    /// Emit a random value on the wire
    Random(usize),
    /// Add the two wires together
    Add(usize, usize, usize),
    /// Add the wire and the constant
    AddConst(usize, usize, T),
    /// Subtract the final wire from the second wire
    Sub(usize, usize, usize),
    /// Subtract the constant value from the wire
    SubConst(usize, usize, T),
    /// Multiply the two wires together
    Mul(usize, usize, usize),
    /// Multiply the first wire by the constant value
    MulConst(usize, usize, T),
    /// Assert that the wire has the const value zero
    AssertZero(usize),
    /// Emit the const value on the wire
    Const(usize, T),
}

...where each usize is an identified wire. This is unambiguous in the current context (since constant values are represented by the T bound), but it's not ideal from a design perspective -- enumerated wires should instead by newtyped as Wire.

Low priority, since this will require a great deal of refactoring.

Define the export APIs with traits

Right now, the Bristol-fashion exporter API is just a collection of functions. We should make it a trait, so that different formats can implement it.

A rough sketch:

pub trait ExportFormat<T: WireValue> {
  fn export_gate(gate: &Operation<T>, sink: &mut impl Write) -> Result<()>;

  fn export_circuit(gates: &[Operation<T>], witness: &[T], sink: &mut impl Write) -> Result<()>;
}

Support exporting JSON (again)

Right now this functionality is marked as "private":

fn _gate_to_json<T: WireValue>(_gate: &Operation<T>) -> Value {
unimplemented!("JSON exporter is private for now");
}
pub fn bool_circuit_to_json(_gates: &[Operation<bool>], _bool_witness: &[bool]) -> Result<String> {
unimplemented!("JSON exporter is private for now");
}

We should support some kind of JSON export, for debugging/golden testing.

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.