Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/jimouris/helm
Browse files Browse the repository at this point in the history
  • Loading branch information
cgouert committed Sep 15, 2023
2 parents d817fd0 + 5308e18 commit e4b26fd
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 145 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">HELM <a href="https://github.com/jimouris/helm/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a> </h1>

<h2 align="center">HELM: Navigating Homomorphic Evaluation through Gates and Lookups</h2>
<h2 align="center">Navigating Homomorphic Evaluation through Gates and Lookups</h2>


## Overview
Expand All @@ -24,7 +24,7 @@ cargo test --release
### 2) HELM Command Line Arguments
```shell
-v, --verilog <FILE> Verilog input file to evaluate
-w, --input-wires <STRING> <HEX> Input wire values (-i wire1 hex1 -i wire2 hex2 ...)
-w, --input-wires <STRING> <STRING> <[NUM]> Input wire values (-w wire1 value1 [width1] -w wire2 value2 [width2]...)
-i, --input-wires-file <FILE> CSV file that contains the input wire values (wire, value)
-o, --output-wires-file <FILE> CSV file to write the output wires (wire, value)
-c, --cycles <NUMBER> Number of cycles for sequential circuits [default: 1]
Expand Down Expand Up @@ -58,6 +58,20 @@ cargo run --bin helm --release -- \
-w a[0] 1 -w a[1] 0 -w b[0] 0 -w b[1] 1 -w cin 0
```

Or equivalently as `wire_name hex_value wire_width`
```shell
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/2-bit-adder.v \
-w a 1 2 -w b[0] 0 -w b[1] 1 -w cin 0
```
The above expands `a` to `a[0] = 1` and `a[1] = 1`.

Similarly:
```shell
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/2-bit-adder.v \
-w a 1 2 -w b 2 2 -w cin 0
```

#### 3.2) Lookup Tables (LUT) Mode
Example in "LUTs"-mode:
Expand Down
242 changes: 175 additions & 67 deletions RUNNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,148 +4,256 @@
1. **16-bit**
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/16-bit-mult-gates.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-gates.v \
--input-wires-file ./hdl-benchmarks/test-cases/16-bit-mult.inputs.csv
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/16-bit-mult-gates.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-gates.v \
--input-wires-file ./hdl-benchmarks/test-cases/16-bit-mult.inputs.csv
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/16-bit-mult-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-lut-2-1.v \
--input-wires-file ./hdl-benchmarks/test-cases/16-bit-mult.inputs.csv
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/16-bit-mult-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-lut-2-1.v \
--input-wires-file ./hdl-benchmarks/test-cases/16-bit-mult.inputs.csv
```
3. **LUT w/o LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/16-bit-mult.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-arith.v \
--arithmetic
cargo run --bin helm --release -- --arithmetic u16 \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-arith.v \
-w G11 99 16 -w G12 4 16
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/16-bit-mult.v \
--output ./hdl-benchmarks/processed-netlists/16-bit-mult-arith.v \
--arithmetic
cargo run --bin helm --release -- --arithmetic u16 \
--verilog ./hdl-benchmarks/processed-netlists/16-bit-mult-arith.v \
-w G11 99 16 -w G12 4 16
```
2. Support for 32-bit, 64-bit, 128-bit.


## 2. Matrix Multiplication
1. 5x5 x 5x5
1. **5x5 x 5x5**
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/5x5_x_5x5_mmult_gates.v \
--output ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult_gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult_gates.v
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/5x5_x_5x5_mmult_gates.v \
--output ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult_gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult_gates.v
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/5x5_x_5x5_mmult-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult-lut-2-1.v
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/5x5_x_5x5_mmult-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult-lut-2-1.v
```
3. **LUT w/o LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/5x5_x_5x5-mmult.v \
--output ./hdl-benchmarks/processed-netlists/5x5_x_5x5-mmult-arith.v \
--arithmetic
cargo run --bin helm --release -- \
--arithmetic u16 \
--verilog ./hdl-benchmarks/processed-netlists/5x5_x_5x5_mmult-lut-2-1.v
```
2. Support for 10x10 x 10x10 and 15x15 x 15x15.


## 3. Chi squared
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/chi_squared_gates.v \
--output ./hdl-benchmarks/processed-netlists/chi_squared_gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/chi_squared_gates.v \
--input-wires-file ./hdl-benchmarks/test-cases/chi_squared_bin_1.inputs.csv
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/chi_squared-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/chi_squared-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/chi_squared-lut-2-1.v \
--input-wires-file ./hdl-benchmarks/test-cases/chi_squared_bin_1.inputs.csv
```
3. **LUT w/o LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/chi_squared.v \
--output ./hdl-benchmarks/processed-netlists/chi_squared_arith.v \
--arithmetic
cargo run --bin helm --release -- \
--arithmetic u32 \
--verilog ./hdl-benchmarks/processed-netlists/chi_squared_arith.v \
--input-wires-file ./hdl-benchmarks/test-cases/chi_squared_arith_1.inputs.csv
```

## 4. Euclidean Distance
1. `N = 32`
```shell
```
2. Support for `N = 64`.
1. `n = 32` Gates
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/v32_euclidean_gates.v \
--output ./hdl-benchmarks/processed-netlists/v32_euclidean_gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/v32_euclidean_gates.v
```
3. `n = 32` 2:1 LUT w/ LBB
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/v32_euclidean-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/v32_euclidean-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/v32_euclidean-lut-2-1.v
```
4. `n = 32` LUT w/o LBB
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/v32-euclidean-distance.v \
--output ./hdl-benchmarks/processed-netlists/v32_euclidean-arith.v \
--arithmetic
cargo run --bin helm --release -- \
--arithmetic u32
--verilog ./hdl-benchmarks/processed-netlists/v32_euclidean-arith.v
```
5. Support for `n = 64`.


## 5. CRC-32
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/crc-32-gates.v \
--output ./hdl-benchmarks/processed-netlists/crc-32-gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/crc-32-gates.v
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/crc32-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/crc32-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/crc32-lut-2-1.v
```

## 6. AES
1. AES Core
1. **AES Core**
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/aes_core_gates.v \
--output ./hdl-benchmarks/processed-netlists/aes_core_gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/aes_core_gates.v \
--input-wires-file ./hdl-benchmarks/test-cases/aes.inputs.csv
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/aes-core-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/aes-core-lut-2-1.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/aes-core-lut-2-1.v \
--input-wires-file ./hdl-benchmarks/test-cases/aes.inputs.csv
```
2. Support for AES-128 with Key Scheduling and AES-128 without Key Scheduling.


## 7. Box Blur and Gaussian Blur
1. Box Blur
1. **Gaussian Blur**
1. **Gates**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/r45-c66-gaussian-blur-gates.v \
--output ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-gates.v
```
2. **LUT w/ LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/r45-c66-gaussian-blur-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-gates.v
cargo run --bin helm --release -- \
--verilog ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-lut-2-1.v
```
3. **LUT w/o LBB**
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/designs/r45_c66-blur.v \
--output ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-arith.v \
--arithmetic
cargo run --bin helm --release -- \
--arithmetic u8
--verilog ./hdl-benchmarks/processed-netlists/r45-c66-gaussian-blur-arith.v \
--input-wires-file ./hdl-benchmarks/test-cases/r45-c66-gaussian-blur.inputs.csv
```
2. Support for Gaussian Blur.


## 9. ISCAS'85
1. c1355
1. **c1355**
1. **Gates**
```shell
```
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/c1355.v \
--output ./hdl-benchmarks/processed-netlists/c1355.v
cargo run --bin helm --release -- --verilog ./hdl-benchmarks/processed-netlists/c1355.v
```
2. **LUT w/ LBB**
```shell
```
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/c1355-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/c1355-lut-2-1.v
cargo run --bin helm --release -- --verilog ./hdl-benchmarks/processed-netlists/c1355-lut-2-1.v
```
2. Support for c1908, c2670, c3540, c5315, c6288, c7552.


## 10. ISCAS'89
1. s386,
1. **s386**
1. **Gates**
```shell
```
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/s386.v \
--output ./hdl-benchmarks/processed-netlists/s386.v
cargo run --bin helm --release -- --verilog ./hdl-benchmarks/processed-netlists/s386.v --cycles 1
```
2. **LUT w/ LBB**
```shell
```
```shell
cargo run --bin preprocessor --release \
--manifest-path=./hdl-benchmarks/Cargo.toml -- \
--input ./hdl-benchmarks/netlists/s386-lut-2-1.v \
--output ./hdl-benchmarks/processed-netlists/s386-lut-2-1.v
cargo run --bin helm --release -- --verilog ./hdl-benchmarks/processed-netlists/s386-lut-2-1.v --cycles 1
```
2. Support for s510, s1196, s5378, s9234, s13207, s15850.
2 changes: 1 addition & 1 deletion hdl-benchmarks
Submodule hdl-benchmarks updated 43 files
+12 −1 README.md
+5,006 −0 designs/10x10_x_10x10-mmult.v
+15,306 −0 designs/15x15_x_15x15-mmult.v
+5 −0 designs/16-bit-mult.v
+731 −0 designs/5x5_x_5x5-mmult.v
+85,618 −0 designs/r45_c66-blur.v
+161 −161 designs/v32-euclidean-distance.v
+1 −0 designs/v64-euclidean-distance.v
+4,877 −0 netlists/16-bit-mult-gates.v
+5,627 −0 netlists/16-bit-mult-lut-2-1.v
+790,788 −0 netlists/5x5_x_5x5_mmult-lut-2-1.v
+669,130 −0 netlists/5x5_x_5x5_mmult_gates.v
+117,795 −0 netlists/aes-core-lut-2-1.v
+1,489,166 −0 netlists/aes-lut-2-1.v
+1,221,862 −0 netlists/aes-no-kex-lut-2-1.v
+111,609 −0 netlists/aes_core_gates.v
+1,415,707 −0 netlists/aes_decryptor_gates.v
+1,154,130 −0 netlists/aes_no_kex_gates.v
+1,543 −0 netlists/c1355-lut-2-1.v
+1,527 −0 netlists/c1908-lut-2-1.v
+4,473 −0 netlists/c2670-lut-2-1.v
+5,854 −0 netlists/c3540-lut-2-1.v
+10,170 −0 netlists/c5315-lut-2-1.v
+12,504 −0 netlists/c6288-lut-2-1.v
+8,644 −0 netlists/c7552-lut-2-1.v
+136,657 −0 netlists/chi_squared-lut-2-1.v
+119,601 −0 netlists/chi_squared_gates.v
+5,315 −0 netlists/crc-32-gates.v
+5,451 −0 netlists/crc32-lut-2-1.v
+4,108,807 −0 netlists/r45-c66-gaussian-blur-gates.v
+4,505,921 −0 netlists/r45-c66-gaussian-blur-lut-2-1.v
+3,457 −0 netlists/s1196-lut-2-1.v
+18,965 −0 netlists/s13207-lut-2-1.v
+15,725 −0 netlists/s15850-lut-2-1.v
+961 −0 netlists/s386-lut-2-1.v
+1,698 −0 netlists/s510-lut-2-1.v
+10,305 −0 netlists/s5378-lut-2-1.v
+10,585 −0 netlists/s9234-lut-2-1.v
+783,983 −0 netlists/v32_euclidean-lut-2-1.v
+722,538 −0 netlists/v32_euclidean_gates.v
+379 −0 processed-netlists/5x5_x_5x5-mmult-arith.v
+257 −0 test-cases/aes.inputs.csv
+2,972 −0 test-cases/r45_c66-blur.inputs.csv
3 changes: 2 additions & 1 deletion src/bin/helm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use helm::{ascii, circuit, circuit::EvalCircuit, verilog_parser};
use std::time::Instant;
use termion::color;
use tfhe::{
boolean::gen_keys, generate_keys, shortint::parameters::PARAM_MESSAGE_1_CARRY_1_KS_PBS, ConfigBuilder,
boolean::gen_keys, generate_keys, shortint::parameters::PARAM_MESSAGE_1_CARRY_1_KS_PBS,
ConfigBuilder,
};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,4 +1085,4 @@ impl<'a> EvalCircuit<CtxtShortInt> for HighPrecisionLutCircuit<'a> {

decrypted_outputs
}
}
}
Loading

0 comments on commit e4b26fd

Please sign in to comment.