Compare commits

..

No commits in common. "load_store" and "master" have entirely different histories.

6 changed files with 38 additions and 1415 deletions

View file

@ -19,7 +19,6 @@ use std::{
borrow::Cow, borrow::Cow,
fmt, fmt,
marker::PhantomData, marker::PhantomData,
num::NonZeroU64,
ops::{ControlFlow, Range}, ops::{ControlFlow, Range},
}; };
@ -2984,19 +2983,6 @@ pub enum LoadStoreWidth {
Width64Bit, Width64Bit,
} }
impl LoadStoreWidth {
#[hdl]
pub fn access_byte_size_sim(this: &<Self as Type>::SimValue) -> NonZeroU64 {
#[hdl(sim)]
match this {
Self::Width8Bit => const { NonZeroU64::new(1).unwrap() },
Self::Width16Bit => const { NonZeroU64::new(2).unwrap() },
Self::Width32Bit => const { NonZeroU64::new(4).unwrap() },
Self::Width64Bit => const { NonZeroU64::new(8).unwrap() },
}
}
}
#[hdl(cmp_eq)] #[hdl(cmp_eq)]
pub enum LoadStoreConversion { pub enum LoadStoreConversion {
ZeroExt, ZeroExt,

View file

@ -127,46 +127,7 @@ impl AddressRange {
}, },
} }
} }
pub const fn is_overlapping(self, other: Self) -> bool {
self.contains(other.start().0) || other.contains(self.start().0)
} }
}
const _: () = {
const N: u64 = 4;
const fn is_overlapping_reference(range1: AddressRange, range2: AddressRange) -> bool {
// we just need to check values < N since all starts/ends are < N
let mut v = 0;
while v < N {
if range1.contains(v) && range2.contains(v) {
return true;
}
v += 1;
}
false
}
let mut start1 = 0;
while start1 < N {
let mut end1 = 0;
while end1 < N {
let mut start2 = 0;
while start2 < N {
let mut end2 = 0;
while end2 < N {
let range1 = AddressRange::from_wrapping_range_inclusive(start1..=end1);
let range2 = AddressRange::from_wrapping_range_inclusive(start2..=end2);
assert!(
range1.is_overlapping(range2) == is_overlapping_reference(range1, range2)
);
end2 += 1;
}
start2 += 1;
}
end1 += 1;
}
start1 += 1;
}
};
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, serde::Serialize, serde::Deserialize)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, serde::Serialize, serde::Deserialize)]
#[non_exhaustive] #[non_exhaustive]

View file

@ -8,7 +8,6 @@ use crate::{
MOpVariantVisitOps, MOpVariantVisitor, MOpVisitVariants, RenamedMOp, mop_enum, MOpVariantVisitOps, MOpVariantVisitor, MOpVisitVariants, RenamedMOp, mop_enum,
}, },
rename_execute_retire::ExecuteToUnitInterface, rename_execute_retire::ExecuteToUnitInterface,
unit::load_store::LoadStoreToDCacheInterface,
}; };
use fayalite::{ use fayalite::{
bundle::{Bundle, BundleType}, bundle::{Bundle, BundleType},
@ -19,7 +18,6 @@ use serde::{Deserialize, Serialize};
use std::ops::ControlFlow; use std::ops::ControlFlow;
pub mod alu_branch; pub mod alu_branch;
pub mod load_store;
macro_rules! all_units { macro_rules! all_units {
( (
@ -335,7 +333,7 @@ all_units! {
#[create_dyn_unit_fn = |config, unit_index, filter| todo!()] #[create_dyn_unit_fn = |config, unit_index, filter| todo!()]
#[extract(transformed_move_mop, transformed_move_mop_sim, transformed_move_mop_sim_ref, transformed_move_mop_sim_mut)] #[extract(transformed_move_mop, transformed_move_mop_sim, transformed_move_mop_sim_ref, transformed_move_mop_sim_mut)]
TransformedMove(TransformedMoveOp), TransformedMove(TransformedMoveOp),
#[create_dyn_unit_fn = |config, unit_index, filter| load_store::LoadStore::new(config, unit_index, filter).to_dyn()] #[create_dyn_unit_fn = |config, unit_index, filter| todo!()]
#[extract(load_store_mop, load_store_mop_sim, load_store_mop_sim_ref, load_store_mop_sim_mut)] #[extract(load_store_mop, load_store_mop_sim, load_store_mop_sim_ref, load_store_mop_sim_mut)]
LoadStore(LoadStoreMOp<DestReg, SrcReg>), LoadStore(LoadStoreMOp<DestReg, SrcReg>),
} }
@ -389,13 +387,6 @@ impl RenamedMOpFilter for () {
} }
} }
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct UnitIO {
pub cd: Option<Expr<ClockDomain>>,
pub from_execute: Expr<ExecuteToUnitInterface<PhantomConst<CpuConfig>>>,
pub to_d_cache: Option<Expr<LoadStoreToDCacheInterface<PhantomConst<CpuConfig>>>>,
}
pub trait UnitTrait: pub trait UnitTrait:
'static + Send + Sync + std::fmt::Debug + fayalite::intern::SupportsPtrEqWithTypeId 'static + Send + Sync + std::fmt::Debug + fayalite::intern::SupportsPtrEqWithTypeId
{ {
@ -404,7 +395,11 @@ pub trait UnitTrait:
fn ty(&self) -> Self::Type; fn ty(&self) -> Self::Type;
fn unit_kind(&self) -> UnitKind; fn unit_kind(&self) -> UnitKind;
fn module(&self) -> Interned<Module<Self::Type>>; fn module(&self) -> Interned<Module<Self::Type>>;
fn io(&self, this: Expr<Self::Type>) -> UnitIO; fn cd(&self, this: Expr<Self::Type>) -> Option<Expr<ClockDomain>>;
fn from_execute(
&self,
this: Expr<Self::Type>,
) -> Expr<ExecuteToUnitInterface<PhantomConst<CpuConfig>>>;
fn to_dyn(&self) -> DynUnit; fn to_dyn(&self) -> DynUnit;
} }
@ -439,8 +434,15 @@ impl UnitTrait for DynUnit {
self.unit.module() self.unit.module()
} }
fn io(&self, this: Expr<Self::Type>) -> UnitIO { fn cd(&self, this: Expr<Self::Type>) -> Option<Expr<ClockDomain>> {
self.unit.io(this) self.unit.cd(this)
}
fn from_execute(
&self,
this: Expr<Self::Type>,
) -> Expr<ExecuteToUnitInterface<PhantomConst<CpuConfig>>> {
self.unit.from_execute(this)
} }
fn to_dyn(&self) -> DynUnit { fn to_dyn(&self) -> DynUnit {
@ -466,8 +468,15 @@ impl<T: UnitTrait + Clone + std::hash::Hash + Eq> UnitTrait for DynUnitWrapper<T
self.0.module().canonical().intern_sized() self.0.module().canonical().intern_sized()
} }
fn io(&self, this: Expr<Self::Type>) -> UnitIO { fn cd(&self, this: Expr<Self::Type>) -> Option<Expr<ClockDomain>> {
self.0.io(Expr::from_bundle(this)) self.0.cd(Expr::from_bundle(this))
}
fn from_execute(
&self,
this: Expr<Self::Type>,
) -> Expr<ExecuteToUnitInterface<PhantomConst<CpuConfig>>> {
self.0.from_execute(Expr::from_bundle(this))
} }
fn to_dyn(&self) -> DynUnit { fn to_dyn(&self) -> DynUnit {

View file

@ -18,7 +18,7 @@ use crate::{
ExecuteToUnitInterface, GlobalState, NextPcPredictorOp, RenamedMOp, UnitCausedCancel, ExecuteToUnitInterface, GlobalState, NextPcPredictorOp, RenamedMOp, UnitCausedCancel,
UnitFinishCauseCancel, UnitInputsReady, UnitOutputReady, UnitFinishCauseCancel, UnitInputsReady, UnitOutputReady,
}, },
unit::{DynUnit, DynUnitWrapper, RenamedMOpFilter, UnitIO, UnitKind, UnitTrait}, unit::{DynUnit, DynUnitWrapper, RenamedMOpFilter, UnitKind, UnitTrait},
}; };
use fayalite::{ use fayalite::{
expr::CastToImpl, expr::CastToImpl,
@ -1613,12 +1613,15 @@ impl UnitTrait for AluBranch {
self.module self.module
} }
fn io(&self, this: Expr<Self::Type>) -> UnitIO { fn cd(&self, _this: Expr<Self::Type>) -> Option<Expr<ClockDomain>> {
UnitIO { None
cd: None,
from_execute: this.from_execute,
to_d_cache: None,
} }
fn from_execute(
&self,
this: Expr<Self::Type>,
) -> Expr<ExecuteToUnitInterface<PhantomConst<CpuConfig>>> {
this.from_execute
} }
fn to_dyn(&self) -> DynUnit { fn to_dyn(&self) -> DynUnit {

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@ use cpu::{
DecodeAndRunSingleInsnInput, DecodeAndRunSingleInsnOutput, DecodeOneInsnInput, DecodeAndRunSingleInsnInput, DecodeAndRunSingleInsnOutput, DecodeOneInsnInput,
DecodeOneInsnMaxMOpCount, decode_and_run_single_insn, DecodeOneInsnMaxMOpCount, decode_and_run_single_insn,
}, },
unit::{RenamedMOpFilter, UnitIO, UnitKind, UnitMOp, UnitTrait}, unit::{RenamedMOpFilter, UnitKind, UnitMOp, UnitTrait},
util::array_vec::ArrayVec, util::array_vec::ArrayVec,
}; };
use fayalite::{ use fayalite::{
@ -91,20 +91,12 @@ fn formal_harness(
dyn_unit.module(), dyn_unit.module(),
SourceLocation::caller(), SourceLocation::caller(),
); );
let UnitIO {
cd: unit_cd,
from_execute: unit_from_execute,
to_d_cache,
} = dyn_unit.io(unit);
if let Some(unit_cd) = unit_cd {
connect(unit_cd, cd);
}
connect( connect(
unit_from_execute, dyn_unit.from_execute(unit),
ExecuteToUnitInterfaces::unit_fields(decode_and_run.to_units)[unit_index], ExecuteToUnitInterfaces::unit_fields(decode_and_run.to_units)[unit_index],
); );
if let Some(to_d_cache) = to_d_cache { if let Some(unit_cd) = dyn_unit.cd(unit) {
unimplemented!("to_d_cache for {unit:?}: {to_d_cache:?}"); connect(unit_cd, cd);
} }
} }
hdl_assert(cd.clk, !decode_and_run.error, ""); hdl_assert(cd.clk, !decode_and_run.error, "");