WIP: completed stages of next-pc logic, still need to combine them into a pipeline

This commit is contained in:
Jacob Lifshay 2025-12-03 21:27:26 -08:00
parent 033d5d4f34
commit 231f5e72ec
Signed by: programmerjake
SSH key fingerprint: SHA256:HnFTLGpSm4Q4Fj502oCFisjZSoakwEuTsJJMSke63RQ
8 changed files with 1708 additions and 587 deletions

View file

@ -17,3 +17,4 @@ version.workspace = true
[dependencies]
fayalite.workspace = true
serde.workspace = true
simple-mermaid.workspace = true

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
stateDiagram-v2
direction LR
state "Next PC" as next_pc
[*] --> next_pc
state "Fetch/Decode" as fetch_decode
next_pc --> fetch_decode
state "Branch Predictor" as br_pred
next_pc --> br_pred
br_pred --> next_pc: cancel following
state "Post-decode" as post_decode
fetch_decode --> post_decode
br_pred --> post_decode
post_decode --> next_pc: cancel following
state "Rename\nDispatch\nExecute" as execute
post_decode --> execute
state "Retire" as retire
execute --> retire
retire --> [*]
retire --> next_pc: cancel following

View file

@ -578,7 +578,8 @@ pub fn reg_alloc(config: &CpuConfig) {
connect(unit_to_reg_alloc.unit_forwarding_info, unit_forwarding_info);
connect(
unit_forwarding_info.unit_output_writes[unit_index],
unit_forwarding_info.ty()
unit_forwarding_info
.ty()
.unit_output_writes
.element()
.HdlNone(),

View file

@ -272,10 +272,7 @@ pub fn alu_branch(config: &CpuConfig, unit_index: usize) {
connect(unit_to_reg_alloc, unit_base.unit_to_reg_alloc);
connect(unit_base.cd, cd);
connect(unit_base.execute_start.ready, true);
connect(
unit_base.execute_end,
unit_base.execute_end.ty().HdlNone(),
);
connect(unit_base.execute_end, unit_base.execute_end.ty().HdlNone());
#[hdl]
if let HdlSome(execute_start) = ReadyValid::firing_data(unit_base.execute_start) {
#[hdl]

View file

@ -34,6 +34,18 @@ impl<T: Type, N: Size> ArrayVec<T, N> {
len: 0u8.cast_to(self.len),
}
}
#[hdl]
pub fn new_full_sim(
self,
elements: impl ToSimValueWithType<ArrayType<T, N>>,
) -> SimValue<Self> {
let elements = elements.to_sim_value_with_type(self.elements);
#[hdl(sim)]
Self {
elements,
len: self.elements.len().to_sim_value_with_type(self.len),
}
}
pub fn element(self) -> T {
self.elements.element()
}