Skip to content
Closed
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
12 changes: 10 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ priority_rules:
priority: 10000
allow_checks_interruption: true

- name: Priority merges without interruption
conditions:
- label = merge-priority
priority: 9000
allow_checks_interruption: false

- name: Lightweight validated changes first
conditions:
- check-success = Lint & Format
Expand Down Expand Up @@ -160,7 +166,7 @@ queue_rules:
# rulesets. Keep those rules enforced by GitHub; Mergify gets no bypass.

pull_request_rules:
- name: Authorize emergency merge requests
- name: Authorize prioritized merge requests
conditions:
- or:
- base ~= ^(master|develop)$
Expand All @@ -169,7 +175,9 @@ pull_request_rules:
- and:
- base ~= ^stack/
- 'body ~= (?m)^Depends-On: '
- label = merge-urgent
- or:
- label = merge-urgent
- label = merge-priority
- -label = release:hold
- -label = dequeued
- -draft
Expand Down
27 changes: 16 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,25 @@ regressions and manual scaling measurements are not made passing by blindly
running every `#[ignore]` test. New exclusions need a concrete reason and
evidence; an unexpected failure must not become a skip.

## Emergency merge priority
## Merge priority labels

Apply `merge-urgent` to request an emergency merge. Mergify adds `merge-ready`
and gives the PR priority 10000, ahead of the normal and lightweight priorities.
It may interrupt lower-priority queue checks to test the urgent PR first; use
this only when the urgency justifies restarting that work. Existing queue
categories and batching still apply, as do stack dependency ordering and all
required checks. This is priority, not permission to merge failing CI.
Both labels add `merge-ready` and request normal queue admission:

| Label | Priority | Running lower-priority checks |
| --- | --- | --- |
| `merge-priority` | 9000 | Finish first; this PR goes ahead of waiting ordinary PRs |
| `merge-urgent` | 10000 | May be interrupted to test this PR first |

Both outrank normal and lightweight priorities. If both labels are present,
`merge-urgent` wins. Reserve it for emergencies that justify restarting checks.
Existing queue categories, batching, stack dependency ordering, and all required
checks still apply. These labels do not permit merging failing CI.

Drafts, conflicts, `release:hold`, and `dequeued` still block automatic admission.
After addressing a dequeue's cause, remove `dequeued` to retry. Removing
`merge-urgent` restores normal priority; remove `merge-ready` and explicitly
After addressing a dequeue's cause, remove `dequeued` to retry. Remove both
priority labels to restore normal priority; remove `merge-ready` and explicitly
dequeue as usual to withdraw the merge request entirely. The generated
`merge-ready` label also activates the existing release-PR freeze mechanism.

The label works after this configuration reaches the PR's base branch. Creating
or applying the label alone does not install the queue policy.
Each label's behavior works after its configuration reaches the PR's base
branch. Creating or applying a label alone does not install the queue policy.
4 changes: 2 additions & 2 deletions Cargo.lock

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

48 changes: 28 additions & 20 deletions crates/celox-frontend-sv/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod procedural;

type RegionedVarAddr = RegionedVarAddrBase<SourceVarId>;
type GlueBlock = GlueBlockBase<SourceVarId>;
const MAX_SV_SPECIALIZATIONS_PER_MODULE: usize = 64;
const MAX_SV_RECURSIVE_SPECIALIZATIONS: usize = 64;
/// The name of a module's [`SimModule::time_slot`].
const TIME_SLOT: &str = "$time";

Expand Down Expand Up @@ -2268,7 +2268,7 @@ fn prepare_external_hierarchy_collecting(
names.sort();

let mut module_ids = HashMap::default();
let mut module_specialization_counts = HashMap::default();
let mut specialization_parents = HashMap::default();
let mut queue = Vec::new();
let mut requested_roots = HashMap::default();
for name in names {
Expand Down Expand Up @@ -2309,7 +2309,6 @@ fn prepare_external_hierarchy_collecting(
}
let module_id = ModuleId(module_ids.len());
module_ids.insert(key.clone(), module_id);
module_specialization_counts.insert(name.clone(), 1usize);
queue.push(key);
}

Expand Down Expand Up @@ -2374,7 +2373,6 @@ fn prepare_external_hierarchy_collecting(
if !module_ids.contains_key(&dependency) {
let id = ModuleId(module_ids.len());
module_ids.insert(dependency.clone(), id);
module_specialization_counts.insert(name.clone(), 1);
queue.push(dependency);
}
}
Expand All @@ -2400,13 +2398,7 @@ fn prepare_external_hierarchy_collecting(
continue;
}
if !module_ids.contains_key(&child_key) {
let specialization_count = module_specialization_counts
.entry(child_key.name.clone())
.or_insert(0);
if *specialization_count >= MAX_SV_SPECIALIZATIONS_PER_MODULE {
return Err(sv_specialization_limit_error(child_key.name.clone()).into());
}
*specialization_count += 1;
register_specialization_parent(&child_key, &key, &mut specialization_parents)?;
let child_id = ModuleId(module_ids.len());
module_ids.insert(child_key.clone(), child_id);
queue.push(child_key);
Expand Down Expand Up @@ -2885,8 +2877,7 @@ fn schedule_sources_collecting(
let root_id = ModuleId(0);
let mut module_ids = HashMap::default();
module_ids.insert(root_key.clone(), root_id);
let mut module_specialization_counts = HashMap::default();
module_specialization_counts.insert(root_key.name.clone(), 1usize);
let mut specialization_parents = HashMap::default();
let mut queue = vec![root_key.clone()];
let mut index = 0;
let mut elaborated = HashMap::default();
Expand Down Expand Up @@ -2923,13 +2914,7 @@ fn schedule_sources_collecting(
return Err(unsupported_sv_instance(child_key.name.clone()).into());
}
if !module_ids.contains_key(&child_key) {
let specialization_count = module_specialization_counts
.entry(child_key.name.clone())
.or_insert(0);
if *specialization_count >= MAX_SV_SPECIALIZATIONS_PER_MODULE {
return Err(sv_specialization_limit_error(child_key.name.clone()).into());
}
*specialization_count += 1;
register_specialization_parent(&child_key, &key, &mut specialization_parents)?;
let child_id = ModuleId(module_ids.len());
module_ids.insert(child_key.clone(), child_id);
queue.push(child_key);
Expand Down Expand Up @@ -3210,6 +3195,29 @@ fn restore_interface_member_paths(module: &mut SimModule, source: &AnalyzedSvMod
}
}

/// Bound parameter-changing recursion along one instantiation path. Independent
/// siblings may have any number of distinct parameter specializations. Repeated
/// identical keys are handled by the hierarchy cycle checks.
fn register_specialization_parent(
child: &LoweredSvModuleKey,
parent: &LoweredSvModuleKey,
parents: &mut HashMap<LoweredSvModuleKey, LoweredSvModuleKey>,
) -> Result<(), ParserError> {
let mut ancestor = Some(parent);
let mut occurrences = 1usize;
while let Some(key) = ancestor {
if key.name == child.name {
occurrences += 1;
if occurrences > MAX_SV_RECURSIVE_SPECIALIZATIONS {
return Err(sv_specialization_limit_error(child.name.clone()));
}
}
ancestor = parents.get(key);
}
parents.insert(child.clone(), parent.clone());
Ok(())
}

fn sv_specialization_limit_error(name: String) -> ParserError {
ParserError::unsupported(
sv::SV_FRONTEND_TRACKING_ISSUE,
Expand Down
22 changes: 22 additions & 0 deletions crates/celox-test-suite/src/sv/cases/hierarchy.vtest
Original file line number Diff line number Diff line change
Expand Up @@ -1738,3 +1738,25 @@
(assert_eq y (fourstate 0x55 0xa0))
(modify (set d 0x96))
(assert_eq y 0x96))

(case many_sibling_parameter_specializations
(source "sibling_specializations.sv" #"
module Leaf #(parameter ID=0)(input wire [7:0] x, output wire [7:0] q);
assign q=x ^ 8'(ID);
endmodule
module Top(input wire [7:0] x, output wire [7:0] first, last);
wire [7:0] lanes[65];
for (genvar n=0; n<65; n=n+1) begin : siblings
Leaf #(.ID(n)) u(.x(x), .q(lanes[n]));
end
assign first=lanes[0];
assign last=lanes[64];
endmodule
"#)
(top Top)
(modify (set x 60))
(assert_eq first 60)
(assert_eq last 124)
(modify (set x 255))
(assert_eq first 255)
(assert_eq last 191))
37 changes: 10 additions & 27 deletions crates/celox-vpi/src/bin/celox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,35 +839,18 @@ fn compile_native_design(design: &Design) -> Result<NativeProgramImage, String>
.iter()
.map(|(text, path)| (text.as_str(), path.as_path()))
.collect();
let untimed = configure_sv(
// VPI advances time and dispatches callbacks even for a process-free
// DUT. Compile its process-capable image directly, rather than first
// compiling an untimed image and repeating analysis and optimization
// when that builder discovers a process.
let simulation = configure_sv(
design,
celox::Simulator::from_sv_sources(refs.clone(), &design.top),
celox::Simulation::from_sv_sources(refs, &design.top),
)
.compile_native();
let image = match untimed {
Ok(simulator) => {
report_warnings(simulator.warnings())?;
simulator.into_program_image()
}
// A design with processes runs as a timed simulation, in step
// with the VPI time callbacks.
Err(error)
if matches!(
error.kind(),
celox::SimulatorErrorKind::ProcessRequiresSimulation(_)
) =>
{
let simulation = configure_sv(
design,
celox::Simulation::from_sv_sources(refs, &design.top),
)
.compile_native()
.map_err(|error| format!("compilation failed:\n{error}"))?;
report_warnings(simulation.warnings())?;
simulation.into_program_image()
}
Err(error) => return Err(format!("compilation failed:\n{error}")),
};
.compile_native()
.map_err(|error| format!("compilation failed:\n{error}"))?;
report_warnings(simulation.warnings())?;
let image = simulation.into_program_image();
return Ok(image);
}
#[cfg(not(feature = "systemverilog"))]
Expand Down
6 changes: 6 additions & 0 deletions crates/celox/tests/frontends/systemverilog/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,3 +776,9 @@ fn rejects_malformed_non_ansi_port_declarations() {
assert!(error.contains(message), "{source}: {error}");
}
}

sv_backends! {
fn many_sibling_parameter_specializations(sim) {
@case "hierarchy::many_sibling_parameter_specializations";
}
}
24 changes: 24 additions & 0 deletions crates/celox/tests/frontends/systemverilog/review_regressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8989,3 +8989,27 @@ fn single_bit_array_driver_windows_still_reject_overlaps() {
assert!(error.contains("multiple variable drivers"), "{error}");
}
}

#[test]
fn mixed_hierarchies_accept_many_sibling_specializations() {
let veryl = "module Top(x: input logic<8>, y: output logic<8>) { inst tree: $sv::Root(x, y); }";
let sv = "module Leaf #(parameter ID=0)(input wire [7:0] x, output wire [7:0] y);
assign y=x ^ 8'(ID); endmodule
module Root(input wire [7:0] x, output wire [7:0] y);
wire [7:0] lanes[65];
for(genvar n=0;n<65;n=n+1) begin: g
Leaf #(.ID(n)) u(.x(x),.y(lanes[n]));
end
assign y=lanes[64]; endmodule";
let mut sim = Simulator::from_mixed_sources(
vec![(veryl, Path::new("top.veryl"))],
vec![(sv, Path::new("siblings.sv"))],
"Top",
)
.build_cranelift()
.unwrap();
let x = sim.signal("x");
let y = sim.signal("y");
sim.modify(|io| io.set(x, 60u8)).unwrap();
assert_eq!(sim.get(y), BigUint::from(124u8));
}
18 changes: 16 additions & 2 deletions scripts/mergify.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ test("lightweight queue priority requires actual skipped product checks and succ

test("emergency labels authorize normal admission and outrank lightweight checks", () => {
const priorities = queueConfig.split("priority_rules:\n")[1].split("queue_rules:\n")[0];
const emergency = priorities.split(" - name: Lightweight validated changes first")[0];
const emergency = priorities.split(" - name: Priority merges without interruption")[0];
assert.match(emergency, /name: Emergency merges first/);
assert.match(emergency, /conditions:\n - label = merge-urgent/);
assert.match(emergency, /priority: 10000/);
assert.match(emergency, /allow_checks_interruption: true/);
const admission = queueConfig.split("pull_request_rules:\n")[1];
const authorize = admission.split(" - name: Queue explicitly requested merges")[0];
assert.match(authorize, /label = merge-urgent/);
assert.match(authorize, /- or:\n - label = merge-urgent\n - label = merge-priority/);
assert.match(authorize, /actions:\n label:\n add:\n - merge-ready/);
for (const guard of ["-label = release:hold", "-label = dequeued", "-draft", "-conflict"])
assert.ok(authorize.includes(` - ${guard}`), guard);
Expand All @@ -214,3 +214,17 @@ test("emergency labels authorize normal admission and outrank lightweight checks
assert.match(authorize, /Depends-On:/);
assert.doesNotMatch(authorize, /queue:|merge:|remove:/);
});


test("priority requests pass waiting work without interrupting running checks", () => {
const rules = queueConfig.split("priority_rules:\n")[1].split("queue_rules:\n")[0]
.split(/^ - name: /m).slice(1);
assert.equal(rules.length, 3);
assert.match(rules[0], /^Emergency merges first/);
assert.match(rules[1], /^Priority merges without interruption/);
assert.match(rules[1], /conditions:\n - label = merge-priority/);
assert.match(rules[1], /priority: 9000/);
assert.match(rules[1], /allow_checks_interruption: false/);
assert.doesNotMatch(rules[1], /check-success|check-skipped/);
assert.match(rules[2], /^Lightweight validated changes first/);
});
Loading