WIP: adding ExecuteToUnitInterface::is_no_longer_speculative_prediction
Some checks failed
/ test (pull_request) Failing after 2m42s

This commit is contained in:
Jacob Lifshay 2026-07-31 16:51:04 -07:00
parent a81d85d9c0
commit 59970cd316
Signed by: programmerjake
SSH key fingerprint: SHA256:HnFTLGpSm4Q4Fj502oCFisjZSoakwEuTsJJMSke63RQ
5 changed files with 62 additions and 0 deletions

View file

@ -203,6 +203,16 @@ pub struct UnitMOpCantCauseCancel<C: PhantomConstGet<CpuConfig>> {
pub config: C,
}
/// This tells the Unit that if [`Self::cant_cause_cancel_id`] can no longer cause a cancel
/// (either via [`UnitMOpCantCauseCancel`] or [`UnitFinishCauseCancel`] without a cancel),
/// then [`Self::predicted_no_longer_speculative_id`] will no longer be speculative.
#[hdl(no_static)]
pub struct UnitMOpIsNoLongerSpeculativePrediction<C: PhantomConstGet<CpuConfig>> {
pub cant_cause_cancel_id: MOpId,
pub predicted_no_longer_speculative_id: MOpId,
pub config: C,
}
/// Interface from the Rename/Execute/Retire control logic to a single Unit.
///
/// ## State diagram for a single &micro;Op in a Unit
@ -223,6 +233,8 @@ pub struct ExecuteToUnitInterface<C: PhantomConstGet<CpuConfig>> {
pub inputs_ready: HdlOption<UnitInputsReady<C>>,
/// if [`Self::unit_outputs_ready`] is `false`, then this is always [`HdlNone`]
pub is_no_longer_speculative: HdlOption<UnitMOpIsNoLongerSpeculative<C>>,
/// if [`Self::unit_outputs_ready`] is `false`, then this is always [`HdlNone`]
pub is_no_longer_speculative_prediction: HdlOption<UnitMOpIsNoLongerSpeculativePrediction<C>>,
/// this uses [`Self::unit_outputs_ready`] as a shared ready flag
#[hdl(flip)]
pub cant_cause_cancel: HdlOption<UnitMOpCantCauseCancel<C>>,

View file

@ -204,6 +204,7 @@ fn connect_to_unit_nop<C: Type + PhantomConstGet<CpuConfig>>(
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel: _,
output_ready: _,
finish_cause_cancel: _,
@ -218,6 +219,10 @@ fn connect_to_unit_nop<C: Type + PhantomConstGet<CpuConfig>>(
is_no_longer_speculative,
is_no_longer_speculative.ty().HdlNone(),
);
connect(
is_no_longer_speculative_prediction,
is_no_longer_speculative_prediction.ty().HdlNone(),
);
connect(unit_outputs_ready, false);
connect(cancel_all.data, HdlNone());
}
@ -506,6 +511,7 @@ impl<C: PhantomConstCpuConfig, MaxMOpCount: Size> DecodeAndRunSingleInsnState<C,
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel: _, // we don't track if it can cause a cancel
output_ready,
finish_cause_cancel,
@ -513,6 +519,10 @@ impl<C: PhantomConstCpuConfig, MaxMOpCount: Size> DecodeAndRunSingleInsnState<C,
cancel_all,
config: _,
} = to_unit;
connect(
is_no_longer_speculative_prediction,
is_no_longer_speculative_prediction.ty().HdlNone(),
);
connect(unit_outputs_ready, true);
connect(cancel_all.data, HdlNone());
#[hdl]

View file

@ -1260,6 +1260,7 @@ pub fn alu_branch(
enqueue,
inputs_ready,
is_no_longer_speculative: _, // we don't care about being speculative for these instructions
is_no_longer_speculative_prediction: _,
cant_cause_cancel,
output_ready,
finish_cause_cancel,

View file

@ -988,6 +988,7 @@ async fn load_store_impl(
enqueue,
inputs_ready: _,
is_no_longer_speculative: _,
is_no_longer_speculative_prediction: _,
cant_cause_cancel,
output_ready,
finish_cause_cancel,
@ -1042,6 +1043,7 @@ async fn load_store_impl(
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel,
output_ready,
finish_cause_cancel,
@ -1066,6 +1068,15 @@ async fn load_store_impl(
{
state.from_execute_is_no_longer_speculative(is_no_longer_speculative);
}
#[hdl(sim)]
if let HdlSome(is_no_longer_speculative_prediction) = sim
.read_past(is_no_longer_speculative_prediction, cd.clk)
.await
{
state.from_execute_is_no_longer_speculative_prediction(
is_no_longer_speculative_prediction,
);
}
if sim.read_past_bool(unit_outputs_ready, cd.clk).await {
#[hdl(sim)]
if let HdlSome(cant_cause_cancel) = sim.read_past(cant_cause_cancel, cd.clk).await {
@ -1221,6 +1232,7 @@ pub fn load_store(
enqueue,
inputs_ready: _,
is_no_longer_speculative: _,
is_no_longer_speculative_prediction: _,
cant_cause_cancel,
output_ready,
finish_cause_cancel,

View file

@ -2149,6 +2149,7 @@ async fn load_store_tester_impl<C: PhantomConstCpuConfig>(
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel: _,
output_ready: _,
finish_cause_cancel: _,
@ -2168,6 +2169,11 @@ async fn load_store_tester_impl<C: PhantomConstCpuConfig>(
state.to_load_store_is_no_longer_speculative(),
)
.await;
sim.write(
is_no_longer_speculative_prediction,
state.to_load_store_is_no_longer_speculative_prediction(),
)
.await;
} else {
sim.write(enqueue.data, enqueue.ty().data.HdlNone()).await;
sim.write(inputs_ready, inputs_ready.ty().HdlNone()).await;
@ -2176,6 +2182,11 @@ async fn load_store_tester_impl<C: PhantomConstCpuConfig>(
is_no_longer_speculative.ty().HdlNone(),
)
.await;
sim.write(
is_no_longer_speculative_prediction,
is_no_longer_speculative_prediction.ty().HdlNone(),
)
.await;
}
sim.write(cancel_all.data, state.to_load_store_cancel_all())
.await;
@ -2190,6 +2201,7 @@ async fn load_store_tester_impl<C: PhantomConstCpuConfig>(
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel,
output_ready,
finish_cause_cancel,
@ -2213,6 +2225,15 @@ async fn load_store_tester_impl<C: PhantomConstCpuConfig>(
{
state.handle_to_load_store_is_no_longer_speculative(is_no_longer_speculative);
}
#[hdl(sim)]
if let HdlSome(is_no_longer_speculative_prediction) = sim
.read_past(is_no_longer_speculative_prediction, cd.clk)
.await
{
state.handle_to_load_store_is_no_longer_speculative_prediction(
is_no_longer_speculative_prediction,
);
}
if sim.read_past_bool(unit_outputs_ready, cd.clk).await {
#[hdl(sim)]
if let HdlSome(cant_cause_cancel) = sim.read_past(cant_cause_cancel, cd.clk).await {
@ -2293,6 +2314,7 @@ fn load_store_tester(config: PhantomConst<CpuConfig>) {
enqueue,
inputs_ready,
is_no_longer_speculative,
is_no_longer_speculative_prediction,
cant_cause_cancel: _,
output_ready: _,
finish_cause_cancel: _,
@ -2318,6 +2340,11 @@ fn load_store_tester(config: PhantomConst<CpuConfig>) {
is_no_longer_speculative.ty().HdlNone(),
)
.await;
sim.write(
is_no_longer_speculative_prediction,
is_no_longer_speculative_prediction.ty().HdlNone(),
)
.await;
sim.write(unit_outputs_ready, false).await;
sim.write(cancel_all.data, HdlNone()).await;
sim.write(test_passed, false).await;