Skip to content

Commit

Permalink
Merge branch 'main' into feature/frontend-backend-crates1
Browse files Browse the repository at this point in the history
  • Loading branch information
ed255 committed Feb 5, 2024
2 parents fb2e556 + bc30c46 commit 25666a4
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions halo2_frontend/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ mod graph;
#[cfg_attr(docsrs, doc(cfg(feature = "dev-graph")))]
pub use graph::{circuit_dot_graph, layout::CircuitLayout};

/// Region of assignments that are done during synthesis.
#[derive(Debug)]
struct Region {
pub struct Region {
/// The name of the region. Not required to be unique.
name: String,
/// The columns involved in this region.
Expand Down Expand Up @@ -86,6 +87,36 @@ impl Region {
}
self.rows = Some((start, end));
}

/// Returns the name of the region.
pub fn name(&self) -> &String {
&self.name
}

/// Returns the columns involved in this region.
pub fn columns(&self) -> &HashSet<Column<Any>> {
&self.columns
}

/// Returns the rows that this region starts and ends on, if known.
pub fn rows(&self) -> Option<(usize, usize)> {
self.rows
}

/// Returns the selectors that have been enabled in this region.
pub fn enabled_selectors(&self) -> &HashMap<Selector, Vec<usize>> {
&self.enabled_selectors
}

/// Returns the annotations given to Advice, Fixed or Instance columns within a region context.
pub fn annotations(&self) -> &HashMap<ColumnMetadata, String> {
&self.annotations
}

/// Returns the cells assigned in this region.
pub fn cells(&self) -> &HashMap<(Column<Any>, usize), usize> {
&self.cells
}
}

/// The value of a particular cell within the circuit.
Expand Down Expand Up @@ -332,7 +363,8 @@ pub enum InstanceValue<F: Field> {
}

impl<F: Field> InstanceValue<F> {
fn value(&self) -> F {
/// Field value on the instance cell
pub fn value(&self) -> F {
match self {
InstanceValue::Assigned(v) => *v,
InstanceValue::Padding => F::ZERO,
Expand Down Expand Up @@ -1246,6 +1278,11 @@ impl<F: FromUniformBytes<64> + Ord> MockProver<F> {
pub fn permutation(&self) -> &permutation::Assembly {
&self.permutation
}

/// Returns the Regions used during synthesis.
pub fn regions(&self) -> &[Region] {
&self.regions
}
}

#[cfg(test)]
Expand Down

0 comments on commit 25666a4

Please sign in to comment.