Skip to content

Commit c75792d

Browse files
committed
Move everything latency counting related to latency/
1 parent 9ea5a21 commit c75792d

File tree

8 files changed

+35
-27
lines changed

8 files changed

+35
-27
lines changed

src/flattening/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ mod initialization;
33
mod lints;
44
mod name_context;
55
mod parser;
6-
mod port_latency_inference;
76
mod typechecking;
87
mod walk;
98

@@ -15,10 +14,10 @@ use crate::typing::type_inference::{DomainVariableIDMarker, TypeVariableIDMarker
1514
use std::cell::OnceCell;
1615
use std::ops::Deref;
1716

17+
use crate::latency::port_latency_inference::PortLatencyInferenceInfo;
1818
pub use flatten::flatten_all_globals;
1919
pub use initialization::gather_initial_file_data;
2020
pub use lints::perform_lints;
21-
use port_latency_inference::PortLatencyInferenceInfo;
2221
pub use typechecking::typecheck_all_modules;
2322

2423
use crate::linker::{Documentation, LinkInfo};
@@ -327,6 +326,8 @@ pub enum WireReferenceRoot {
327326
/// int local_var
328327
/// local_var = 3
329328
/// ```
329+
///
330+
/// [FlatID] points to [Instruction::Declaration]
330331
LocalDecl(FlatID, Span),
331332
/// ```sus
332333
/// bool b = true // root is global constant `true`

src/instantiation/mod.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
mod concrete_typecheck;
22
mod execute;
3-
mod latency_algorithm;
4-
mod latency_count;
5-
mod list_of_lists;
63
mod unique_names;
74

85
use unique_names::UniqueNames;
@@ -24,8 +21,6 @@ use crate::{
2421

2522
use crate::typing::concrete_type::ConcreteType;
2623

27-
use self::latency_algorithm::SpecifiedLatency;
28-
2924
// Temporary value before proper latency is given
3025
pub const CALCULATE_LATENCY_LATER: i64 = i64::MIN;
3126

@@ -38,7 +33,7 @@ pub enum RealWirePathElem {
3833
}
3934

4035
impl RealWirePathElem {
41-
fn for_each_wire_in_path(path: &[RealWirePathElem], mut f: impl FnMut(WireID)) {
36+
pub fn for_each_wire_in_path(path: &[RealWirePathElem], mut f: impl FnMut(WireID)) {
4237
for v in path {
4338
match v {
4439
RealWirePathElem::ArrayAccess { span: _, idx_wire } => {
@@ -318,24 +313,24 @@ pub struct ConditionStackElem {
318313
}
319314

320315
/// As with other contexts, this is the shared state we're lugging around while executing & typechecking a module.
321-
struct InstantiationContext<'fl, 'l> {
322-
name: String,
323-
generation_state: GenerationState<'fl>,
324-
wires: FlatAlloc<RealWire, WireIDMarker>,
325-
submodules: FlatAlloc<SubModule, SubModuleIDMarker>,
316+
pub struct InstantiationContext<'fl, 'l> {
317+
pub name: String,
318+
pub wires: FlatAlloc<RealWire, WireIDMarker>,
319+
pub submodules: FlatAlloc<SubModule, SubModuleIDMarker>,
326320

327-
type_substitutor: TypeSubstitutor<ConcreteType, ConcreteTypeVariableIDMarker>,
321+
pub type_substitutor: TypeSubstitutor<ConcreteType, ConcreteTypeVariableIDMarker>,
328322

329-
// Used for Execution
323+
/// Used for Execution
324+
generation_state: GenerationState<'fl>,
330325
unique_name_producer: UniqueNames,
331326
condition_stack: Vec<ConditionStackElem>,
332327

333-
interface_ports: FlatAlloc<Option<InstantiatedPort>, PortIDMarker>,
334-
errors: ErrorCollector<'l>,
328+
pub interface_ports: FlatAlloc<Option<InstantiatedPort>, PortIDMarker>,
329+
pub errors: ErrorCollector<'l>,
335330

336-
template_args: &'fl TVec<ConcreteType>,
337-
md: &'fl Module,
338-
linker: &'l Linker,
331+
pub template_args: &'fl TVec<ConcreteType>,
332+
pub md: &'fl Module,
333+
pub linker: &'l Linker,
339334
}
340335

341336
/// Mangle the module name for use in code generation
File renamed without changes.

src/instantiation/latency_count.rs renamed to src/latency/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
mod latency_algorithm;
2+
mod list_of_lists;
3+
pub mod port_latency_inference;
4+
15
use std::{cmp::max, iter::zip};
26

37
use crate::prelude::*;
48

5-
use crate::{
6-
flattening::{Instruction, WriteModifiers},
7-
instantiation::latency_algorithm::{
8-
convert_fanin_to_fanout, solve_latencies, FanInOut, LatencyCountingError,
9-
},
9+
use crate::flattening::{Instruction, WriteModifiers};
10+
11+
use latency_algorithm::{
12+
convert_fanin_to_fanout, solve_latencies, FanInOut, LatencyCountingError, SpecifiedLatency,
1013
};
1114

1215
use self::list_of_lists::ListOfLists;
1316

14-
use super::*;
17+
use crate::instantiation::*;
1518

1619
struct PathMuxSource<'s> {
1720
to_wire: &'s RealWire,

src/flattening/port_latency_inference.rs renamed to src/latency/port_latency_inference.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use crate::{
66
value::Value,
77
};
88

9-
use super::{BinaryOperator, Instruction, Port, UnaryOperator, WireReference, WireReferenceRoot};
9+
use crate::flattening::{
10+
BinaryOperator, Instruction, Port, UnaryOperator, WireReference, WireReferenceRoot,
11+
};
1012

1113
/*/// ports whose latency annotations require them to be at fixed predefined offsets
1214
///

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod errors;
99
mod file_position;
1010
mod flattening;
1111
mod instantiation;
12+
mod latency;
1213
mod prelude;
1314
mod to_string;
1415
mod typing;

test.sus

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,3 +1118,9 @@ module IfTesting #(int WIDTH) {
11181118
} else when WIDTH > BASE_CASE_SIZE {
11191119
}
11201120
}
1121+
1122+
module test {
1123+
gen int[2] p
1124+
1125+
int zsda = p[0]
1126+
}

0 commit comments

Comments
 (0)