Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"halo2",
"backend",
"bberg",
"bberg_pil_cli",
"ast",
"analysis",
"linker",
Expand Down
42 changes: 42 additions & 0 deletions bberg_pil_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

[package]
name = "bberg_bin_cli"
version = "0.1.0"
authors = ["Maddiaa"]
edition = "2021"

[[bin]]
name = "bberg_pil"
path = "src/main.rs"

[dependencies]
clap = { version = "^4.3", features = ["derive"] }
asm_utils = { path = "../asm_utils" }
compiler = { path = "../compiler" }
num-bigint = "0.4.3"

number = { path = "../number" }
pil_analyzer = { path = "../pil_analyzer" }
num-traits = "0.2.15"
num-integer = "0.1.45"
itertools = "^0.10"
log = "0.4.17"
rand = "0.8.5"
ast = { version = "0.1.0", path = "../ast" }


# TODO: we probably want to pull in the local version of nargo while i am working on it here

# Include acvm brillig module such that we can serialise and deserialise them
acvm = { git = "https://github.com/noir-lang/noir", directory = "acvm-repo/acvm" }
base64 = "*"

[dev-dependencies]
importer = { path = "../importer" }
analysis = { path = "../analysis" }
executor = { path = "../executor" }
parser = { path = "../parser" }
test-log = "0.2.12"
env_logger = "0.10.0"
linker = { path = "../linker" }

3 changes: 3 additions & 0 deletions bberg_pil_cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## BBERG PIL CLI
A small wrapper around powdr pil that only implements the parts of powdr required for direct pil -> bberg codegen

42 changes: 42 additions & 0 deletions bberg_pil_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::{io, path::Path};

use clap::Parser;
use compiler::{compile_pil, inputs_to_query_callback, BackendType};
use number::Bn254Field;

#[derive(Parser)]
#[command(name = "bberg_pil", author, version, about, long_about = None)]
struct Cli {
/// Input file
file: String,

/// Output directory for the PIL file, json file and fixed and witness column data.
#[arg(short, long)]
#[arg(default_value_t = String::from("."))]
output_directory: String,

/// BBerg: Name of the output file for bberg
#[arg(long)]
name: Option<String>,
}

fn main() -> Result<(), io::Error> {
let args = Cli::parse();

let file_name = args.file;
let output_dir = Path::new(&args.output_directory);
let name = args.name;
let inputs: Vec<Bn254Field> = Vec::new();
let prove_with = Some(BackendType::BBerg);
let external_witness_values = Vec::new();

compile_pil(
Path::new(&file_name),
output_dir,
inputs_to_query_callback(inputs),
prove_with,
external_witness_values,
name,
);
Ok(())
}
2 changes: 1 addition & 1 deletion compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn compile<T: FieldElement, Q: QueryCallback<T>>(
&constants,
&witness_in_powdr_form,
None,
None,
bname,
);
}

Expand Down
15 changes: 9 additions & 6 deletions test_data/pil/fibonacci.pil
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ constant %N = 16;
// This uses the alternative nomenclature as well.

namespace Fibonacci(%N);
col fixed ISLAST(i) { match i {
col fixed LAST(i) { match i {
%N - 1 => 1,
0 => 1, // also added is last at the beginning to make the empty shifts work
_ => 0,
} };
col fixed FIRST(i) { match i {
0 => 1,
_ => 0,
} };
col witness x, y;

ISLAST * (y' - 1) = 0;
ISLAST * (x' - 1) = 0;
LAST * (y' - 1) = 0;
LAST * (x' - 1) = 0;

(1-ISLAST) * (x' - y) = 0;
(1-ISLAST) * (y' - (x + y)) = 0;
(1-LAST) * (x' - y) = 0;
(1-LAST) * (y' - (x + y)) = 0;


public out = y(%N-1);