Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
cf4c82e
feat(runtime)!: wait for clock edges in process kernels with fused ticks
tignear Oct 9, 2026
5b223ee
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
166e4cc
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
fc4b0ab
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
310ddb6
fix(runtime): address review findings of the fused clock ticks
tignear Oct 10, 2026
8a2f684
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
3c21bab
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
74dc7cd
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
c9e9a03
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
9aad5d6
Merge branch 'feature/1123-vtest' into feature/1123-clock-waits
tignear Oct 10, 2026
117be45
Merge feature/1123-vtest into feature/1123-clock-waits
tignear Oct 11, 2026
78390ba
fix(runtime): preserve clock phases and simultaneous edge state
tignear Oct 11, 2026
fc0ee77
test(runtime): reject progress before a failed clock edge
tignear Oct 11, 2026
a0916fb
Merge updated feature/1123-vtest into feature/1123-clock-waits
tignear Oct 11, 2026
d24a8ac
fix(runtime): report tiered batch progress after the edge
tignear Oct 11, 2026
aca53d6
Merge latest timed-suite fixes into feature/1123-clock-waits
tignear Oct 11, 2026
fc2ed80
fix(native): version and validate process clock metadata
tignear Oct 12, 2026
841f160
Merge commit '9f6995686' into HEAD
tignear Oct 12, 2026
aed8e34
Merge commit '577836a19' into HEAD
tignear Oct 12, 2026
1cf29b0
Merge commit 'aeff36fb0' into HEAD
tignear Oct 12, 2026
b5fd626
fix(runtime): honor step limits and settle clock-sensitive low phases
tignear Oct 12, 2026
e2cc137
Merge bounded host-wake and queued-update fixes into clock waits
tignear Oct 12, 2026
aea6e7c
Merge commit 'ec24cf34821c3f26186f2bf71f1f775a79ca6815' into HEAD
tignear Oct 12, 2026
a2e9079
Merge commit 'b8ec51086839751c5ee0034b3f8be6606ebbb85b' into HEAD
tignear Oct 12, 2026
ca7e626
fix(runtime): reject conflicting clocks and validate edge advances at…
tignear Oct 12, 2026
4f46a87
fix(runtime): defer generated edges until clock wait resumptions
tignear Oct 12, 2026
a679802
Merge commit 'edc168aaf' into HEAD
tignear Oct 12, 2026
eb4ecf7
Merge commit '870cb1ff4' into HEAD
tignear Oct 12, 2026
94d8523
Merge commit '5d89e754d' into HEAD
tignear Oct 12, 2026
e04ad42
Merge commit '781cf3e20' into HEAD
tignear Oct 12, 2026
b57cd01
fix(runtime): retain generated clock progress across phase failures
tignear Oct 12, 2026
8cec152
Merge commit '246a74cd5' into HEAD
tignear Oct 12, 2026
75968b6
test(native): check pre-edge failure progress with lane kernels
tignear Oct 12, 2026
ea9a178
Merge commit '1515e0af2' into HEAD
tignear Oct 12, 2026
3265fda
fix(runtime): reject scheduled clock drivers and retry unpublished falls
tignear Oct 12, 2026
470aa98
Merge commit '371ff0c29' into HEAD
tignear Oct 12, 2026
d5efa1f
Merge commit '202cc9f23' into HEAD
tignear Oct 12, 2026
c075dfd
Merge commit '049e5d735' into HEAD
tignear Oct 12, 2026
9692f11
fix(runtime): restore same-time clock drive provenance
tignear Oct 12, 2026
85bfb8c
Merge commit 'bcce47be4' into HEAD
tignear Oct 12, 2026
4df0b60
Merge commit 'bdf1746da' into HEAD
tignear Oct 12, 2026
4465425
Merge commit '715b311b8' into HEAD
tignear Oct 12, 2026
4e3aef4
Merge commit '4da2d0e8749168312a04fa431671c88cf5745fab' into HEAD
tignear Oct 12, 2026
944ee21
fix(runtime): batch newly activated clocks with coincident domains
tignear Oct 12, 2026
62f4766
Merge commit 'b886ae2fc74d88b6a6aa3eb572389539fd4ffd94' into HEAD
tignear Oct 12, 2026
737167d
fix(runtime): retain clock progress and native image invariants
tignear Oct 12, 2026
504fe09
fix(runtime): suppress overflowing edges after coincident finish
tignear Oct 12, 2026
dc487f0
Merge commit '488ad2abe32ebdbf4d5cc1afcecea5007ed452dd' into HEAD
tignear Oct 12, 2026
148c4e6
Merge commit '80c5b89450be26adad0eb61359d9a12cad970151' into HEAD
tignear Oct 12, 2026
6afb3a4
Merge validated SV and timed-suite review fixes from #1159
tignear Oct 12, 2026
fe4ae00
Merge commit '5da31b787077858e284a6420a1ff7e8ea86c9f75' into HEAD
tignear Oct 12, 2026
f5d75fc
fix(runtime): retain generated clock coincidence and exported drive p…
tignear Oct 13, 2026
04a73a1
Merge timed-suite fixes and current master contracts
tignear Oct 13, 2026
8579425
Merge scoped callable and byte-output follow-ups
tignear Oct 13, 2026
f84c3a2
Merge commit '28c48234afe7396d5f6563054d5ab045e14cdd31' into HEAD
tignear Oct 13, 2026
ecc7122
Merge commit '803f117db' into HEAD
tignear Oct 13, 2026
60fcf54
Merge commit '5eea0ccd6e3aa33b9ddb4d088f886a9b02debb34' into HEAD
tignear Oct 13, 2026
f3446a4
style: format clock wait review regressions
tignear Oct 13, 2026
7510686
test(runtime): count clock edges in the retry regression
tignear Oct 13, 2026
3553fb0
Merge commit '8a1ca30e6fb84d42a68fb92e8a7fecc247ec159b' into HEAD
tignear Oct 13, 2026
511aad8
fix(runtime): bound clock settling and reject host drives with accura…
tignear Oct 13, 2026
d71fabc
Merge commit 'b9f8483c3' into HEAD
tignear Oct 13, 2026
011196f
Merge commit '7d9a1ae74' into HEAD
tignear Oct 13, 2026
d4945a5
fix(runtime): settle target-time clock falls and normalize unknown le…
tignear Oct 13, 2026
66273b5
Merge commit '922fd8c49' into HEAD
tignear Oct 13, 2026
5452bdf
Merge commit '48ae93696' into HEAD
tignear Oct 13, 2026
69c579f
Merge commit 'bf1868619fdc4ebf8f4fd53b1216080608603f0a' into HEAD
tignear Oct 13, 2026
2ba62a3
Merge commit '5d600d409b8274626950a1da91f6b01cef6bbfa0' into HEAD
tignear Oct 13, 2026
512ead9
fix(runtime): retain and retry normalizing clock falls
tignear Oct 13, 2026
2315b14
Merge commit 'eeb06ce62' into HEAD
tignear Oct 14, 2026
e88f385
fix(runtime): keep generated edge retries in their scheduled batches
tignear Oct 14, 2026
021ac9c
Merge commit 'ce623993f' into HEAD
tignear Oct 14, 2026
77d4152
fix(testbench): preserve zero-progress FF failure diagnostics
tignear Oct 14, 2026
7fef3f6
Merge commit '1a729ecdd' into HEAD
tignear Oct 14, 2026
1fbec40
test(runtime): register competing clocks at a valid current time
tignear Oct 14, 2026
6c48c46
Merge commit '5c77e10b7' into HEAD
tignear Oct 14, 2026
89acc27
Merge commit '843e54d6a' into HEAD
tignear Oct 14, 2026
752cc65
fix(runtime): bound coincident host edges in timed runs
tignear Oct 14, 2026
e99f7ac
Merge commit '5db4882a6' into HEAD
tignear Oct 14, 2026
40f6f96
Merge commit '721d8a05f' into HEAD
tignear Oct 14, 2026
fc4c612
Merge commit 'b5bc0adec' into HEAD
tignear Oct 14, 2026
d4d5ed4
fix(runtime): return the time reached by coincident steps
tignear Oct 14, 2026
da7b239
Merge commit '645921688' into HEAD
tignear Oct 14, 2026
f7e8574
Merge commit 'c427930998b075770abc5c28fc697e8a23c0de58' into HEAD
tignear Oct 14, 2026
fe70e04
fix(runtime): bound immediate zero-count clock continuations
tignear Oct 14, 2026
a3f6c03
Merge commit '70b902ce37ca62a72b3af7b8ec5c5452efcbc91b' into HEAD
tignear Oct 14, 2026
84ccbf5
Merge commit '8612b020e3317eff71953bc1e81474dd6d81888e' into HEAD
tignear Oct 14, 2026
e736c76
Merge commit 'f6315c58bc73c433e5bbb884e3387de0f334b810' into HEAD
tignear Oct 14, 2026
894b8c7
Merge commit '9fa23635b19a24dc5c5381991abc8046ffb35970' into HEAD
tignear Oct 14, 2026
a1d7aea
Merge commit 'c904573ac' into HEAD
tignear Oct 14, 2026
3fa2116
Merge commit '81929f9e52883b21dde4291a7c93c160052b4723' into HEAD
tignear Oct 14, 2026
8d287c5
Merge commit '303c9fe640174649c201efed5c09f01bed4f07aa' into HEAD
tignear Oct 14, 2026
8056fb8
Merge commit '7fab93845' into HEAD
tignear Oct 14, 2026
3162923
fix(runtime): batch derived process edges and reject aliased clock dr…
tignear Oct 14, 2026
98ef56b
Merge commit '576ed7215fb9a4e6b04de42bf628f684742cbe7e' into HEAD
tignear Oct 14, 2026
a2bcf6a
fix(native): bind process clock controls to compiled kernels
tignear Oct 14, 2026
8ccbe3a
Merge commit '6c88018f1' into HEAD
tignear Oct 14, 2026
64f5239
Merge commit '8ed1f9ec5' into HEAD
tignear Oct 14, 2026
0f7b79b
Merge commit 'f1e05de4b' into HEAD
tignear Oct 14, 2026
6d5f980
fix(runtime): bind native clock metadata and detect escaped clock writes
tignear Oct 14, 2026
74e51ca
Merge commit '4bb5c8505d' into HEAD
tignear Oct 14, 2026
7d09896
fix(runtime): reject checkpoints with escaped clock mutations
tignear Oct 14, 2026
6178a7c
Merge commit '47ee213b13a678176d1c64d387a42e2b452795fa' into HEAD
tignear Oct 14, 2026
3a6b3ce
Merge commit '4d7ae3e978591034117bf05c5f6589a4985d67f3' into HEAD
tignear Oct 14, 2026
8aa0ed5
Merge commit 'b8a2e153c' into HEAD
tignear Oct 14, 2026
0b5300e
fix(runtime): batch captured host edges with clock activation
tignear Oct 14, 2026
268c1c4
Merge commit 'a650205c4769c5169464a80737a90cb958d554e1' into HEAD
tignear Oct 14, 2026
8162bb7
Merge commit '43f6646a7c09edf27fd2602eb8f5e4f489388883' into HEAD
tignear Oct 14, 2026
80e4e97
fix(test): preserve module boundaries when integrating review regress…
tignear Oct 14, 2026
f1f3e1a
Merge commit '818ba9052bb36739faf597c0ec364ecd0d3a927d' into HEAD
tignear Oct 15, 2026
22812d0
fix(runtime): batch transient process edges with clock activation
tignear Oct 15, 2026
b212815
Merge commit '6511befd2227626322750308d3b5585886bc029b' into HEAD
tignear Oct 15, 2026
7ffa018
fix(runtime): retain clock drive ownership across timestamps
tignear Oct 15, 2026
089f183
Merge commit 'c5160a8de07ecedb6bd9ad56357fb4ac5d1e768d' into HEAD
tignear Oct 15, 2026
4d4cb13
fix(runtime): retain rejected process clock activations
tignear Oct 15, 2026
94c5094
Merge commit 'a26c6e4030b4de10af7ad4e8e13ae693c6a234f9' into HEAD
tignear Oct 15, 2026
86cc996
Merge commit '7b2214d4fcf099adbf7e63760a96320adc06c5f9' into HEAD
tignear Oct 15, 2026
312c858
Merge commit '8f5599b17e3b0e241134a874dfa7d55ff40462ed' into HEAD
tignear Oct 15, 2026
09a2ca0
Merge commit 'bde8b76d0f98e2953c39c76b164f15a998a07299' into HEAD
tignear Oct 15, 2026
bda41c2
Merge selected-case timing repair through #1159
tignear Oct 15, 2026
9d14ef8
fix(runtime): retain generated drive ownership across clock retries
tignear Oct 15, 2026
df8ac95
Merge first-iteration exit timing repair through #1159
tignear Oct 15, 2026
c5b3367
Merge typed loop-count proof repair through #1159
tignear Oct 15, 2026
8ff7274
fix(runtime): validate compiled tick loops and require fusion opt-in
tignear Oct 15, 2026
6e4b414
Merge commit '13ad4e826baf5e0aff89d36f9cad8f5ea3ad4247' into HEAD
tignear Oct 15, 2026
b7fbfc3
docs(native): clarify trust in image code and ABI metadata
tignear Oct 15, 2026
f66b668
Merge commit 'b9930d24b96b635207ce62d425b61361379b5ba2' into HEAD
tignear Oct 15, 2026
b1a080b
Merge commit '6a44fa4df50a44ffd4d262b63733cc8eca267338' into HEAD
tignear Oct 15, 2026
6abcc64
Merge commit '0a3349e476ec435971c7a85d5530eb6713d6e400' into HEAD
tignear Oct 15, 2026
fae5180
Merge active-region and adapter review fixes from feature/1123-vtest
tignear Oct 15, 2026
95a1aed
Merge bare-call shadowing coverage from feature/1123-vtest
tignear Oct 15, 2026
beb037c
Merge initializer and connection staging review fixes from feature/11…
tignear Oct 15, 2026
e4a7a6e
fix(runtime): bound clean waiter settling to the current time
tignear Oct 15, 2026
21fab4b
Merge const initializer staging guard and review regressions from fea…
tignear Oct 15, 2026
ab25b39
Merge commit '59a23b7504cdd01a489ef4ca90af5ab7308c8ad1' into HEAD
tignear Oct 15, 2026
034b9aa
Merge commit '24c0a54ae' into HEAD
tignear Oct 15, 2026
41bdab7
fix(runtime): retain unpublished falls and zero-wait retries
tignear Oct 15, 2026
df91142
Merge commit '41741431aed1b56d6464738061d213766c146379' into HEAD
tignear Oct 15, 2026
1b8130f
Merge commit '2c4f7451a4b6f67f31b86bfebea13bb46edf746e' into HEAD
tignear Oct 15, 2026
6b75225
Merge commit '2c69da92673b158b663669fec25d679a87898a19' into HEAD
tignear Oct 15, 2026
f334c81
Merge commit 'e87c219a5278db9e54b648488df3c7965db278d6' into HEAD
tignear Oct 15, 2026
718e22e
ci: restore focused validation from feature/1123-vtest
tignear Oct 15, 2026
0dc1372
Merge commit '4b9cbf530' into HEAD
tignear Oct 15, 2026
1e70190
Merge remote-tracking branch 'origin/feature/1123-clock-waits' into HEAD
tignear Oct 15, 2026
5e5fce0
Merge commit 'd33b1be913a768a8bcb52b749460be625b5de44c' into HEAD
tignear Oct 15, 2026
0e09889
ci: inherit the corrected Mergify CLI action reference
tignear Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 51 additions & 6 deletions crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ pub enum ProcessStatus {
/// It ran no statement, so no state other than its own wait bookkeeping
/// changed.
Pending,
/// Resume after the number of rising edges stored in
/// [`ProcessSlots::delay`] of the process clock whose index is stored in
/// [`ProcessSlots::clock`]. The runtime generates those edges: the clock
/// toggles every half period from the first wait on it, and the process
/// resumes one period after the last counted edge, before the edge that
/// follows.
WaitClock,
/// An event occurred while sampling queued drives; resume its body after the batch.
Ready,
/// Resume this process immediately, charging the current time-slot budget.
Expand All @@ -247,6 +254,7 @@ impl ProcessStatus {
Self::Finish => 3,
Self::Wait => 4,
Self::Pending => 5,
Self::WaitClock => 6,
Self::Ready => 11,
Self::Yield => 10,
}
Expand All @@ -260,25 +268,50 @@ impl ProcessStatus {
3 => Some(Self::Finish),
4 => Some(Self::Wait),
5 => Some(Self::Pending),
6 => Some(Self::WaitClock),
11 => Some(Self::Ready),
10 => Some(Self::Yield),
_ => None,
}
}
}

/// A clock a process waits on with [`ProcessStatus::WaitClock`]: the clock
/// signal of a sequential domain, and the period of the edges the runtime
/// generates for it (at least two time units).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ProcessClock<A> {
pub signal: A,
pub period: u64,
}

impl<A> ProcessClock<A> {
pub fn map<B>(self, map: impl FnOnce(A) -> B) -> ProcessClock<B> {
ProcessClock {
signal: map(self.signal),
period: self.period,
}
}
}

/// State through which one process kernel exchanges control with the runtime.
///
/// A process kernel is a resumable function. On entry it reads `resume` to
/// find where it stopped; before returning it stores the next resume point,
/// a [`ProcessStatus`] code in `status` and, for a delay, the number of time
/// units in `delay`. All three are ordinary two-state state objects, so
/// checkpoints capture a suspended process.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
/// a [`ProcessStatus`] code in `status` and, for a delay or a clock wait, the
/// number of time units or edges in `delay`; a clock wait also stores the
/// index into `clocks` in `clock`. The slots are ordinary two-state state
/// objects, so checkpoints capture a suspended process.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ProcessSlots<A> {
pub resume: A,
pub status: A,
pub delay: A,
pub clock: A,
/// The clocks the process may wait on, in the order its kernel numbers
/// them.
#[serde(default = "Vec::new")]
pub clocks: Vec<ProcessClock<A>>,
Comment thread
tignear marked this conversation as resolved.
Resolved
Comment thread
tignear marked this conversation as resolved.
Resolved
}

impl<A> ProcessSlots<A> {
Expand All @@ -287,18 +320,27 @@ impl<A> ProcessSlots<A> {
resume: map(self.resume),
status: map(self.status),
delay: map(self.delay),
clock: map(self.clock),
clocks: self
.clocks
.into_iter()
.map(|clock| clock.map(&mut map))
.collect(),
}
}

/// The control slots, without the clock signals.
pub fn iter(&self) -> impl Iterator<Item = &A> {
[&self.resume, &self.status, &self.delay].into_iter()
[&self.resume, &self.status, &self.delay, &self.clock].into_iter()
}
}

/// Width of [`ProcessSlots::status`].
pub const PROCESS_STATUS_WIDTH: usize = 8;
/// Width of [`ProcessSlots::delay`].
pub const PROCESS_DELAY_WIDTH: usize = 64;
/// Width of [`ProcessSlots::clock`].
pub const PROCESS_CLOCK_WIDTH: usize = 32;

pub const PROCESS_EVENT_COUNTER_WIDTH: usize = 32;

Expand Down Expand Up @@ -348,6 +390,8 @@ pub struct RuntimeSchema<A> {
/// derived from the other state, so state files recompute rather than
/// compare them.
pub comb_writes: HashSet<A>,
/// Combinational execution reads a clock, so both phases must settle.
pub clock_phase_sensitive_comb: bool,
/// Dead store elimination policy the program was compiled with. Together
/// with `live_signals` and the design it decides which combinationally
/// written state the host may observe.
Expand All @@ -357,7 +401,7 @@ pub struct RuntimeSchema<A> {
/// Control slots of the process kernels, in kernel order.
pub processes: Vec<ProcessSlots<A>>,
pub process_event_counters: Vec<ProcessEventCounters<A>>,
/// FF evaluation domains that publish blocking stores into active state.
/// FF domains with blocking stores or finish effects in the active region.
pub active_ff_events: HashSet<A>,
}

Expand All @@ -371,6 +415,7 @@ impl<A> Default for RuntimeSchema<A> {
testbench_read_roots: HashSet::default(),
rtl_writes: HashSet::default(),
comb_writes: HashSet::default(),
clock_phase_sensitive_comb: false,
dead_store_policy: DeadStorePolicy::Off,
live_signals: HashSet::default(),
processes: Vec::new(),
Expand Down
29 changes: 27 additions & 2 deletions crates/celox-frontend-core/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//! suspension methods where the source suspends.

use celox_design::{
PROCESS_DELAY_WIDTH, PROCESS_STATUS_WIDTH, ProcessSlots, ProcessStatus, RegionedVarAddrBase,
STABLE_REGION,
PROCESS_CLOCK_WIDTH, PROCESS_DELAY_WIDTH, PROCESS_STATUS_WIDTH, ProcessSlots, ProcessStatus,
RegionedVarAddrBase, STABLE_REGION,
};
use celox_sir::{
BinaryOp, BlockId, ExecutionUnit, RegisterId, SIRBuilder, SIRInstruction, SIROffset,
Expand All @@ -43,6 +43,8 @@ pub const MAX_PROCESS_SUSPENSIONS: usize = (1 << PROCESS_RESUME_WIDTH) - 1;
pub enum ProcessKernelError {
#[error("a process has more than {MAX_PROCESS_SUSPENSIONS} suspension points")]
TooManySuspensions,
#[error("a process waits on clock {0}, which its slots do not list")]
UnknownClock(u32),
}

/// Builder of one process kernel.
Expand Down Expand Up @@ -140,6 +142,29 @@ impl ProcessKernelBuilder {
Ok(())
}

/// Suspend until `count` rising edges of the process clock `clock` (an
/// index into the slots' clock list) have passed, and continue at a new
/// resume point one period after the last of them. `count` is an
/// unsigned two-state register of [`PROCESS_DELAY_WIDTH`] bits; a count
/// of zero continues at once.
pub fn wait_clock(&mut self, clock: u32, count: RegisterId) -> Result<(), ProcessKernelError> {
if clock as usize >= self.slots.clocks.len() {
return Err(ProcessKernelError::UnknownClock(clock));
}
let point = self.resume_blocks.len();
if point > MAX_PROCESS_SUSPENSIONS {
return Err(ProcessKernelError::TooManySuspensions);
}
self.store(self.slots.delay, PROCESS_DELAY_WIDTH, count);
self.store_constant(self.slots.clock, PROCESS_CLOCK_WIDTH, u64::from(clock));
self.store_constant(self.slots.resume, PROCESS_RESUME_WIDTH, point as u64);
self.end(ProcessStatus::WaitClock);
let resume = self.builder.new_block();
self.resume_blocks.push(resume);
self.builder.switch_to_block(resume);
Ok(())
}

/// Suspend until a condition the kernel evaluates holds, and continue at
/// a new resume point. The caller lowers the condition at that point
/// and ends it with [`Self::wake_if`]; the runtime resumes the process
Expand Down
45 changes: 38 additions & 7 deletions crates/celox-frontend-core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use celox_design::{
BinaryOp, BitAccess, DomainKind, InitialStateData, InitialStateValue, ModuleId,
PROCESS_DELAY_WIDTH, PROCESS_STATUS_WIDTH, PortTypeKind, ProcessSlots, RegionedVarAddrBase,
STABLE_REGION, TriggerSet, UnaryOp, VarAtomBase, VariableMetadata, WORKING_REGION,
PROCESS_CLOCK_WIDTH, PROCESS_DELAY_WIDTH, PROCESS_STATUS_WIDTH, PortTypeKind, ProcessClock,
ProcessSlots, RegionedVarAddrBase, STABLE_REGION, TriggerSet, UnaryOp, VarAtomBase,
VariableMetadata, WORKING_REGION,
};
use celox_frontend_sdk::{
ActiveLevel, Direction, Edge, ExprId, ExprNode, FrontendArtifact, SignalId, SignalSlice,
Expand Down Expand Up @@ -1034,6 +1035,7 @@ fn lower_registers(
fn lower_statements(
artifact: &FrontendArtifact,
kernel: &mut ProcessKernelBuilder,
clocks: &[SignalId],
statements: &[Statement],
) -> Result<bool, FrontendArtifactError> {
for statement in statements {
Expand Down Expand Up @@ -1075,7 +1077,7 @@ fn lower_statements(
let mut join = None;
for (block, body) in [(then_block, then_body), (else_block, else_body)] {
kernel.builder().switch_to_block(block);
if lower_statements(artifact, kernel, body)? {
if lower_statements(artifact, kernel, clocks, body)? {
let builder = kernel.builder();
let target = *join.get_or_insert_with(|| builder.new_block());
builder.seal_block(SIRTerminator::Jump(target, Vec::new()));
Expand All @@ -1100,7 +1102,7 @@ fn lower_statements(
false_block: (exit, Vec::new()),
});
builder.switch_to_block(body_block);
if lower_statements(artifact, kernel, body)? {
if lower_statements(artifact, kernel, clocks, body)? {
kernel
.builder()
.seal_block(SIRTerminator::Jump(header, Vec::new()));
Expand All @@ -1112,7 +1114,7 @@ fn lower_statements(
let header = builder.new_block();
builder.seal_block(SIRTerminator::Jump(header, Vec::new()));
builder.switch_to_block(header);
if lower_statements(artifact, kernel, body)? {
if lower_statements(artifact, kernel, clocks, body)? {
kernel
.builder()
.seal_block(SIRTerminator::Jump(header, Vec::new()));
Expand All @@ -1129,6 +1131,20 @@ fn lower_statements(
)?;
kernel.delay(amount)?;
}
Statement::ClockCycles { clock, count } => {
let index = clocks
.iter()
.position(|c| c == clock)
.ok_or(FrontendArtifactError::UnknownSignal(clock.index()))?;
let count = coerce_sir_expression(
artifact,
*count,
ValueType::bits(PROCESS_DELAY_WIDTH)?,
kernel.builder(),
&mut cache,
)?;
kernel.wait_clock(index as u32, count)?;
}
Statement::Finish => {
kernel.finish();
return Ok(false);
Expand Down Expand Up @@ -1176,13 +1192,28 @@ fn lower_processes(
.enumerate()
.map(|(index, process)| {
let name = |slot: &str| vec![format!("$process[{index}]"), slot.to_string()];
let mut clocks = Vec::new();
celox_frontend_sdk::collect_process_clocks(process.body(), &mut clocks);
let slots = ProcessSlots {
resume: declare(name("resume"), PROCESS_RESUME_WIDTH),
status: declare(name("status"), PROCESS_STATUS_WIDTH),
delay: declare(name("delay"), PROCESS_DELAY_WIDTH),
clock: declare(name("clock"), PROCESS_CLOCK_WIDTH),
clocks: clocks
.iter()
.map(|clock| {
Ok(ProcessClock {
signal: source_id(*clock),
period: artifact
.clock_period(*clock)
.ok_or(FrontendArtifactError::UnknownSignal(clock.index()))?
.max(2),
})
})
.collect::<Result<Vec<_>, FrontendArtifactError>>()?,
};
let mut kernel = ProcessKernelBuilder::new(slots);
lower_statements(artifact, &mut kernel, process.body())?;
let mut kernel = ProcessKernelBuilder::new(slots.clone());
lower_statements(artifact, &mut kernel, &clocks, process.body())?;
Ok(SymbolicProcess {
kernel: kernel.build(),
slots,
Expand Down
6 changes: 5 additions & 1 deletion crates/celox-frontend-core/src/symbolic/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@ pub fn schedule_symbolic_rtl(
testbench_read_roots: process_read_roots,
rtl_writes,
comb_writes: Default::default(),
clock_phase_sensitive_comb: false,
dead_store_policy: Default::default(),
live_signals: Default::default(),
processes: process_slots,
Expand Down Expand Up @@ -2273,7 +2274,10 @@ fn relocate_units(
&runtime_event_site_map,
&extern_function_map,
),
slots: process.slots.map(|var_id| bindings.locate(*id, var_id)),
slots: process
.slots
.clone()
.map(|var_id| bindings.locate(*id, var_id)),
},
));
}
Expand Down
Loading
Loading