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. |
| void | executeTick() Inlined hot path executed millions of times per second. |
| 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) |
Friends
| Name | |
|---|---|
| class | TickSimulation |
Additional inherited members
Public Functions inherited from chronon::sender::Unit
| Name | |
|---|---|
| virtual | ~Unit() =default |
| void | useFastCycleCounter() Default mode. Eliminates atomic overhead (~80% of tight-loop time). |
| void | useAtomicCycleCounter() |
| tree::TreeNode * | treeNode() const |
| UnitState | state() const |
| void | setTreeNode(tree::TreeNode * node) Triggers registration of all pending ports to PortDirectory. |
| void | registerPort(PortBase * port) |
| const std::vector< PortBase * > & | ports() const |
| Unit & | operator=(const Unit & ) =delete |
| Unit & | operator=(Unit && ) =delete |
| const std::string & | name() const |
| uint64_t | localCycle() 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() Called after run() completes or simulation is stopped. |
| uint8_t | crashNameLen() const |
| const char * | crashName() const |
| void | addPendingPortRegistration(std::function< void(const std::string &)> registration) |
| Unit(std::string name) | |
| Unit(const Unit & ) =delete | |
| Unit(Unit && ) =delete |
Protected Functions inherited from chronon::sender::Unit
| Name | |
|---|---|
| void | setState(UnitState state) |
| void | setLocalCycle(uint64_t cycle) |
| void | setId(uint32_t id) |
| uint64_t | localCycleAtomic() const |
| void | advanceLocalCycle(uint64_t delta =1) Fast path: ~0.3ns increment. Slow path (atomic): ~15ns. |
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 executeTick
inline void executeTick()
Inlined hot path executed millions of times per second.
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 epoch boundary.
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
)
Friends
friend TickSimulation
friend class TickSimulation(
TickSimulation
);
Updated on 2026-05-26 at 05:42:32 +0000