Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring file & namespace #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,4 @@ fpga/.Xil/
# vscode temp file
.vscode/
.bloop
.metals/
6 changes: 6 additions & 0 deletions .metals/metals.lock.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#FileLock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来 .metals 中的文件在修改 gitignore 之前被仓库跟踪了?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops,我只是删除了本地的但没有revert回去,我改一下再push

#Mon Oct 24 22:46:26 CST 2022
server=localhost\:42597
hostName=localhost
method=file
id=1840a758cb97dd43e099648973046290a4902dd73eb
Binary file added .metals/metals.mv.db
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/scala/bus/simplebus/SimpleBus.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import utils._
import bus.axi4._
import bus.memport._

sealed abstract class SimpleBusBundle extends Bundle with HasNutCoreParameter
abstract class SimpleBusBundle extends Bundle with HasNutCoreParameter

object SimpleBusCmd {
// req
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/nutcore/Bundle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package nutcore
import chisel3._
import chisel3.util._

import nutcore.backend._

class CtrlSignalIO extends NutCoreBundle {
val src1Type = Output(SrcType())
val src2Type = Output(SrcType())
Expand Down
16 changes: 11 additions & 5 deletions src/main/scala/nutcore/NutCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore.frontend._
import nutcore.backend._

import nutcore.mem.cache._
import nutcore.mem.tlb._

import bus.simplebus._
import bus.axi4._
import utils._
Expand Down Expand Up @@ -98,15 +104,15 @@ class NutCore(implicit val p: NutCoreConfig) extends NutCoreModule {

// Frontend
val frontend = (Settings.get("IsRV32"), Settings.get("EnableOutOfOrderExec")) match {
case (true, _) => Module(new Frontend_embedded)
case (false, true) => Module(new Frontend_ooo)
case (false, false) => Module(new Frontend_inorder)
case (true, _) => Module(new FrontendEmbedded)
case (false, true) => Module(new FrontendDynamic)
case (false, false) => Module(new FrontendSequential)
}

// Backend
if (EnableOutOfOrderExec) {
val mmioXbar = Module(new SimpleBusCrossbarNto1(if (HasDcache) 2 else 3))
val backend = Module(new Backend_ooo)
val backend = Module(new BackendDynamic)
PipelineVector2Connect(new DecodeIO, frontend.io.out(0), frontend.io.out(1), backend.io.in(0), backend.io.in(1), frontend.io.flushVec(1), 16)
backend.io.flush := frontend.io.flushVec(2)
frontend.io.redirect <> backend.io.redirect
Expand Down Expand Up @@ -143,7 +149,7 @@ class NutCore(implicit val p: NutCoreConfig) extends NutCoreModule {
io.mmio <> mmioXbar.io.out

} else {
val backend = Module(new Backend_inorder)
val backend = Module(new BackendSequential)

PipelineVector2Connect(new DecodeIO, frontend.io.out(0), frontend.io.out(1), backend.io.in(0), backend.io.in(1), frontend.io.flushVec(1), 4)

Expand Down
43 changes: 43 additions & 0 deletions src/main/scala/nutcore/backend/BackendCommons.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**************************************************************************************
* Copyright (c) 2020 Institute of Computing Technology, CAS
* Copyright (c) 2020 University of Chinese Academy of Sciences
*
* NutShell is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._
import bus.simplebus._
import difftest._

trait HasBackendConst{
// val multiIssue = true
val robSize = 16
val robWidth = 2
val robInstCapacity = robSize * robWidth
val checkpointSize = 4 // register map checkpoint size
val brTagWidth = log2Up(checkpointSize)
val prfAddrWidth = log2Up(robSize) + log2Up(robWidth) // physical rf addr width

val DispatchWidth = 2
val CommitWidth = 2
val RetireWidth = 2

val enableCheckpoint = true
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
/**************************************************************************************
* Copyright (c) 2020 Institute of Computing Technology, CAS
* Copyright (c) 2020 University of Chinese Academy of Sciences
*
* NutShell is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

package nutcore

package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._
import bus.simplebus._
import difftest._

trait HasBackendConst{
// val multiIssue = true
val robSize = 16
val robWidth = 2
val robInstCapacity = robSize * robWidth
val checkpointSize = 4 // register map checkpoint size
val brTagWidth = log2Up(checkpointSize)
val prfAddrWidth = log2Up(robSize) + log2Up(robWidth) // physical rf addr width

val DispatchWidth = 2
val CommitWidth = 2
val RetireWidth = 2

val enableCheckpoint = true
}

// NutShell/Argo Out Of Order Execution Backend
class Backend_ooo(implicit val p: NutCoreConfig) extends NutCoreModule with HasRegFileParameter with HasBackendConst{
class BackendDynamic(implicit val p: NutCoreConfig) extends NutCoreModule with HasRegFileParameter with HasBackendConst{

val io = IO(new Bundle {
// EXU
Expand Down Expand Up @@ -666,35 +638,3 @@ class Backend_ooo(implicit val p: NutCoreConfig) extends NutCoreModule with HasR
}

}

class Backend_inorder(implicit val p: NutCoreConfig) extends NutCoreModule {
val io = IO(new Bundle {
val in = Vec(2, Flipped(Decoupled(new DecodeIO)))
val flush = Input(UInt(2.W))
val dmem = new SimpleBusUC(addrBits = VAddrBits)
val memMMU = Flipped(new MemMMUIO)

val redirect = new RedirectIO
})

val isu = Module(new ISU)
val exu = Module(new EXU)
val wbu = Module(new WBU)

PipelineConnect(isu.io.out, exu.io.in, exu.io.out.fire(), io.flush(0))
PipelineConnect(exu.io.out, wbu.io.in, true.B, io.flush(1))

isu.io.in <> io.in

isu.io.flush := io.flush(0)
exu.io.flush := io.flush(1)

isu.io.wb <> wbu.io.wb
io.redirect <> wbu.io.redirect
// forward
isu.io.forward <> exu.io.forward

io.memMMU.imem <> exu.io.memMMU.imem
io.memMMU.dmem <> exu.io.memMMU.dmem
io.dmem <> exu.io.dmem
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package nutcore

package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._

// Out of Order Execution Pipeline for NutShell/Argo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
* See the Mulan PSL v2 for more details.
***************************************************************************************/

package nutcore
package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._
import difftest._


object physicalRFTools{
def getPRFAddr(robIndex: UInt, bank: UInt): UInt = {
Cat(robIndex, bank(0))
Expand Down Expand Up @@ -110,7 +113,7 @@ class ROB(implicit val p: NutCoreConfig) extends NutCoreModule with HasInstrType
val rmtMap = Reg(Vec(NRReg, UInt(prfAddrWidth.W)))
val rmtValid = RegInit(VecInit(Seq.fill(NRReg)(false.B)))

sealed class Checkpoint extends NutCoreBundle {
class Checkpoint extends NutCoreBundle {
val map = Vec(NRReg, UInt(prfAddrWidth.W))
val valid = Vec(NRReg, Bool())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* See the Mulan PSL v2 for more details.
***************************************************************************************/

package nutcore
package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._

trait HasRSConst{
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/nutcore/backend/fu/ALU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore.frontend.instr_fetch.branch_predict._

import utils._
import difftest._
import top.Settings
Expand Down
44 changes: 44 additions & 0 deletions src/main/scala/nutcore/backend/sequential/BackendSequential.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

package nutcore.backend

import chisel3._
import chisel3.util._
import chisel3.util.experimental.BoringUtils

import nutcore._

import utils._
import bus.simplebus._
import difftest._

class BackendSequential(implicit val p: NutCoreConfig) extends NutCoreModule {
val io = IO(new Bundle {
val in = Vec(2, Flipped(Decoupled(new DecodeIO)))
val flush = Input(UInt(2.W))
val dmem = new SimpleBusUC(addrBits = VAddrBits)
val memMMU = Flipped(new MemMMUIO)

val redirect = new RedirectIO
})

val isu = Module(new ISU)
val exu = Module(new EXU)
val wbu = Module(new WBU)

PipelineConnect(isu.io.out, exu.io.in, exu.io.out.fire(), io.flush(0))
PipelineConnect(exu.io.out, wbu.io.in, true.B, io.flush(1))

isu.io.in <> io.in

isu.io.flush := io.flush(0)
exu.io.flush := io.flush(1)

isu.io.wb <> wbu.io.wb
io.redirect <> wbu.io.redirect
// forward
isu.io.forward <> exu.io.forward

io.memMMU.imem <> exu.io.memMMU.imem
io.memMMU.dmem <> exu.io.memMMU.dmem
io.dmem <> exu.io.dmem
}
Loading