-
Notifications
You must be signed in to change notification settings - Fork 39
Make MaxWidthCellManager work with fixed signals - Issue #97 #135
Changes from 4 commits
218a047
87503ea
dd602f0
1d4f872
dbc8cc8
8479b41
85d26f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,24 +231,26 @@ impl CellManager for SingleRowCellManager { | |
|
||
#[derive(Debug, Default, Clone)] | ||
pub struct MaxWidthCellManager { | ||
max_width: usize, | ||
max_width_advice: usize, | ||
max_width_fixed: usize, | ||
same_height: bool, | ||
} | ||
|
||
impl MaxWidthCellManager { | ||
pub fn new(max_width: usize, same_height: bool) -> Self { | ||
pub fn new(max_width_advice: usize, max_width_fixed: usize, same_height: bool) -> Self { | ||
Self { | ||
max_width, | ||
max_width_advice, | ||
max_width_fixed, | ||
same_height, | ||
} | ||
} | ||
} | ||
|
||
impl CellManager for MaxWidthCellManager { | ||
fn place<F>(&self, unit: &mut CompilationUnit<F>) { | ||
if (!unit.shared_signals.is_empty() || !unit.fixed_signals.is_empty()) && !self.same_height | ||
if (!unit.shared_signals.is_empty()) && !self.same_height | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atsupontio this must be kept. Fixed signals should not work when same_height is disabled |
||
{ | ||
panic!("Shared signals and fixed signals are not supported for MaxWidthCellManager, which might return steps with variable heights."); | ||
panic!("Shared signals are not supported for MaxWidthCellManager, which might return steps with variable heights."); | ||
} | ||
|
||
let mut placement = Placement { | ||
|
@@ -287,7 +289,7 @@ impl CellManager for MaxWidthCellManager { | |
); | ||
|
||
forward_signal_column += 1; | ||
if forward_signal_column >= self.max_width { | ||
if forward_signal_column >= self.max_width_advice { | ||
forward_signal_column = 0; | ||
forward_signal_row += 1; | ||
} | ||
|
@@ -299,6 +301,48 @@ impl CellManager for MaxWidthCellManager { | |
forward_signal_row | ||
} as u32; | ||
|
||
|
||
|
||
let mut fixed_signal_column: usize = 0; | ||
let mut fixed_signal_row: usize = 0; | ||
|
||
for fixed_signal in unit.fixed_signals.iter() { | ||
let column = if placement.columns.len() <= fixed_signal_column { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atsupontio you should add some tests, this will not work. Because placement.columns contains both advice and fixed signals, if there are both, for example when |
||
let column = if let Some(annotation) = unit.annotations.get(&fixed_signal.uuid()) | ||
{ | ||
Column::fixed(format!("mwcm fixed signal {}", annotation)) | ||
} else { | ||
Column::fixed("mwcm fixed signal") | ||
}; | ||
|
||
placement.columns.push(column.clone()); | ||
column | ||
} else { | ||
placement.columns[fixed_signal_column].clone() | ||
}; | ||
|
||
placement.fixed.insert( | ||
*fixed_signal, | ||
SignalPlacement { | ||
column, | ||
rotation: fixed_signal_row as i32, | ||
}, | ||
); | ||
|
||
fixed_signal_column += 1; | ||
if fixed_signal_column >= self.max_width_fixed { | ||
fixed_signal_column = 0; | ||
fixed_signal_row += 1; | ||
} | ||
} | ||
|
||
placement.base_height = if fixed_signal_column != 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atsupontio what if there is more rows in the advice than in the fixed? |
||
fixed_signal_row + 1 | ||
} else { | ||
fixed_signal_row | ||
} as u32; | ||
|
||
|
||
for step in unit.step_types.values() { | ||
let mut step_placement = StepPlacement { | ||
height: if forward_signal_column > 0 { | ||
|
@@ -337,7 +381,7 @@ impl CellManager for MaxWidthCellManager { | |
step_placement.height = (internal_signal_row + 1) as u32; | ||
|
||
internal_signal_column += 1; | ||
if internal_signal_column >= self.max_width { | ||
if internal_signal_column >= self.max_width_advice { | ||
internal_signal_column = 0; | ||
internal_signal_row += 1; | ||
} | ||
|
@@ -402,7 +446,8 @@ mod tests { | |
// forward signals: a, b; step1 internal: c1, d, e; step2 internal c2 | ||
|
||
let cm = MaxWidthCellManager { | ||
max_width: 2, | ||
max_width_advice: 2, | ||
max_width_fixed: 2, | ||
same_height: false, | ||
}; | ||
|
||
|
@@ -472,7 +517,8 @@ mod tests { | |
// forward signals: a, b; step1 internal: c1, d, e; step2 internal c2 | ||
|
||
let cm = MaxWidthCellManager { | ||
max_width: 2, | ||
max_width_advice: 2, | ||
max_width_fixed: 2, | ||
same_height: true, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atsupontio I think it would be better if run the example with both Cell Managers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leolara Thank you!
I'll fix it!