1mod backend;
2#[cfg(all(feature = "arm64-codegen", feature = "x86_64-codegen"))]
3compile_error!("arm64-codegen and x86_64-codegen cannot be enabled together");
4#[cfg(feature = "host-runtime")]
5mod component;
6#[cfg(feature = "host-runtime")]
7pub use component::{
8 InjectedCall, InjectedComponentHandler, InjectedComponents, InjectedHook, InjectedNamedValue,
9 InjectedPort, InjectedResult, InjectedValue, register_static_component,
10 register_static_component_manifest,
11};
12mod debug;
13mod diagnostics;
14mod ir;
15mod optimizer;
16mod parser;
17pub(crate) mod portable;
18#[cfg(feature = "host-runtime")]
19mod simulation;
20mod simulator;
21#[cfg(feature = "host-runtime")]
22pub mod testbench;
23mod testbench_compile;
24pub(crate) mod timing;
25pub use backend::SimulatorErrorCode as RuntimeErrorCode;
26pub use backend::{
27 EventHandle, LayoutRequirements, MemoryLayout, MemoryLayoutMode, SimBackend, get_byte_size,
28};
29pub use celox_design::{DomainKind, ElaboratedDesign, EventTopology, RuntimeSchema};
30pub use celox_frontend_core::FrontendArtifactError;
31pub use celox_frontend_sdk as frontend_sdk;
32pub use celox_frontend_sdk::FrontendArtifact;
33pub use celox_frontend_veryl::{FrontendDiagnostic, LoweringPhase, ParserError};
34pub use celox_runtime::{
35 DesignReflection, ReflectionScope, ReflectionScopeId, ReflectionSignal, ReflectionSignalId,
36 SignalDirection,
37};
38pub use celox_slt::scheduler::SchedulerError;
39pub use debug::{CompilationTrace, NativeProfileBlock, TraceOptions};
40pub use diagnostics::RuntimeDiagnostics;
41pub(crate) use fxhash::FxHashMap as HashMap;
42pub(crate) use fxhash::FxHashSet as HashSet;
43pub use ir::{
44 AbsoluteAddr, AddrLookupError, FrontendLookup, InstancePath, LaidOutProgram, OptimizedSir,
45 PortTypeKind, RuntimeDesign, RuntimeErrorInfo, RuntimeInstance, RuntimeProgram,
46 RuntimeVariable, SignalRef, SirProgram, SourceAddr, SourceVarId, UnoptimizedSir, VariableInfo,
47 VariableKind,
48};
49pub use num_bigint::BigUint;
50pub use optimizer::OptLevel;
51pub use optimizer::OptimizeOptions;
52pub use optimizer::SirDiagnostics;
53pub use optimizer::SirPass;
54pub use simulator::render_diagnostic;
55pub use simulator::{CodegenError, CompilationWarning, SimulatorError, SimulatorErrorKind};
56pub use veryl_metadata::{ClockType, ResetType};
57
58#[cfg(feature = "host-runtime")]
59mod host_api {
60 use crate::SimBackend;
61 pub use crate::backend::wasm_runtime::WasmBackend;
62 pub use crate::backend::{
63 CraneliftDiagnostics, CraneliftOptLevel, CraneliftOptions, EventRef, JitBackend,
64 RegallocAlgorithm, SharedJitCode,
65 };
66 pub use crate::debug::CompilationTraceResult;
67 pub use crate::diagnostics::DiagnosticsOptions;
68 pub use crate::simulation::Simulation;
69 #[cfg(any(
70 target_arch = "x86_64",
71 feature = "arm64-codegen",
72 target_arch = "aarch64"
73 ))]
74 pub use crate::simulator::NativeCompilation;
75 pub use crate::simulator::{
76 DeadStorePolicy, InstanceHierarchy, NamedEvent, NamedSignal, RuntimeEvent,
77 RuntimeEventDrain, RuntimeFormatContext, Simulator, SimulatorBuilder, SimulatorOptions,
78 };
79 pub use crate::testbench::{AssertionResult, SourceLocation, TestResult, TestResultDetailed};
80 pub use celox_macros::veryl_test;
81 pub use celox_runtime::{VcdSignalDesc, VcdWriter};
82
83 pub struct IOContext<'a, B: SimBackend = DefaultBackend> {
84 pub(crate) backend: &'a mut B,
85 }
86
87 impl<'a, B: SimBackend> IOContext<'a, B> {
88 pub fn set<T: Copy>(&mut self, signal: crate::SignalRef, val: T) {
89 self.backend.set(signal, val);
90 }
91
92 pub fn set_wide(&mut self, signal: crate::SignalRef, val: crate::BigUint) {
93 self.backend.set_wide(signal, val);
94 }
95
96 pub fn set_four_state(
97 &mut self,
98 signal: crate::SignalRef,
99 val: crate::BigUint,
100 mask: crate::BigUint,
101 ) {
102 self.backend.set_four_state(signal, val, mask);
103 }
104 }
105
106 #[cfg(any(
107 target_arch = "x86_64",
108 feature = "arm64-codegen",
109 target_arch = "aarch64"
110 ))]
111 pub mod native_backend {
112 pub use crate::backend::native::*;
114 }
115
116 #[cfg(any(
117 target_arch = "x86_64",
118 feature = "arm64-codegen",
119 target_arch = "aarch64"
120 ))]
121 pub use crate::backend::native::backend::NativeEventRef;
122 #[cfg(any(
123 target_arch = "x86_64",
124 feature = "arm64-codegen",
125 target_arch = "aarch64"
126 ))]
127 pub use crate::backend::native::{
128 AppendedNativeImage, NativeBackend, NativeCodeEntry, NativeImageArchitecture,
129 NativeImageContainerError, NativeProgramImage, NativeProgramInstance,
130 NativeProgramLoadError, NativeSignalIdentity, SharedNativeCode,
131 };
132 #[cfg(any(
133 target_arch = "x86_64",
134 feature = "arm64-codegen",
135 target_arch = "aarch64"
136 ))]
137 pub use crate::backend::{NativeDiagnostics, NativeDumpOptions};
138
139 #[cfg(any(
142 all(target_arch = "x86_64", not(feature = "arm64-codegen")),
143 all(target_arch = "aarch64", not(feature = "x86_64-codegen"))
144 ))]
145 pub type DefaultBackend = NativeBackend;
146 #[cfg(not(any(
147 all(target_arch = "x86_64", not(feature = "arm64-codegen")),
148 all(target_arch = "aarch64", not(feature = "x86_64-codegen"))
149 )))]
150 pub type DefaultBackend = JitBackend;
151
152 pub type DefaultEventRef = <DefaultBackend as SimBackend>::Event;
153}
154
155#[cfg(feature = "host-runtime")]
156pub use host_api::*;
157
158pub use backend::wasm_codegen;
160
161pub use simulator::{compile_frontend_to_sir, compile_to_sir};
163#[cfg(feature = "systemverilog")]
164pub use simulator::{compile_mixed_to_sir, compile_sv_to_sir};
165
166#[cfg(test)]
167mod flatting_tests;