Skip to content

Commit

Permalink
Move everything latency counting related to latency/
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Feb 16, 2025
1 parent 9ea5a21 commit c75792d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/flattening/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod initialization;
mod lints;
mod name_context;
mod parser;
mod port_latency_inference;
mod typechecking;
mod walk;

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

use crate::latency::port_latency_inference::PortLatencyInferenceInfo;
pub use flatten::flatten_all_globals;
pub use initialization::gather_initial_file_data;
pub use lints::perform_lints;
use port_latency_inference::PortLatencyInferenceInfo;
pub use typechecking::typecheck_all_modules;

use crate::linker::{Documentation, LinkInfo};
Expand Down Expand Up @@ -327,6 +326,8 @@ pub enum WireReferenceRoot {
/// int local_var
/// local_var = 3
/// ```
///
/// [FlatID] points to [Instruction::Declaration]
LocalDecl(FlatID, Span),
/// ```sus
/// bool b = true // root is global constant `true`
Expand Down
31 changes: 13 additions & 18 deletions src/instantiation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
mod concrete_typecheck;
mod execute;
mod latency_algorithm;
mod latency_count;
mod list_of_lists;
mod unique_names;

use unique_names::UniqueNames;
Expand All @@ -24,8 +21,6 @@ use crate::{

use crate::typing::concrete_type::ConcreteType;

use self::latency_algorithm::SpecifiedLatency;

// Temporary value before proper latency is given
pub const CALCULATE_LATENCY_LATER: i64 = i64::MIN;

Expand All @@ -38,7 +33,7 @@ pub enum RealWirePathElem {
}

impl RealWirePathElem {
fn for_each_wire_in_path(path: &[RealWirePathElem], mut f: impl FnMut(WireID)) {
pub fn for_each_wire_in_path(path: &[RealWirePathElem], mut f: impl FnMut(WireID)) {
for v in path {
match v {
RealWirePathElem::ArrayAccess { span: _, idx_wire } => {
Expand Down Expand Up @@ -318,24 +313,24 @@ pub struct ConditionStackElem {
}

/// As with other contexts, this is the shared state we're lugging around while executing & typechecking a module.
struct InstantiationContext<'fl, 'l> {
name: String,
generation_state: GenerationState<'fl>,
wires: FlatAlloc<RealWire, WireIDMarker>,
submodules: FlatAlloc<SubModule, SubModuleIDMarker>,
pub struct InstantiationContext<'fl, 'l> {
pub name: String,
pub wires: FlatAlloc<RealWire, WireIDMarker>,
pub submodules: FlatAlloc<SubModule, SubModuleIDMarker>,

type_substitutor: TypeSubstitutor<ConcreteType, ConcreteTypeVariableIDMarker>,
pub type_substitutor: TypeSubstitutor<ConcreteType, ConcreteTypeVariableIDMarker>,

// Used for Execution
/// Used for Execution
generation_state: GenerationState<'fl>,
unique_name_producer: UniqueNames,
condition_stack: Vec<ConditionStackElem>,

interface_ports: FlatAlloc<Option<InstantiatedPort>, PortIDMarker>,
errors: ErrorCollector<'l>,
pub interface_ports: FlatAlloc<Option<InstantiatedPort>, PortIDMarker>,
pub errors: ErrorCollector<'l>,

template_args: &'fl TVec<ConcreteType>,
md: &'fl Module,
linker: &'l Linker,
pub template_args: &'fl TVec<ConcreteType>,
pub md: &'fl Module,
pub linker: &'l Linker,
}

/// Mangle the module name for use in code generation
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 9 additions & 6 deletions src/instantiation/latency_count.rs → src/latency/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
mod latency_algorithm;
mod list_of_lists;
pub mod port_latency_inference;

use std::{cmp::max, iter::zip};

use crate::prelude::*;

use crate::{
flattening::{Instruction, WriteModifiers},
instantiation::latency_algorithm::{
convert_fanin_to_fanout, solve_latencies, FanInOut, LatencyCountingError,
},
use crate::flattening::{Instruction, WriteModifiers};

use latency_algorithm::{
convert_fanin_to_fanout, solve_latencies, FanInOut, LatencyCountingError, SpecifiedLatency,
};

use self::list_of_lists::ListOfLists;

use super::*;
use crate::instantiation::*;

struct PathMuxSource<'s> {
to_wire: &'s RealWire,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::{
value::Value,
};

use super::{BinaryOperator, Instruction, Port, UnaryOperator, WireReference, WireReferenceRoot};
use crate::flattening::{
BinaryOperator, Instruction, Port, UnaryOperator, WireReference, WireReferenceRoot,
};

/*/// ports whose latency annotations require them to be at fixed predefined offsets
///
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod errors;
mod file_position;
mod flattening;
mod instantiation;
mod latency;
mod prelude;
mod to_string;
mod typing;
Expand Down
6 changes: 6 additions & 0 deletions test.sus
Original file line number Diff line number Diff line change
Expand Up @@ -1118,3 +1118,9 @@ module IfTesting #(int WIDTH) {
} else when WIDTH > BASE_CASE_SIZE {
}
}

module test {
gen int[2] p

int zsda = p[0]
}

0 comments on commit c75792d

Please sign in to comment.