forked from libre-chip/cpu
move MemoryInterface and related types to crate::main_memory_and_io
This commit is contained in:
parent
2a1813bff3
commit
cd7823e81d
4 changed files with 65 additions and 49 deletions
|
|
@ -8,6 +8,10 @@ use crate::{
|
|||
CpuConfigLog2FetchWidthInBytes, CpuConfigLog2L1ICacheLineCount,
|
||||
CpuConfigMaxFetchesInFlight, PhantomConstCpuConfig,
|
||||
},
|
||||
main_memory_and_io::{
|
||||
MemoryInterface, MemoryOperationErrorKind, MemoryOperationFinish,
|
||||
MemoryOperationFinishKind, MemoryOperationKind, MemoryOperationStart,
|
||||
},
|
||||
next_pc::{
|
||||
FETCH_BLOCK_ID_WIDTH, NextPcToFetchInterface, NextPcToFetchInterfaceInner, ResetStatus,
|
||||
ResetSteps, SimValueDefault,
|
||||
|
|
@ -22,51 +26,6 @@ use fayalite::{
|
|||
};
|
||||
use std::{collections::VecDeque, fmt};
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationKind {
|
||||
Read,
|
||||
Write,
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryOperationStart<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub kind: MemoryOperationKind,
|
||||
pub addr: UInt<64>,
|
||||
pub write_data: ArrayType<UInt<8>, CpuConfigFetchWidthInBytes<C>>,
|
||||
pub fetch_block_id: UInt<{ FETCH_BLOCK_ID_WIDTH }>, // for debugging
|
||||
pub config: C,
|
||||
}
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationErrorKind {
|
||||
Generic,
|
||||
}
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationFinishKind {
|
||||
Success(MemoryOperationKind),
|
||||
Error(MemoryOperationErrorKind),
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryOperationFinish<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub kind: MemoryOperationFinishKind,
|
||||
pub read_data: ArrayType<UInt<8>, CpuConfigFetchWidthInBytes<C>>,
|
||||
pub config: C,
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryInterface<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub start: ReadyValid<MemoryOperationStart<C>>,
|
||||
#[hdl(flip)]
|
||||
pub finish: ReadyValid<MemoryOperationFinish<C>>,
|
||||
/// for debugging
|
||||
#[hdl(flip)]
|
||||
pub next_fetch_block_ids:
|
||||
HdlOption<ArrayVec<UInt<{ FETCH_BLOCK_ID_WIDTH }>, CpuConfigMaxFetchesInFlight<C>>>,
|
||||
pub config: C,
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct FetchToDecodeInterfaceInner<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub start_pc: UInt<64>,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ pub mod config;
|
|||
pub mod decoder;
|
||||
pub mod fetch;
|
||||
pub mod instruction;
|
||||
pub mod main_memory_and_io;
|
||||
pub mod next_pc;
|
||||
pub mod powerisa_instructions_xml;
|
||||
pub mod reg_alloc;
|
||||
|
|
|
|||
56
crates/cpu/src/main_memory_and_io.rs
Normal file
56
crates/cpu/src/main_memory_and_io.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
// See Notices.txt for copyright information
|
||||
|
||||
use crate::{
|
||||
config::{
|
||||
CpuConfig, CpuConfigFetchWidthInBytes, CpuConfigMaxFetchesInFlight, PhantomConstCpuConfig,
|
||||
},
|
||||
next_pc::FETCH_BLOCK_ID_WIDTH,
|
||||
util::array_vec::ArrayVec,
|
||||
};
|
||||
use fayalite::{prelude::*, util::ready_valid::ReadyValid};
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationKind {
|
||||
Read,
|
||||
Write,
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryOperationStart<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub kind: MemoryOperationKind,
|
||||
pub addr: UInt<64>,
|
||||
pub write_data: ArrayType<UInt<8>, CpuConfigFetchWidthInBytes<C>>,
|
||||
pub fetch_block_id: UInt<{ FETCH_BLOCK_ID_WIDTH }>, // for debugging
|
||||
pub config: C,
|
||||
}
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationErrorKind {
|
||||
Generic,
|
||||
}
|
||||
|
||||
#[hdl]
|
||||
pub enum MemoryOperationFinishKind {
|
||||
Success(MemoryOperationKind),
|
||||
Error(MemoryOperationErrorKind),
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryOperationFinish<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub kind: MemoryOperationFinishKind,
|
||||
pub read_data: ArrayType<UInt<8>, CpuConfigFetchWidthInBytes<C>>,
|
||||
pub config: C,
|
||||
}
|
||||
|
||||
#[hdl(no_static)]
|
||||
pub struct MemoryInterface<C: PhantomConstGet<CpuConfig> + PhantomConstCpuConfig> {
|
||||
pub start: ReadyValid<MemoryOperationStart<C>>,
|
||||
#[hdl(flip)]
|
||||
pub finish: ReadyValid<MemoryOperationFinish<C>>,
|
||||
/// for debugging
|
||||
#[hdl(flip)]
|
||||
pub next_fetch_block_ids:
|
||||
HdlOption<ArrayVec<UInt<{ FETCH_BLOCK_ID_WIDTH }>, CpuConfigMaxFetchesInFlight<C>>>,
|
||||
pub config: C,
|
||||
}
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
use cpu::{
|
||||
config::{CpuConfig, UnitConfig},
|
||||
fetch::{
|
||||
FetchToDecodeInterface, FetchToDecodeInterfaceInner, MemoryInterface,
|
||||
MemoryOperationErrorKind, MemoryOperationFinish, MemoryOperationFinishKind,
|
||||
MemoryOperationKind, MemoryOperationStart, fetch,
|
||||
fetch::{FetchToDecodeInterface, FetchToDecodeInterfaceInner, fetch},
|
||||
main_memory_and_io::{
|
||||
MemoryInterface, MemoryOperationErrorKind, MemoryOperationFinish,
|
||||
MemoryOperationFinishKind, MemoryOperationKind, MemoryOperationStart,
|
||||
},
|
||||
next_pc::{FETCH_BLOCK_ID_WIDTH, NextPcToFetchInterface, NextPcToFetchInterfaceInner},
|
||||
unit::UnitKind,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue