Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6aa3592
feat: add some inst
Chrisqcwx Mar 19, 2023
6a5a383
feat: add branch inst
Chrisqcwx Mar 20, 2023
1562843
feat: add branch inst
Chrisqcwx Mar 20, 2023
53284e8
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu
Chrisqcwx Mar 20, 2023
20b2f67
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Mar 20, 2023
651dd92
feat: add branch inst
Chrisqcwx Mar 20, 2023
87b6016
fix: fix some bug in MulStage
Chrisqcwx Mar 20, 2023
4099b34
feat: add load store inst
Chrisqcwx Mar 20, 2023
b9592b2
feat: add load and store inst
Chrisqcwx Mar 21, 2023
f175e9e
Merge branch 'dev-yhy'
Chrisqcwx Mar 21, 2023
1cab7e2
fix: deal conflict
Chrisqcwx Mar 21, 2023
bae2228
fix: fix some bug in ExeStage
Chrisqcwx Mar 21, 2023
d240163
fix: add decoder fallback
Chrisqcwx Mar 21, 2023
dbfe974
delete temp issueStage
Chrisqcwx Mar 21, 2023
a1ab1a1
refactor: add insts in SimpleCpuSpec
Chrisqcwx Mar 22, 2023
aabdf2d
refactor: comments
Mar 22, 2023
7c3452c
fix: make bullshit in `IssueStage` smell better
Mar 22, 2023
8db4f3b
fix: when you are free to go, even you are still in blocking state, y…
Mar 22, 2023
9ce6d48
test some inst
Chrisqcwx Mar 22, 2023
a8d83f2
Merge branch 'dev-yhy' of github.com:Invalid-Syntax-NSCSCC/invalid-cp…
Chrisqcwx Mar 22, 2023
0f3eba8
fix: now it's not a mess in `IssueStage`
Mar 23, 2023
d7ea58c
Merge branch 'dev-yhy' of github.com:Invalid-Syntax-NSCSCC/invalid-cp…
Chrisqcwx Mar 23, 2023
9bb53df
refactor: refactor exeStage with state machine
Chrisqcwx Mar 23, 2023
ad419bf
refactor: alu
Chrisqcwx Mar 23, 2023
72a6c6a
refactor: reformat
Chrisqcwx Mar 24, 2023
1dc7725
feat: avoid recalculating mul and div in alu when stall
Chrisqcwx Mar 25, 2023
035f1c3
refactor: reformat
Chrisqcwx Mar 25, 2023
6a09062
deal with conflicts
Chrisqcwx Mar 25, 2023
02fde3c
deal with conflicts
Chrisqcwx Mar 25, 2023
31e519c
feat: add some inst
Chrisqcwx Mar 25, 2023
0d52bcd
refactor: reformat
Chrisqcwx Mar 25, 2023
f8f6b2b
feat: add mem stage
Chrisqcwx Mar 26, 2023
f77c9ee
refactor: rename MemLoadStoreNdPort -> MemLoadStoreInfoNdPort
Chrisqcwx Mar 26, 2023
2f84aaf
deal with conflicts
Chrisqcwx Mar 26, 2023
ddbca6c
Merge branch 'main' into dev-yhy
rewired-gh Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/src/CoreCpuTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ class CoreCpuTop extends Module {

// Mem stage
memStage.io.gprWritePassThroughPort.in := exeStage.io.gprWritePort
memStage.io.memLoadStorePort := exeStage.io.memLoadStorePort
memStage.io.memLoadStoreInfoPort := exeStage.io.memLoadStoreInfoPort
memStage.io.pipelineControlPort := cu.io.pipelineControlPorts(PipelineStageIndex.memStage)
memStage.io.memLoadStorePort <> DontCare
memStage.io.wbDebugPassthroughPort.in := exeStage.io.wbDebugPassthroughPort.out

// Write-back stage
Expand Down
10 changes: 5 additions & 5 deletions src/src/pipeline/execution/ExeStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import pipeline.dispatch.bundles.ExeInstNdPort
import spec.ExeInst.Sel
import spec._
import pipeline.ctrl.bundles.PipelineControlNDPort
import pipeline.execution.bundles.MemLoadStoreNdPort
import pipeline.execution.bundles.MemLoadStoreInfoNdPort
import chisel3.experimental.VecLiterals._
import chisel3.experimental.BundleLiterals.AddBundleLiteralConstructor
import spec.Param.{ExeStageState => State}
Expand All @@ -20,8 +20,8 @@ class ExeStage(readNum: Int = Param.instRegReadNum) extends Module {

// TODO: Add `MemStage` in between
// `ExeStage` -> `WbStage` (next clock pulse)
val memLoadStoreInfoPort = Output(new MemLoadStoreInfoNdPort)
val gprWritePort = Output(new RfWriteNdPort)
val memLoadStorePort = Output(new MemLoadStoreNdPort)
val wbDebugPassthroughPort = new PassThroughPort(new WbDebugNdPort)

// Pipeline control signal
Expand Down Expand Up @@ -119,9 +119,9 @@ class ExeStage(readNum: Int = Param.instRegReadNum) extends Module {
}

// MemLoadStore
io.memLoadStorePort.exeOp := io.exeInstPort.exeOp
io.memLoadStoreInfoPort.exeOp := io.exeInstPort.exeOp
// store : the data to write
// preld, dbar, ibar : hint
io.memLoadStorePort.data := io.exeInstPort.rightOperand
io.memLoadStorePort.vaddr := (io.exeInstPort.leftOperand + io.exeInstPort.loadStoreImm)
io.memLoadStoreInfoPort.data := io.exeInstPort.rightOperand
io.memLoadStoreInfoPort.vaddr := (io.exeInstPort.leftOperand + io.exeInstPort.loadStoreImm)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chisel3._
import chisel3.util._
import spec._

class MemLoadStoreNdPort extends Bundle {
class MemLoadStoreInfoNdPort extends Bundle {
val exeOp = UInt(Param.Width.exeOp)
val vaddr = UInt(Width.Reg.data)
val data = UInt(Width.Reg.data)
Expand Down
14 changes: 11 additions & 3 deletions src/src/pipeline/mem/MemStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ import pipeline.dispatch.bundles.ExeInstNdPort
import spec.ExeInst.Sel
import spec._
import pipeline.ctrl.bundles.PipelineControlNDPort
import pipeline.execution.bundles.MemLoadStoreNdPort
import pipeline.execution.bundles.MemLoadStoreInfoNdPort
import chisel3.experimental.VecLiterals._
import chisel3.experimental.BundleLiterals.AddBundleLiteralConstructor
import pipeline.mem.bundles.MemLoadStorePort
import pipeline.writeback.bundles.WbDebugNdPort

class MemStage extends Module {
val io = IO(new Bundle {
// `ExeStage` -> `MemStage` -> `WbStage`
val gprWritePassThroughPort = new PassThroughPort(new RfWriteNdPort)
// `ExeStage` -> `MemStage`
val memLoadStorePort = Input(new MemLoadStoreNdPort)
val memLoadStoreInfoPort = Input(new MemLoadStoreInfoNdPort)
// `Cu` -> `MemStage`
val pipelineControlPort = Input(new PipelineControlNDPort)
// `MemStage` -> Cu
val stallRequest = Output(Bool())

// `MemStage` -> ?Ram
val memLoadStorePort = Flipped(new MemLoadStorePort)

val wbDebugPassthroughPort = new PassThroughPort(new WbDebugNdPort)
})

Expand All @@ -39,4 +42,9 @@ class MemStage extends Module {
io.gprWritePassThroughPort.out := gprWriteReg

io.stallRequest := false.B

val storeData = WireDefault(io.memLoadStoreInfoPort.data)
val hint = WireDefault(io.memLoadStoreInfoPort.data)

io.memLoadStorePort <> DontCare
}
15 changes: 15 additions & 0 deletions src/src/pipeline/mem/bundles/MemLoadStorePort.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pipeline.mem.bundles

import chisel3._
import chisel3.util._
import spec._
import chisel3.experimental.BundleLiterals.AddBundleLiteralConstructor

class MemLoadStorePort extends Bundle {
val valid = Input(Bool())
val mode = Input(Bool())
val memSel = Input(UInt(Param.Width.memSel))
val addr = Input(UInt(Width.Reg.data))
val dataWrite = Input(UInt(Width.Reg.data))
val dataRead = Output(UInt(Width.Reg.data))
}
2 changes: 2 additions & 0 deletions src/src/spec/Param.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ object Param {
val exeOp = 8.W
val simpleFetchStageState = 2.W

val memSel = 4.W

object Axi { // crossbar
val slaveId = 8
val masterId = slaveId + log2Ceil(Count.Axi.slave)
Expand Down
5 changes: 5 additions & 0 deletions src/src/spec/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ package object spec {
def getCount: Int = count
}

object ReadWriteMode {
val read = false.B
val write = true.B
}

object Width {
val inst = wordLength.W
object Reg {
Expand Down