Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion .github/RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# Release policy

Celox is released as one lockstep distribution. `VERSION`,
`.release-please-manifest.json`, the npm packages, and all Rust workspace crates
`.release-please-manifest.json`, the npm packages, and all Celox Rust workspace crates
must always carry the same version. The public Rust entry points are `celox`,
`celox-frontend-sdk`, `celox-test-suite`, and the Rust adapter API in `celox-napi`; the remaining
published `celox-*` crates satisfy their Cargo dependency graph and remain
implementation details.

Aplite has its own version and release train (`release-aplite.yml` and
`publish-aplite.yml`). Publish the Aplite version required by the workspace
before releasing Celox: `celox-heap` depends on it, and Cargo resolves the
published Aplite crate when packaging Celox crates. A bootstrap `0.0.0` release
does not satisfy this dependency. Aplite is deliberately absent from Celox's
lockstep publication list.

## Versioning before 1.0

Pull request titles are the input to release automation after GitHub copies the
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ description = "Celox HDL Simulator"
rust-version = "1.99.1"

[workspace.dependencies]
# Aplite has its own release version; these consumers are unpublished.
aplite = { path = "crates/aplite" }
# Aplite has an independent release version.
aplite = { version = "0.1.0", path = "crates/aplite" }
celox = { version = "=0.11.0", path = "crates/celox", default-features = false } # x-release-please-version
celox-analysis = { version = "=0.11.0", path = "crates/celox-analysis" } # x-release-please-version
celox-backend-arm64 = { version = "=0.11.0", path = "crates/celox-backend-arm64" } # x-release-please-version
Expand Down
2 changes: 2 additions & 0 deletions crates/celox-frontend-sv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
serde_json = { workspace = true }

celox-design = { workspace = true }
celox-frontend-core = { workspace = true }
celox-heap = { workspace = true }
Expand Down
19 changes: 18 additions & 1 deletion crates/celox-frontend-sv/src/lowering/ff/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ impl Ff<'_, '_> {
})
.collect::<Result<Vec<_>, _>>()?;
let result = match op {
ObjectOp::Randomize(program) => {
let object = self.handle(&args[0])?;
let check = self.integer_of_width(&args[1], 1, false)?;
let bytes = serde_json::to_vec(program).expect("constraint program serialization");
let mut buffer = self.heap_call(ops::NEW, &[]);
for chunk in bytes.chunks(8) {
let value = chunk
.iter()
.fold(0u64, |value, byte| (value << 8) | u64::from(*byte));
let value = self.constant64(value);
let count = self.constant64(chunk.len() as u64);
buffer = self.heap_call(ops::APPEND_BYTES, &[buffer, value, count]);
}
let program = self.heap_call(ops::FREEZE, &[buffer]);
self.heap_call(ops::OBJECT_RANDOMIZE, &[object, program, check])
}
ObjectOp::Container { .. } => unreachable!("handled by container_call"),
ObjectOp::New {
class,
Expand Down Expand Up @@ -132,7 +148,8 @@ impl Ff<'_, '_> {
HandleProperty::String => celox_design::ValueKind::StrRef,
HandleProperty::Object => celox_design::ValueKind::ObjRef,
}),
ObjectOp::Store(_)
ObjectOp::Randomize(_)
| ObjectOp::Store(_)
| ObjectOp::ClassOf
| ObjectOp::Random
| ObjectOp::RandomCyclic { .. }
Expand Down
3 changes: 3 additions & 0 deletions crates/celox-heap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
aplite = { workspace = true }
serde_json = { workspace = true }

serde = { workspace = true, features = ["rc"] }
fxhash = { workspace = true }

Expand Down
1 change: 1 addition & 0 deletions crates/celox-heap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};
pub mod containers;
mod objects;
pub mod ops;
pub mod randomization;

pub use objects::{Fault, NULL};

Expand Down
4 changes: 4 additions & 0 deletions crates/celox-heap/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl Object {
/// reports once control returns to it.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Fault {
ConstraintRandomization(String),
NegativeArraySize,
ContainerAllocationLimit,
/// A property access or method call through `null` or a handle of no
Expand All @@ -61,6 +62,9 @@ pub enum Fault {
impl std::fmt::Display for Fault {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ConstraintRandomization(reason) => {
write!(f, "constraint randomization failed: {reason}")
}
Self::NegativeArraySize => f.write_str("negative dynamic array size"),
Self::ContainerAllocationLimit => {
f.write_str("dynamic container allocation limit exceeded")
Expand Down
16 changes: 16 additions & 0 deletions crates/celox-heap/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub const OBJECT_MODE_SELECTED: u64 = 61;
pub const OBJECT_RANDOM_CYCLIC: u64 = 62;
/// `copy(object)`: a new object with a copy of the properties of `object`.
pub const OBJECT_COPY: u64 = 63;
/// Solve the scalar constraint program in string b for object a; c selects check-only.
pub const OBJECT_RANDOMIZE: u64 = 64;

/// The opcode word of `op` with parameter `parameter`.
pub const fn encode(op: u64, parameter: u64) -> u64 {
Expand Down Expand Up @@ -193,6 +195,20 @@ impl Heap {
0
}
OBJECT_CLASS => self.class_of(a as Handle).into(),
OBJECT_RANDOMIZE => {
match serde_json::from_slice::<crate::randomization::Program>(
self.string(b as Handle),
) {
Comment on lines +199 to +201

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align program deserialization depth with accepted expressions

For sufficiently deep expressions accepted by the binder, the generated program fails at runtime because serde_json::from_slice uses its default 128-level recursion limit. For example, a constraint comparing a left-associated sum of 64 occurrences of an 8-bit field against 32'd0 stays within the binder's 64-level expression limit, but the externally tagged Binary objects and inserted Resize objects exceed the JSON limit. A satisfiable constraint therefore raises ConstraintRandomization before reaching the solver. Align the accepted expression depth with the serialized representation, or deserialize compiler-generated programs using a suitably bounded higher limit.

Useful? React with 👍 / 👎.

Ok(program) => u64::from(self.randomize_object(a as Handle, &program, c != 0)),
Err(error) => {
self.fault
.get_or_insert(crate::Fault::ConstraintRandomization(
error.to_string(),
));
0
}
}
}
OBJECT_RANDOM => self.random_object(a as Handle),
OBJECT_RANDOM_CYCLIC => self.random_cyclic_object(a as Handle, parameter as u32, b),
OBJECT_SEED => {
Expand Down
Loading
Loading