Struct Scheduler

Source
pub(crate) struct Scheduler {
    sub_cycle: SubCycle,
    cycle: Cycle,
    exec: ExecSchedule,
    data: DataSchedule,
}
Expand description

Overall state for the simulated execution schedule

Fields§

§sub_cycle: SubCycle

Current timestamp in the schedule, in sub-cycles

Sub-cycles advance as code is generated, modeling the time taken to fetch and decode instructions.

§cycle: Cycle

Current timestamp in the schedule, in cycles

Derived from sub_cycle.

§exec: ExecSchedule

State for scheduling execution by fitting micro-ops into execution ports

§data: DataSchedule

State for scheduling register access by keeping track of data latency

Implementations§

Source§

impl Scheduler

Source

pub(crate) fn new() -> Self

Create a new empty execution schedule at cycle 0

Source

pub(crate) fn stall(&mut self) -> Result<(), ()>

Stall for one cycle.

Used when register allocation fails. Returns Ok if we had enough time, or Err if we ran out.

Source

pub(crate) fn instruction_stream_sub_cycle(&self) -> SubCycle

Return the current instruction fetch/decode timestamp in sub-cycles.

Source

fn advance(&mut self, n: usize) -> Result<(), ()>

Advance forward in time by some number of sub-cycles.

Stops just before reaching Cycle::target(), where we stop scheduling new instructions.

Source

pub(crate) fn advance_instruction_stream( &mut self, op: Opcode, ) -> Result<(), ()>

Advance time forward by the modeled duration of the instruction fetch and decode, in sub-cycles.

Returns Ok if we still have enough time to schedule more, or Err if the schedule would be full.

Source

pub(crate) fn instruction_plan(&self, op: Opcode) -> Result<InstructionPlan, ()>

Calculate a timing plan describing the cycle and execution units on which a particular opcode could run, at the earliest.

Source

pub(crate) fn commit_instruction_plan( &mut self, plan: &InstructionPlan, inst: &Instruction, )

Commit to using a plan returned by Self::instruction_plan(), for a particular concrete Instruction instance.

Marks as busy each execution unit cycle in the plan, and updates the latency for the Instruction’s destination register if it has one.

Source

pub(crate) fn register_available(&self, reg: RegisterId, cycle: Cycle) -> bool

Look up if a register will be available at or before the indicated cycle.

Source

pub(crate) fn overall_latency(&self) -> Cycle

Return the overall data latency.

This is the Cycle at which we expect every register to reach its final simulated state.

Trait Implementations§

Source§

impl Clone for Scheduler

Source§

fn clone(&self) -> Scheduler

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scheduler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scheduler

Source§

fn default() -> Scheduler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.