aboutsummaryrefslogtreecommitdiff
path: root/VexRiscv/src/test/scala/vexriscv/experimental/Experiments.scala
blob: 1fead218109d8f1e18d8a067a12a520b0a4e58d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package vexriscv.experimental

import spinal.core._

class Stageable[T <: Data](val dataType : T) extends HardType[T](dataType) with Nameable{
  setWeakName(this.getClass.getSimpleName.replace("$",""))
}

trait Stage{
  def read[T <: Data](stageable : Stageable[T]) : T
  def write[T <: Data](stageable : Stageable[T], value : T, cond : Bool = null) : Unit

  def haltBySelf   : Bool   //user settable, stuck the instruction, should only be set by the instruction itself
  def haltByOthers : Bool   //When settable, stuck the instruction, should only be set by something else than the stucked instruction
  def removeIt     : Bool   //When settable, unschedule the instruction as if it was never executed (no side effect)
  def flushAll     : Bool   //When settable, unschedule instructions in the current stage and all prior ones

  def isValid        : Bool //Inform if a instruction is in the current stage
  def isStuck        : Bool //Inform if the instruction is stuck (haltItself || haltByOther)
  def isStuckByOthers: Bool //Inform if the instruction is stuck by sombody else
  def isRemoved      : Bool //Inform if the instruction is going to be unschedule the current cycle
  def isFlushed      : Bool //Inform if the instruction is flushed (flushAll set in the current or subsequents stages)
  def isFiring       : Bool //Inform if the current instruction will go to the next stage the next cycle (isValid && !isStuck && !removeIt)
}

abstract class UnusedStage extends Stage
abstract class AsyncStage extends Stage
abstract class CycleStage extends Stage
abstract class SyncStage extends Stage
abstract class CutStage extends Stage

abstract class PipelineStd{
  val prefetch, fetch, decode, execute, memory, writeback = 0
}