chronon::TickableUnit
#include <TickableUnit.hpp>
Inherits from chronon::sender::Unit
Inherited by chronon::sender::PhasedTickableUnit< Derived >, chronon::sender::factory::AutoRegisteredUnit< Derived >
Public Functions
| Name | |
|---|---|
| virtual | ~TickableUnit() =default |
| virtual void | tick() =0 Per-cycle behavior. Must complete synchronously. |
| virtual bool | isCompleted() const Return true to signal the simulation can stop. |
| TickableUnit(std::string name) |
Protected Functions
| Name | |
|---|---|
| template <ValidPhase P> void | tickPhase() |
| void | requestTermination(TerminationReason reason, int32_t exit_code =0, std::string_view message ="") |
| void | requestTermination(TerminationReason reason, int32_t exit_code, uint64_t cycle, std::string_view message) |
| void | requestExitSyscall(int32_t exit_code) |
| void | requestError(std::string_view message) |
| void | executeTickAlwaysActive() Hot path for units that have not opted into activity scheduling. |
| void | executeTick() Inlined hot path executed millions of times per second. |
| void | advanceIdleTick(uint64_t delta) Batched inactive-cycle advance used when an entire cluster is idle. |
Friends
| Name | |
|---|---|
| class | TickSimulation |
Additional inherited members
Public Functions inherited from chronon::sender::Unit
| Name | |
|---|---|
| virtual | ~Unit() =default |
| void | wakeAt(uint64_t cycle) Wake the unit no later than cycle. Safe for cross-thread producers. |
| bool | usesActivityScheduling() const |
| void | useFastCycleCounter() Default mode. Eliminates atomic overhead (~80% of tight-loop time). |
| void | useAtomicCycleCounter() |
| tree::TreeNode * | treeNode() const |
| uint32_t | tickInterval() const |
| UnitState | state() const |
| void | sleepUntil(uint64_t cycle) |
| void | sleepForever() Disable the tick body until an external wakeAt() or port arrival wakes it. |
| bool | shouldRunTickAt(uint64_t cycle) const |
| void | setTreeNode(tree::TreeNode * node, PortDirectory & directory =PortDirectory::instance()) Triggers registration of all pending ports to PortDirectory. |
| void | setTickInterval(uint32_t interval) |
| void | registerPort(PortBase * port) |
| void | registerCyclePreparedPort(PortBase * port) |
| const std::vector< PortBase * > & | ports() const |
| SimTime | physicalTime() const |
| Unit & | operator=(const Unit & ) =delete |
| Unit & | operator=(Unit && ) =delete |
| uint64_t | nextRunnableCycleAtOrAfter(uint64_t cycle) const |
| uint64_t | nextActiveCycle() const |
| const std::string & | name() const |
| uint64_t | localCycle() const |
| bool | isClockEdgeExecuting() const |
| virtual void | initialize() Called after all connections are made, before run() starts. |
| uint32_t | id() const |
| std::string | fullPath() const Returns the tree path if a TreeNode is set, else the unit name. |
| virtual void | finalize() |
| void | enableActivityScheduling() |
| uint8_t | crashNameLen() const |
| const char * | crashName() const |
| observe::ClockTraceStream * | clockTraceStream() const |
| bool | clockTopologyFrozen() const |
| void | clockEvent(observe::ClockEventKind kind, uint64_t transaction =0, uint64_t value =0) |
| ClockDomainId | clockDomainId() const Edge number in this Unit's hardware domain, never a cross-domain timestamp. |
| const ClockDomain & | clockDomain() const |
| void | addPendingPortRegistration(std::function< void(const std::string &, PortDirectory &)> registration) |
| uint64_t | activitySchedulingGeneration() const |
| bool | acceptsPortWakeups() const |
| Unit(std::string name) | |
| Unit(const Unit & ) =delete | |
| Unit(Unit && ) =delete |
Protected Functions inherited from chronon::sender::Unit
| Name | |
|---|---|
| void | setLocalCycle(uint64_t cycle) |
| void | setInstanceName_(std::string name) |
| void | setId(uint32_t id) |
| void | prepareCyclePorts_() |
| uint64_t | localCycleAtomic() const |
| void | finishActiveTick_() |
| void | beginActiveTick_() |
| void | advanceLocalCycle(uint64_t delta =1) Fast path: ~0.3ns increment. Slow path (atomic): ~15ns. |
Public Attributes inherited from chronon::sender::Unit
| Name | |
|---|---|
| uint64_t | NEVER_ACTIVE |
Detailed Description
class chronon::TickableUnit;
State-machine based simulation unit.
tick() is called every cycle; state lives in member variables. Avoids coroutine overhead and integrates with stdexec parallel execution.
class FetchUnit : public TickableUnit {
OutPort<Instruction> out{this, "out"};
uint64_t pc_ = 0;
void tick() override {
if (out.canSend()) out.send(Instruction{pc_++});
}
};
Public Functions Documentation
function ~TickableUnit
virtual ~TickableUnit() =default
function tick
virtual void tick() =0
Per-cycle behavior. Must complete synchronously.
function isCompleted
inline virtual bool isCompleted() const
Return true to signal the simulation can stop.
function TickableUnit
inline explicit TickableUnit(
std::string name
)
Protected Functions Documentation
function tickPhase
template <ValidPhase P>
inline void tickPhase()
Phase-templated tick for compile-time pipeline slot selection.
Override instead of tick() when using StageReg. Phase0/Phase1 dispatch is based on cycle parity. Default delegates to tick().
template<ValidPhase P>
void tickPhase() {
if (reg_.valid<P>()) process(reg_.get<P>());
reg_.set<P>(new_data);
}
function requestTermination
inline void requestTermination(
TerminationReason reason,
int32_t exit_code =0,
std::string_view message =""
)
Request simulation termination. First request wins; the simulation stops at the next scheduler boundary, and parallel lookahead workers are signaled through the shared stop token.
function requestTermination
inline void requestTermination(
TerminationReason reason,
int32_t exit_code,
uint64_t cycle,
std::string_view message
)
Overload taking an explicit cycle (avoids cross-thread localCycle() reads in MMIO callbacks).
function requestExitSyscall
inline void requestExitSyscall(
int32_t exit_code
)
function requestError
inline void requestError(
std::string_view message
)
function executeTickAlwaysActive
inline void executeTickAlwaysActive()
Hot path for units that have not opted into activity scheduling.
function executeTick
inline void executeTick()
Inlined hot path executed millions of times per second.
function advanceIdleTick
inline void advanceIdleTick(
uint64_t delta
)
Batched inactive-cycle advance used when an entire cluster is idle.
Friends
friend TickSimulation
friend class TickSimulation(
TickSimulation
);
Updated on 2026-09-20 at 14:23:39 +0000