-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a component that can derive assignments and other code on identities and multiple rows. It keeps track of which cells in the trace are already known and which not. The way to access fixed rows is abstracted because it does not have a concept of an absolute row. While this might work for block machines with cyclic fixed columns, it does not work in the general case. What it does not do: - have a sequence of which identities to consider on which rows - a mechanism that determines when it is finished --------- Co-authored-by: Georg Wiese <[email protected]>
- Loading branch information
1 parent
2aa7f83
commit e3c4c85
Showing
6 changed files
with
673 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use std::{ | ||
fmt::{self, Display, Formatter}, | ||
hash::{Hash, Hasher}, | ||
}; | ||
|
||
use powdr_ast::analyzed::AlgebraicReference; | ||
|
||
/// The identifier of a witness cell in the trace table. | ||
/// The `row_offset` is relative to a certain "zero row" defined | ||
/// by the component that uses this data structure. | ||
#[derive(Debug, Clone, Eq)] | ||
pub struct Cell { | ||
/// Name of the column, used only for display purposes. | ||
pub column_name: String, | ||
pub id: u64, | ||
pub row_offset: i32, | ||
} | ||
|
||
impl Hash for Cell { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.id.hash(state); | ||
self.row_offset.hash(state); | ||
} | ||
} | ||
|
||
impl PartialEq for Cell { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.id == other.id && self.row_offset == other.row_offset | ||
} | ||
} | ||
|
||
impl Ord for Cell { | ||
fn cmp(&self, other: &Self) -> std::cmp::Ordering { | ||
(self.id, self.row_offset).cmp(&(other.id, other.row_offset)) | ||
} | ||
} | ||
|
||
impl PartialOrd for Cell { | ||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | ||
Some(self.cmp(other)) | ||
} | ||
} | ||
|
||
impl Cell { | ||
pub fn from_reference(r: &AlgebraicReference, row_offset: i32) -> Self { | ||
assert!(r.is_witness()); | ||
Self { | ||
column_name: r.name.clone(), | ||
id: r.poly_id.id, | ||
row_offset: r.next as i32 + row_offset, | ||
} | ||
} | ||
} | ||
|
||
impl Display for Cell { | ||
fn fmt(&self, f: &mut Formatter) -> fmt::Result { | ||
write!(f, "{}[{}]", self.column_name, self.row_offset) | ||
} | ||
} |
Oops, something went wrong.