Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 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
6b2c83c
refactor: modify some comment
Chrisqcwx Mar 27, 2023
0d3d633
Merge branch 'dev-yhy' of github.com:Invalid-Syntax-NSCSCC/invalid-cp…
Chrisqcwx Mar 27, 2023
1971768
deal with conflicts
Chrisqcwx Mar 27, 2023
97514d6
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Mar 27, 2023
e6cb6d4
refactor: refactor Mul module with booth algorithm and wallance tree.
Chrisqcwx Mar 27, 2023
03ddec4
fix: memLoadStoreInfoPort lack 1 cycle delay; feat: add CsrRegs
Chrisqcwx Mar 28, 2023
65881d7
refactor: reformat
Chrisqcwx Mar 28, 2023
dab47b2
fix: fix some bugs
Chrisqcwx Mar 28, 2023
3803d9d
feat: add some Exception; issue: add some TODO
Chrisqcwx Mar 28, 2023
e114584
fix: fix uninitialize error in issueStage
Chrisqcwx Mar 29, 2023
66365e1
feat: add some exceptions
Chrisqcwx Mar 29, 2023
7c26830
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Mar 29, 2023
1d06144
refactor: rename WbDebugPort --> InstInfoPort
Chrisqcwx Mar 29, 2023
3ab4472
feat: add cu's control of gprWrite
Chrisqcwx Mar 29, 2023
7726a4f
fix: delete divisor is zero exception (according to the instruction m…
Chrisqcwx Mar 30, 2023
f5b8001
refactor: add bundle-UInt support in csr
Chrisqcwx Mar 31, 2023
fa3c315
fix: deal conflicts
Chrisqcwx Mar 31, 2023
0604065
feat: add many csr regs
Chrisqcwx Mar 31, 2023
1b68755
feat: add clear and flush output in Cu
Chrisqcwx Mar 31, 2023
3b4fda5
feat: add clear and flush in pipeline
Chrisqcwx Mar 31, 2023
c8e1354
feat: add ecode and esubcode in cu
Chrisqcwx Apr 1, 2023
f40023b
refactor: reformat
Chrisqcwx Apr 1, 2023
0f41cc0
feat: add new pc in cu
Chrisqcwx Apr 1, 2023
c1e5fde
fix: delete some temp file
Chrisqcwx Apr 1, 2023
e68bd35
fix: deal with conflicts
Chrisqcwx Apr 1, 2023
8bc5b94
refactor: minor modified in csr
Chrisqcwx Apr 2, 2023
7dbd64a
fix: some bug in cu; feat: add some exception deal in cu and csr
Chrisqcwx Apr 2, 2023
cd38c1c
feat: add some assignment on csr regs
Chrisqcwx Apr 2, 2023
1430e7c
refactor: move some bundles from ctrl/bundles to ctrl/csrRegsBundles
Chrisqcwx Apr 2, 2023
e81a943
refactor: move exeOp from MemLoadStoreNdPort -> InstInfoPort
Chrisqcwx Apr 2, 2023
849f0f9
fix: fix some wrong in writing csrRegs[llbctl]
Chrisqcwx Apr 2, 2023
0b43c77
refactor: set the badvaddr control between csr and cu into a bundle
Chrisqcwx Apr 2, 2023
d74afa8
fix: fix some bug in llbit and fix a spelling error
Chrisqcwx Apr 2, 2023
b6e19f4
fix: fix assignment error in csr
Chrisqcwx Apr 2, 2023
f9ace03
refactor: reformat
Chrisqcwx Apr 2, 2023
de5a8a9
fix: fix an assign error in csr
Chrisqcwx Apr 2, 2023
ab970fe
feat: add some csr assignment
Chrisqcwx Apr 2, 2023
e9e30e9
fix: fix state behavior error in ExeStage
Chrisqcwx Apr 3, 2023
2b9c17b
docs: add a README in pipeline
Chrisqcwx Apr 3, 2023
646007b
feat: add decode of csr; fix: fix state behavior error in exe
Chrisqcwx Apr 3, 2023
2e0bd28
fix: delete the pipeline control in pc
Chrisqcwx Apr 4, 2023
b39e7ca
feat: add scoreboard for csr
Chrisqcwx Apr 4, 2023
e6e0059
fix: deal with conflicts
Chrisqcwx Apr 4, 2023
79afb30
refactor: replace isFlush port in instQueue with pipelinecontrol port
Chrisqcwx Apr 4, 2023
6c5e000
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 5, 2023
cae7838
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 7, 2023
751d375
fix: fix the init value of PC
Chrisqcwx Apr 8, 2023
6f334ba
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 8, 2023
6cd3454
feat: add csrScoreboardBlocking in IssueStage
Chrisqcwx Apr 8, 2023
5023345
feat: add stable counter
Chrisqcwx Apr 9, 2023
122da68
fix: fix some bugs
Chrisqcwx Apr 9, 2023
a99b2cd
feat: add data forward for RegRead and free scoreboard
Chrisqcwx Apr 9, 2023
214e495
refactor: remove some comment
Chrisqcwx Apr 9, 2023
2804c28
refactor: replace the * in mulStage
Chrisqcwx Apr 11, 2023
6c955b6
feat: add etrn inst; fix: fix decode bug in decoder_special
Chrisqcwx Apr 11, 2023
a67bf69
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 14, 2023
51a6dfb
docs: add some comment in readme for pipeline
Chrisqcwx Apr 15, 2023
7f59de4
refactor: jump branch new Pc calc by exe send to Ctrl Unit to decide …
Chrisqcwx Apr 17, 2023
01a0593
feat: try MultiInstQueue(do not worry, it does not connect to the cpu)
Chrisqcwx Apr 17, 2023
10bd5c0
refactor: decode in issueStage -> decode in instQueue
Chrisqcwx Apr 17, 2023
e775068
refactor: rename some ports
Chrisqcwx Apr 17, 2023
a1d64b3
test: test inst queue
Chrisqcwx Apr 17, 2023
c3ea059
feat: add BiCounter
Chrisqcwx Apr 17, 2023
03d449c
feat: add BiInstQueue (test success)
Chrisqcwx Apr 18, 2023
3cb8a2d
feat: add decode in BiInstQueue
Chrisqcwx Apr 18, 2023
4e9da76
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 18, 2023
78c5973
add BiIssueStage(unfinish)
Chrisqcwx Apr 18, 2023
07e9b7d
feat: add reorder buffer (unfinished)
Chrisqcwx Apr 18, 2023
17d559b
feat: improve rob (unfinished)
Chrisqcwx Apr 18, 2023
775f0e4
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 18, 2023
03c64c0
fix: remove data forward temporarily
Chrisqcwx Apr 18, 2023
676a8ce
feat: improve rob (unfinished)
Chrisqcwx Apr 18, 2023
2fac508
refactor: move some util module to utils
Chrisqcwx Apr 19, 2023
1f4c0c2
feat: add MinFinder
Chrisqcwx Apr 19, 2023
b483829
test: test MinFinder success
Chrisqcwx Apr 19, 2023
d11ece5
fix: fix logic bug in rob
Chrisqcwx Apr 19, 2023
af31b73
feat: finish RobStage (without test)
Chrisqcwx Apr 19, 2023
814e538
feat: add read ports in rob; refactor: rename DataForwardReadPort -> …
Chrisqcwx Apr 19, 2023
adb0903
feat: imporve BiIssueStage (好难啊啊啊啊啊啊)
Chrisqcwx Apr 19, 2023
435d9b8
refactor: remove some comments
Chrisqcwx Apr 19, 2023
084c860
feat: add IssueInfoWithValid Bundle
Chrisqcwx Apr 19, 2023
c1cbf10
feat: improve BiIssueStage
Chrisqcwx Apr 19, 2023
32c457b
feat: write a lot lot lot of bullshit in BiIssueStage
Chrisqcwx Apr 19, 2023
e6950e2
feat: finish BiIssueStage (without test) (with so many bullshit)
Chrisqcwx Apr 19, 2023
befc393
Merge branch 'main' of github.com:Invalid-Syntax-NSCSCC/invalid-cpu i…
Chrisqcwx Apr 19, 2023
4fcd9dd
fix : fix some bugs
Chrisqcwx Apr 19, 2023
ff4582f
refactor: replace all the bullshit with new implement in BiIssueStage
Chrisqcwx Apr 20, 2023
701d43b
feat: add memAccessPort in ExeStage
Chrisqcwx Apr 20, 2023
de08c98
refactor: remove some comment
Chrisqcwx Apr 20, 2023
d8e7540
fix: fix commit bug in rob
Chrisqcwx Apr 21, 2023
a6d9bbc
add support for robId in BiIssueStage
Chrisqcwx Apr 21, 2023
60d5f78
feat: add isUnsigned port in MemAccessPort
Chrisqcwx Apr 21, 2023
70a3918
refactor: tidy up the test files' path
Chrisqcwx Apr 21, 2023
49e5e0c
fix: fix some bugs in robStage
Chrisqcwx Apr 21, 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
28 changes: 14 additions & 14 deletions src/src/CoreCpuTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CoreCpuTop extends Module {
val scoreboard = Module(new Scoreboard)
val csrScoreBoard = Module(new Scoreboard(changeNum = Param.csrScoreBoardChangeNum, regNum = Count.csrReg))

val dataforward = Module(new DataForwardStage)
// val dataforward = Module(new DataForwardStage)

val regFile = Module(new RegFile)
val pc = Module(new Pc)
Expand All @@ -131,9 +131,8 @@ class CoreCpuTop extends Module {
// Pc
pc.io.newPc := cu.io.newPc


// TODO: debug crossbar
io.axi <> simpleFetchStage.io.axiMasterInterface
io.axi <> simpleFetchStage.io.axiMasterInterface
crossbar.io <> DontCare
// // AXI top <> AXI crossbar
// crossbar.io.slaves <> DontCare
Expand Down Expand Up @@ -231,9 +230,10 @@ class CoreCpuTop extends Module {
issueStage.io.csrRegScores := csrScoreBoard.io.regScores
csrScoreBoard.io.occupyPorts := issueStage.io.csrOccupyPorts

scoreboard.io.freePorts(0) := exeStage.io.freePorts
scoreboard.io.freePorts(1) := memStage.io.freePorts
scoreboard.io.freePorts(2) := wbStage.io.freePorts(0)
// scoreboard.io.freePorts(0) := exeStage.io.freePorts
// scoreboard.io.freePorts(1) := memStage.io.freePorts
// scoreboard.io.freePorts(2) := wbStage.io.freePorts(0)
scoreboard.io.freePorts(0) := wbStage.io.freePorts(0)
csrScoreBoard.io.freePorts(0) := wbStage.io.csrFreePorts(0)

// Reg-read stage
Expand All @@ -242,9 +242,9 @@ class CoreCpuTop extends Module {
regReadStage.io.gprReadPorts(1) <> regFile.io.readPorts(1)
regReadStage.io.pipelineControlPort := cu.io.pipelineControlPorts(PipelineStageIndex.regReadStage)
regReadStage.io.instInfoPassThroughPort.in := issueStage.io.instInfoPassThroughPort.out
regReadStage.io.dataforwardPorts.zip(dataforward.io.readPorts).foreach {
case (regRead, df) => regRead <> df
}
// regReadStage.io.dataforwardPorts.zip(dataforward.io.readPorts).foreach {
// case (regRead, df) => regRead <> df
// }

// Execution stage
exeStage.io.exeInstPort := regReadStage.io.exeInstPort
Expand All @@ -253,8 +253,8 @@ class CoreCpuTop extends Module {

// Mem stage
memStage.io.gprWritePassThroughPort.in := exeStage.io.gprWritePort
memStage.io.memLoadStoreInfoPort := exeStage.io.memLoadStoreInfoPort // TODO: MemLoadStoreInfoPort is deprecated
memStage.io.pipelineControlPort := cu.io.pipelineControlPorts(PipelineStageIndex.memStage)
// memStage.io.memLoadStoreInfoPort := exeStage.io.memLoadStoreInfoPort // TODO: MemLoadStoreInfoPort is deprecated
// memStage.io.pipelineControlPort := //cu.io.pipelineControlPorts(PipelineStageIndex.memStage)
memStage.io.memAccessPort <> DontCare
memStage.io.instInfoPassThroughPort.in := exeStage.io.instInfoPassThroughPort.out

Expand All @@ -264,13 +264,13 @@ class CoreCpuTop extends Module {
regFile.io.writePort := cu.io.gprWritePassThroughPorts.out(0)

// data forward
dataforward.io.writePorts(0) := exeStage.io.gprWritePort
dataforward.io.writePorts(1) := memStage.io.gprWritePassThroughPort.out
// dataforward.io.writePorts(0) := exeStage.io.gprWritePort
// dataforward.io.writePorts(1) := memStage.io.gprWritePassThroughPort.out

// Ctrl unit
cu.io.instInfoPorts(0) := wbStage.io.instInfoPassThroughPort.out
cu.io.exeStallRequest := exeStage.io.stallRequest
cu.io.memStallRequest := memStage.io.stallRequest
cu.io.memStallRequest := false.B // memStage.io.stallRequest *********** TODO
cu.io.gprWritePassThroughPorts.in(0) := wbStage.io.gprWritePort
cu.io.csrValues := csr.io.csrValues
cu.io.stableCounterReadPort <> stableCounter.io
Expand Down
2 changes: 1 addition & 1 deletion src/src/axi/AxiCrossbarRead.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class AxiCrossbarRead(
val slaveAruserMux = WireInit(IntSlavesAr(aGrantEncoded).user)
val slaveArvalidMux = WireInit(IntArValid(aGrantEncoded)(index) && aGrantValid)
val slaveArreadyMux = Wire(Bool())
slaveAridMux := IntSlavesAr(aGrantEncoded).id | (aGrantEncoded << Param.Width.Axi.slaveId).asUInt
slaveAridMux := IntSlavesAr(aGrantEncoded).id | (aGrantEncoded << Param.Width.Axi.slaveId).asUInt

IntArReady(index) := (aGrantValid && slaveArreadyMux) << aGrantEncoded

Expand Down
2 changes: 1 addition & 1 deletion src/src/common/Pc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Pc(
val io = IO(new Bundle {
val pc = Output(UInt(Width.Reg.data))
val isNext = Input(Bool())
// 异常处理
// 异常处理 + 分支跳转
val newPc = Input(new PcSetPort)
})

Expand Down
211 changes: 211 additions & 0 deletions src/src/frontend/BiInstQueue.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
package frontend

import chisel3._
import chisel3.util._

import spec._
import pipeline.dispatch.bundles.InstInfoBundle
import control.bundles.PipelineControlNDPort
import frontend._
import pipeline.dispatch.bundles.{DecodeOutNdPort, DecodePort, InstInfoBundle, IssuedInfoNdPort, ScoreboardChangeNdPort}
import pipeline.dispatch.decode.{
Decoder,
Decoder_2R,
Decoder_2RI12,
Decoder_2RI14,
Decoder_2RI16,
Decoder_3R,
Decoder_4R,
Decoder_special
}
import pipeline.writeback.bundles.InstInfoNdPort
import utils.BiCounter
// 尝试写双发射的queue,未接入,不用管它
// assert: enqueuePorts总是最低的几位有效
class BiInstQueue(
val queueLength: Int = Param.instQueueLength,
val issueNum: Int = Param.issueInstInfoMaxNum)
extends Module {
val io = IO(new Bundle {
// val isFlush = Input(Bool())
val pipelineControlPort = Input(new PipelineControlNDPort)
val enqueuePorts = Vec(issueNum, Flipped(Decoupled(new InstInfoBundle)))

// `InstQueue` -> `IssueStage`
val dequeuePorts = Vec(
issueNum,
Decoupled(new Bundle {
val decode = new DecodeOutNdPort
val instInfo = new InstInfoNdPort
})
)

// val debugPort = Output(Vec(issueNum, new InstInfoBundle))
})
require(issueNum == 2)
// val queue =
// Queue(io.enqueuePorts(0), entries = queueLength, pipe = false, flow = true, flush = Some(io.pipelineControlPort.flush))

// io.dequeuePort <> queue

val ram = RegInit(VecInit(Seq.fill(queueLength)(InstInfoBundle.default)))
val enq_ptr = Module(new BiCounter(queueLength))
val deq_ptr = Module(new BiCounter(queueLength))

enq_ptr.io.inc := 0.U
enq_ptr.io.flush := io.pipelineControlPort.flush
deq_ptr.io.inc := 0.U
deq_ptr.io.flush := io.pipelineControlPort.flush

val maybeFull = RegInit(false.B)
val ptrMatch = enq_ptr.io.value === deq_ptr.io.value
val isEmpty = ptrMatch && !maybeFull
val isFull = ptrMatch && maybeFull

val storeNum = WireDefault(
Mux(
enq_ptr.io.value > deq_ptr.io.value,
enq_ptr.io.value - deq_ptr.io.value,
(queueLength.U - deq_ptr.io.value) + enq_ptr.io.value
)
)
val emptyNum = WireDefault(queueLength.U - storeNum)

val isEmptyByOne = WireDefault(storeNum === 1.U)
val isFullByOne = WireDefault(emptyNum === 1.U)

io.enqueuePorts(0).ready := !isFull
io.enqueuePorts(1).ready := !isFullByOne

io.dequeuePorts(0).valid := !isEmpty
io.dequeuePorts(1).valid := !isEmptyByOne

// enqueue
val numWidth: Int = log2Ceil(issueNum)

val enqEn = (io.enqueuePorts.map(port => (port.ready && port.valid)))
// val enqueueNum = io.enqueuePorts.map(_.valid).map(_.asUInt).reduce(_ + _)
// 优化
val enqueueNum = Cat(
enqEn(0) & enqEn(1),
enqEn(0) ^ enqEn(1)
)

// dequeue
val deqEn = (io.dequeuePorts.map(port => (port.ready && port.valid)))
// val dequeueNum = io.dequeuePorts.map(_.valid).map(_.asUInt).reduce(_ + _)
val dequeueNum = Cat(
deqEn(0) & deqEn(1),
deqEn(0) ^ deqEn(1)
)

when(enqueueNum > dequeueNum) {
maybeFull := true.B
}.elsewhen(enqueueNum < dequeueNum) {
maybeFull := false.B
}

when(!isFull) {
when(enqueueNum(1)) {
// 请求入队两个
ram(enq_ptr.io.value) := io.enqueuePorts(0).bits
when(isFullByOne) {
// 只剩一个位置
enq_ptr.io.inc := 1.U
}.otherwise {
// 直接加两个
ram(enq_ptr.io.value + 1.U) := io.enqueuePorts(1).bits
enq_ptr.io.inc := 2.U
}
}.elsewhen(enqueueNum(0)) {
// 请求入队一个
ram(enq_ptr.io.value) := io.enqueuePorts(0).bits
enq_ptr.io.inc := 1.U
}
}

when(!isEmpty) {
when(dequeueNum(1)) {
// 请求出队两个
when(isEmptyByOne) {
// 只有一条指令
deq_ptr.io.inc := 1.U
}.otherwise {
// 正常出队两条
deq_ptr.io.inc := 2.U
}
}.elsewhen(dequeueNum(0)) {
// 请求出队一个
deq_ptr.io.inc := 1.U
}
}
// Decode

val decodeInstInfos = WireDefault(VecInit(ram(deq_ptr.io.value), ram(deq_ptr.io.value + 1.U)))

// io.debugPort(0) := decodeInstInfos(0)
// io.debugPort(1) := decodeInstInfos(1)

// Select a decoder

val decoders0 = Seq(
Module(new Decoder_2RI12),
Module(new Decoder_2RI14),
Module(new Decoder_2RI16),
Module(new Decoder_2R),
Module(new Decoder_3R),
// Module(new Decoder_4R),
Module(new Decoder_special)
)

val decoders1 = Seq(
Module(new Decoder_2RI12),
Module(new Decoder_2RI14),
Module(new Decoder_2RI16),
Module(new Decoder_2R),
Module(new Decoder_3R),
// Module(new Decoder_4R),
Module(new Decoder_special)
)

decoders0.foreach(_.io.instInfoPort := decodeInstInfos(0))
decoders1.foreach(_.io.instInfoPort := decodeInstInfos(1))

val decoderWires = Wire(Vec(2, Vec(decoders0.length, new DecodeOutNdPort)))
// decoderWires.zip(decoders).foreach {
// case (port, decoder) =>
// port := decoder.io.out
// }
decoderWires.zip(Seq(decoders0, decoders1)).foreach {
case (decoderWire, decoders) =>
decoderWire.zip(decoders).foreach {
case (port, decoder) =>
port := decoder.io.out
}
}

// val decoderIndex = WireDefault(OHToUInt(Cat(decoderWires.map(_.isMatched).reverse)))
// val selectedDecoder = WireDefault(decoderWires(decoderIndex))
val decoderIndices = WireDefault(VecInit(decoderWires.map { decoderWire =>
OHToUInt(Cat(decoderWire.map(_.isMatched).reverse))
}))
val selectedDecoders = WireDefault(VecInit(decoderWires.zip(decoderIndices).map {
case (decoderWire, decoderIndex) =>
decoderWire(decoderIndex)
}))

io.dequeuePorts.lazyZip(selectedDecoders).lazyZip(decodeInstInfos).zipWithIndex.foreach {
case ((dequeuePort, selectedDecoder, decodeInstInfo), index) =>
dequeuePort.bits.decode := selectedDecoder
// InstInfoNdPort.setDefault(dequeuePort.bits.instInfo)
dequeuePort.bits.instInfo := InstInfoNdPort.default
dequeuePort.bits.instInfo.pc := decodeInstInfo.pcAddr
dequeuePort.bits.instInfo.inst := decodeInstInfo.inst
dequeuePort.bits.instInfo
.exceptionRecords(CsrRegs.ExceptionIndex.ine) := !decoderWires(index).map(_.isMatched).reduce(_ || _)
}

when(io.pipelineControlPort.flush) {
ram.foreach(_ := InstInfoBundle.default)
}
}
10 changes: 7 additions & 3 deletions src/src/frontend/InstQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ class InstQueue(val queueLength: Int = Param.instQueueLength) extends Module {
case (port, decoder) =>
port := decoder.io.out
}

val isMatched = WireDefault(decoderWires.map(_.isMatched).reduce(_ || _))
val decoderIndex = WireDefault(OHToUInt(Cat(decoderWires.map(_.isMatched).reverse)))
val selectedDecoder = WireDefault(decoderWires(decoderIndex))

io.dequeuePort.bits.decode := selectedDecoder
InstInfoNdPort.setDefault(io.dequeuePort.bits.instInfo)
io.dequeuePort.bits.instInfo.pc := decodeInstInfo.pcAddr
io.dequeuePort.bits.instInfo.inst := decodeInstInfo.inst
// InstInfoNdPort.setDefault(io.dequeuePort.bits.instInfo)
io.dequeuePort.bits.instInfo := InstInfoNdPort.default
io.dequeuePort.bits.instInfo.exceptionRecords(CsrRegs.ExceptionIndex.ine) := !isMatched
io.dequeuePort.bits.instInfo.pc := decodeInstInfo.pcAddr
io.dequeuePort.bits.instInfo.inst := decodeInstInfo.inst

// io.dequeuePort <> queue

Expand Down
22 changes: 17 additions & 5 deletions src/src/memory/bundles/MemAccessNdPort.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,27 @@ package memory.bundles

import chisel3._
import common.enums.ReadWriteSel
import chisel3.experimental.BundleLiterals.AddBundleLiteralConstructor
import spec._

class MemAccessNdPort extends Bundle {
val isValid = Bool()
val rw = ReadWriteSel
val addr = UInt(Width.Reg.data)
val isValid = Bool()
val rw = ReadWriteSel()
val addr = UInt(Width.Reg.data)
val isUnsigned = Bool()

val write = new Bundle {
val data = UInt(Width.Reg.data)
val mask = UInt(Width.Reg.data)
val data = UInt(Width.Mem.data)
val mask = UInt((Width.Mem._data / byteLength).W)
}
}

object MemAccessNdPort {
val default = (new MemAccessNdPort).Lit(
_.isValid -> false.B,
_.rw -> ReadWriteSel.read,
_.addr -> zeroWord,
_.write.data -> zeroWord,
_.write.mask -> zeroWord
)
}
3 changes: 2 additions & 1 deletion src/src/pipeline/dataforward/DataForwardStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import common.bundles.RfWriteNdPort
import common.bundles.RfReadPort
import pipeline.dataforward.bundles._

import pipeline.dataforward.bundles.ReadPortWithValid
class DataForwardStage(
dataForwardNum: Int = Param.dataForwardInputNum,
readNum: Int = Param.regFileReadNum)
extends Module {
val io = IO(new Bundle {
val writePorts = Input(Vec(dataForwardNum, new RfWriteNdPort))
val readPorts = Vec(readNum, new DataForwardReadPort)
val readPorts = Vec(readNum, new ReadPortWithValid)
})

io.readPorts.foreach { readPort =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chisel3._
import common.bundles.RfReadPort
import spec._

class DataForwardReadPort extends Bundle {
class ReadPortWithValid extends Bundle {
val en = Input(Bool())
val addr = Input(UInt(Width.Reg.addr))
val valid = Output(Bool())
Expand Down
Loading