2014-09-12 19:15:04 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2014-09-02 22:51:57 +02:00
|
|
|
package rocketchip
|
2014-08-23 10:26:03 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2015-07-30 02:56:19 +02:00
|
|
|
import junctions._
|
2014-08-23 10:26:03 +02:00
|
|
|
import uncore._
|
|
|
|
import rocket._
|
|
|
|
import rocket.Util._
|
2015-07-14 00:46:42 +02:00
|
|
|
import zscale._
|
2015-06-26 08:17:35 +02:00
|
|
|
import scala.math.max
|
2015-07-13 23:54:26 +02:00
|
|
|
import DefaultTestSuites._
|
2014-08-23 10:26:03 +02:00
|
|
|
|
2014-10-06 22:43:40 +02:00
|
|
|
class DefaultConfig extends ChiselConfig (
|
|
|
|
topDefinitions = { (pname,site,here) =>
|
|
|
|
type PF = PartialFunction[Any,Any]
|
|
|
|
def findBy(sname:Any):Any = here[PF](site[Any](sname))(pname)
|
2015-10-02 23:23:42 +02:00
|
|
|
def genCsrAddrMap: AddrMap = {
|
|
|
|
val csrSize = (1 << 12) * (site(XLen) / 8)
|
|
|
|
val csrs = (0 until site(NTiles)).map{ i =>
|
|
|
|
AddrMapEntry(s"csr$i", None, MemSize(csrSize, AddrMapConsts.RW))
|
|
|
|
}
|
2015-10-06 19:47:38 +02:00
|
|
|
val scrSize = site(HtifKey).nSCR * (site(XLen) / 8)
|
2015-10-02 23:23:42 +02:00
|
|
|
val scr = AddrMapEntry("scr", None, MemSize(scrSize, AddrMapConsts.RW))
|
|
|
|
new AddrMap(csrs :+ scr)
|
2015-09-25 18:41:19 +02:00
|
|
|
}
|
2014-10-06 22:43:40 +02:00
|
|
|
pname match {
|
2015-07-14 00:46:42 +02:00
|
|
|
case UseZscale => false
|
2015-10-06 19:47:38 +02:00
|
|
|
case HtifKey => HtifParameters(
|
|
|
|
width = Dump("HTIF_WIDTH", 16),
|
|
|
|
nSCR = 64,
|
|
|
|
offsetBits = site(CacheBlockOffsetBits),
|
|
|
|
nCores = site(NTiles))
|
2014-10-06 22:43:40 +02:00
|
|
|
//Memory Parameters
|
|
|
|
case PAddrBits => 32
|
2015-06-26 08:17:35 +02:00
|
|
|
case PgIdxBits => 12
|
|
|
|
case PgLevels => if (site(XLen) == 64) 3 /* Sv39 */ else 2 /* Sv32 */
|
|
|
|
case PgLevelBits => site(PgIdxBits) - log2Up(site(XLen)/8)
|
|
|
|
case VPNBits => site(PgLevels) * site(PgLevelBits)
|
2014-10-06 22:43:40 +02:00
|
|
|
case PPNBits => site(PAddrBits) - site(PgIdxBits)
|
2015-06-26 08:17:35 +02:00
|
|
|
case VAddrBits => site(VPNBits) + site(PgIdxBits)
|
|
|
|
case ASIdBits => 7
|
|
|
|
case MIFTagBits => Dump("MEM_TAG_BITS",
|
|
|
|
log2Up(site(NAcquireTransactors)+2) +
|
|
|
|
log2Up(site(NBanksPerMemoryChannel)) +
|
2015-08-06 21:51:18 +02:00
|
|
|
log2Up(site(NMemoryChannels)))
|
2014-10-06 22:43:40 +02:00
|
|
|
case MIFDataBits => Dump("MEM_DATA_BITS", 128)
|
|
|
|
case MIFAddrBits => Dump("MEM_ADDR_BITS", site(PAddrBits) - site(CacheBlockOffsetBits))
|
2015-06-26 08:17:35 +02:00
|
|
|
case MIFDataBeats => site(TLDataBits)*site(TLDataBeats)/site(MIFDataBits)
|
2015-10-06 19:47:38 +02:00
|
|
|
case NastiKey => NastiParameters(
|
|
|
|
dataBits = site(MIFDataBits),
|
|
|
|
addrBits = site(PAddrBits),
|
|
|
|
idBits = site(MIFTagBits))
|
2014-10-06 22:43:40 +02:00
|
|
|
//Params used by all caches
|
|
|
|
case NSets => findBy(CacheName)
|
|
|
|
case NWays => findBy(CacheName)
|
|
|
|
case RowBits => findBy(CacheName)
|
2015-06-26 08:17:35 +02:00
|
|
|
case NTLBEntries => findBy(CacheName)
|
2014-10-06 22:43:40 +02:00
|
|
|
case "L1I" => {
|
2015-06-26 08:17:35 +02:00
|
|
|
case NSets => Knob("L1I_SETS") //64
|
|
|
|
case NWays => Knob("L1I_WAYS") //4
|
2014-10-06 22:43:40 +02:00
|
|
|
case RowBits => 4*site(CoreInstBits)
|
2015-06-26 08:17:35 +02:00
|
|
|
case NTLBEntries => 8
|
2014-10-06 22:43:40 +02:00
|
|
|
}:PF
|
|
|
|
case "L1D" => {
|
2015-06-26 08:17:35 +02:00
|
|
|
case NSets => Knob("L1D_SETS") //64
|
2014-10-06 22:43:40 +02:00
|
|
|
case NWays => Knob("L1D_WAYS") //4
|
|
|
|
case RowBits => 2*site(CoreDataBits)
|
2015-06-26 08:17:35 +02:00
|
|
|
case NTLBEntries => 8
|
2014-10-06 22:43:40 +02:00
|
|
|
}:PF
|
|
|
|
case ECCCode => None
|
|
|
|
case Replacer => () => new RandomReplacement(site(NWays))
|
2015-06-26 08:17:35 +02:00
|
|
|
case AmoAluOperandBits => site(XLen)
|
2014-10-06 22:43:40 +02:00
|
|
|
//L1InstCache
|
2015-10-06 19:47:38 +02:00
|
|
|
case BtbKey => BtbParameters()
|
2014-10-06 22:43:40 +02:00
|
|
|
//L1DataCache
|
2015-06-26 08:17:35 +02:00
|
|
|
case WordBits => site(XLen)
|
2014-10-06 22:43:40 +02:00
|
|
|
case StoreDataQueueDepth => 17
|
|
|
|
case ReplayQueueDepth => 16
|
|
|
|
case NMSHRs => Knob("L1D_MSHRS")
|
2015-08-06 21:51:18 +02:00
|
|
|
case NIOMSHRs => 1
|
2014-10-06 22:43:40 +02:00
|
|
|
case LRSCCycles => 32
|
2015-06-26 08:17:35 +02:00
|
|
|
//L2 Memory System Params
|
|
|
|
case NAcquireTransactors => 7
|
|
|
|
case L2StoreDataQueueDepth => 1
|
|
|
|
case L2DirectoryRepresentation => new NullRepresentation(site(TLNCachingClients))
|
2015-10-06 19:47:38 +02:00
|
|
|
case BuildL2CoherenceManager => (p: Parameters) =>
|
|
|
|
Module(new L2BroadcastHub()(p.alterPartial({
|
|
|
|
case InnerTLId => "L1ToL2"
|
|
|
|
case OuterTLId => "L2ToMC" })))
|
2014-10-06 22:43:40 +02:00
|
|
|
//Tile Constants
|
2015-07-13 23:54:26 +02:00
|
|
|
case BuildTiles => {
|
2015-07-14 03:56:18 +02:00
|
|
|
TestGeneration.addSuites(rv64i.map(_("p")))
|
|
|
|
TestGeneration.addSuites((if(site(UseVM)) List("pt","v") else List("pt")).flatMap(env => rv64u.map(_(env))))
|
|
|
|
TestGeneration.addSuites(if(site(NTiles) > 1) List(mtBmarks, bmarks) else List(bmarks))
|
2015-10-06 19:47:38 +02:00
|
|
|
List.fill(site(NTiles)){ (r: Bool, p: Parameters) =>
|
|
|
|
Module(new RocketTile(resetSignal = r)(p.alterPartial({case TLId => "L1ToL2"})))
|
|
|
|
}
|
2015-07-13 23:54:26 +02:00
|
|
|
}
|
2014-10-06 22:43:40 +02:00
|
|
|
case BuildRoCC => None
|
|
|
|
case NDCachePorts => 2 + (if(site(BuildRoCC).isEmpty) 0 else 1)
|
|
|
|
case NPTWPorts => 2 + (if(site(BuildRoCC).isEmpty) 0 else 3)
|
|
|
|
//Rocket Core Constants
|
2015-06-26 08:17:35 +02:00
|
|
|
case FetchWidth => 1
|
2014-10-06 22:43:40 +02:00
|
|
|
case RetireWidth => 1
|
|
|
|
case UseVM => true
|
2015-09-28 22:55:55 +02:00
|
|
|
case UsePerfCounters => true
|
2014-10-06 22:43:40 +02:00
|
|
|
case FastLoadWord => true
|
|
|
|
case FastLoadByte => false
|
|
|
|
case FastMulDiv => true
|
2015-06-26 08:17:35 +02:00
|
|
|
case XLen => 64
|
2015-07-14 03:56:18 +02:00
|
|
|
case BuildFPU => {
|
|
|
|
val env = if(site(UseVM)) List("p","pt","v") else List("p","pt")
|
|
|
|
if(site(FDivSqrt)) TestGeneration.addSuites(env.map(rv64uf))
|
|
|
|
else TestGeneration.addSuites(env.map(rv64ufNoDiv))
|
2015-10-06 19:47:38 +02:00
|
|
|
Some((p: Parameters) => Module(new FPU()(p)))
|
2015-07-14 03:56:18 +02:00
|
|
|
}
|
2015-06-26 08:17:35 +02:00
|
|
|
case FDivSqrt => true
|
2014-10-06 22:43:40 +02:00
|
|
|
case SFMALatency => 2
|
|
|
|
case DFMALatency => 3
|
|
|
|
case CoreInstBits => 32
|
2015-06-26 08:17:35 +02:00
|
|
|
case CoreDataBits => site(XLen)
|
2014-10-06 22:43:40 +02:00
|
|
|
case CoreDCacheReqTagBits => 7 + log2Up(here(NDCachePorts))
|
2015-06-26 08:17:35 +02:00
|
|
|
case NCustomMRWCSRs => 0
|
2014-10-06 22:43:40 +02:00
|
|
|
//Uncore Paramters
|
2015-07-08 02:26:07 +02:00
|
|
|
case RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock
|
2015-06-26 08:17:35 +02:00
|
|
|
case LNEndpoints => site(TLNManagers) + site(TLNClients)
|
|
|
|
case LNHeaderBits => log2Ceil(site(TLNManagers)) + log2Up(site(TLNClients))
|
|
|
|
case TLBlockAddrBits => site(PAddrBits) - site(CacheBlockOffsetBits)
|
|
|
|
case TLNClients => site(TLNCachingClients) + site(TLNCachelessClients)
|
|
|
|
case TLDataBits => site(CacheBlockBytes)*8/site(TLDataBeats)
|
|
|
|
case TLDataBeats => 4
|
2015-08-06 21:51:18 +02:00
|
|
|
case TLWriteMaskBits => (site(TLDataBits) - 1) / 8 + 1
|
2015-06-26 08:17:35 +02:00
|
|
|
case TLNetworkIsOrderedP2P => false
|
|
|
|
case TLNManagers => findBy(TLId)
|
|
|
|
case TLNCachingClients => findBy(TLId)
|
|
|
|
case TLNCachelessClients => findBy(TLId)
|
|
|
|
case TLCoherencePolicy => findBy(TLId)
|
|
|
|
case TLMaxManagerXacts => findBy(TLId)
|
|
|
|
case TLMaxClientXacts => findBy(TLId)
|
|
|
|
case TLMaxClientsPerPort => findBy(TLId)
|
|
|
|
case "L1ToL2" => {
|
|
|
|
case TLNManagers => site(NBanksPerMemoryChannel)*site(NMemoryChannels)
|
|
|
|
case TLNCachingClients => site(NTiles)
|
|
|
|
case TLNCachelessClients => site(NTiles) + 1
|
|
|
|
case TLCoherencePolicy => new MESICoherence(site(L2DirectoryRepresentation))
|
|
|
|
case TLMaxManagerXacts => site(NAcquireTransactors) + 2
|
2015-08-06 21:51:18 +02:00
|
|
|
case TLMaxClientXacts => max(site(NMSHRs) + site(NIOMSHRs),
|
2015-06-26 08:17:35 +02:00
|
|
|
if(site(BuildRoCC).isEmpty) 1
|
|
|
|
else site(RoCCMaxTaggedMemXacts))
|
|
|
|
case TLMaxClientsPerPort => if(site(BuildRoCC).isEmpty) 1 else 3
|
|
|
|
}:PF
|
|
|
|
case "L2ToMC" => {
|
|
|
|
case TLNManagers => 1
|
|
|
|
case TLNCachingClients => site(NBanksPerMemoryChannel)
|
|
|
|
case TLNCachelessClients => 0
|
|
|
|
case TLCoherencePolicy => new MEICoherence(new NullRepresentation(site(NBanksPerMemoryChannel)))
|
|
|
|
case TLMaxManagerXacts => 1
|
|
|
|
case TLMaxClientXacts => 1
|
|
|
|
case TLMaxClientsPerPort => site(NAcquireTransactors) + 2
|
|
|
|
}:PF
|
2014-10-06 22:43:40 +02:00
|
|
|
case NTiles => Knob("NTILES")
|
2015-06-26 08:17:35 +02:00
|
|
|
case NMemoryChannels => 1
|
|
|
|
case NBanksPerMemoryChannel => Knob("NBANKS")
|
|
|
|
case NOutstandingMemReqsPerChannel => site(NBanksPerMemoryChannel)*(site(NAcquireTransactors)+2)
|
|
|
|
case BankIdLSB => 0
|
2014-10-06 22:43:40 +02:00
|
|
|
case CacheBlockBytes => 64
|
|
|
|
case CacheBlockOffsetBits => log2Up(here(CacheBlockBytes))
|
|
|
|
case UseBackupMemoryPort => true
|
2015-08-06 21:51:18 +02:00
|
|
|
case MMIOBase => BigInt(1 << 30) // 1 GB
|
|
|
|
case ExternalIOStart => 2 * site(MMIOBase)
|
2015-10-02 23:23:42 +02:00
|
|
|
case NastiAddrMap => AddrMap(
|
|
|
|
AddrMapEntry("mem", None, MemSize(site(MMIOBase), AddrMapConsts.RWX)),
|
|
|
|
AddrMapEntry("conf", None, MemSubmap(site(ExternalIOStart) - site(MMIOBase), genCsrAddrMap)),
|
|
|
|
AddrMapEntry("io", Some(site(ExternalIOStart)), MemSize(2 * site(MMIOBase), AddrMapConsts.RW)))
|
2014-10-06 22:43:40 +02:00
|
|
|
}},
|
|
|
|
knobValues = {
|
2014-08-25 04:30:53 +02:00
|
|
|
case "NTILES" => 1
|
|
|
|
case "NBANKS" => 1
|
|
|
|
case "L1D_MSHRS" => 2
|
2015-06-26 08:17:35 +02:00
|
|
|
case "L1D_SETS" => 64
|
2014-08-25 04:30:53 +02:00
|
|
|
case "L1D_WAYS" => 4
|
2015-06-26 08:17:35 +02:00
|
|
|
case "L1I_SETS" => 64
|
|
|
|
case "L1I_WAYS" => 4
|
2014-08-25 04:30:53 +02:00
|
|
|
}
|
2014-10-06 22:43:40 +02:00
|
|
|
)
|
2014-08-28 22:07:54 +02:00
|
|
|
class DefaultVLSIConfig extends DefaultConfig
|
|
|
|
class DefaultCPPConfig extends DefaultConfig
|
|
|
|
|
2015-07-07 03:21:06 +02:00
|
|
|
class With2Cores extends ChiselConfig(knobValues = { case "NTILES" => 2 })
|
|
|
|
class With4Cores extends ChiselConfig(knobValues = { case "NTILES" => 4 })
|
|
|
|
class With8Cores extends ChiselConfig(knobValues = { case "NTILES" => 8 })
|
|
|
|
|
|
|
|
class With2Banks extends ChiselConfig(knobValues = { case "NBANKS" => 2 })
|
|
|
|
class With4Banks extends ChiselConfig(knobValues = { case "NBANKS" => 4 })
|
|
|
|
class With8Banks extends ChiselConfig(knobValues = { case "NBANKS" => 8 })
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
class WithL2Cache extends ChiselConfig(
|
|
|
|
(pname,site,here) => pname match {
|
|
|
|
case "L2_CAPACITY_IN_KB" => Knob("L2_CAPACITY_IN_KB")
|
|
|
|
case "L2Bank" => {
|
|
|
|
case NSets => (((here[Int]("L2_CAPACITY_IN_KB")*1024) /
|
|
|
|
site(CacheBlockBytes)) /
|
|
|
|
site(NBanksPerMemoryChannel)*site(NMemoryChannels)) /
|
|
|
|
site(NWays)
|
|
|
|
case NWays => Knob("L2_WAYS")
|
|
|
|
case RowBits => site(TLDataBits)
|
|
|
|
}: PartialFunction[Any,Any]
|
|
|
|
case NAcquireTransactors => 2
|
|
|
|
case NSecondaryMisses => 4
|
|
|
|
case L2DirectoryRepresentation => new FullRepresentation(site(TLNCachingClients))
|
2015-10-06 19:47:38 +02:00
|
|
|
case BuildL2CoherenceManager => (p: Parameters) =>
|
|
|
|
Module(new L2HellaCacheBank()(p.alterPartial({
|
2015-06-26 08:17:35 +02:00
|
|
|
case CacheName => "L2Bank"
|
|
|
|
case InnerTLId => "L1ToL2"
|
2015-10-06 19:47:38 +02:00
|
|
|
case OuterTLId => "L2ToMC"})))
|
2015-06-26 08:17:35 +02:00
|
|
|
},
|
|
|
|
knobValues = { case "L2_WAYS" => 8; case "L2_CAPACITY_IN_KB" => 2048 }
|
|
|
|
)
|
|
|
|
|
2015-07-07 03:21:06 +02:00
|
|
|
class WithL2Capacity2048 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 2048 })
|
|
|
|
class WithL2Capacity1024 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 1024 })
|
|
|
|
class WithL2Capacity512 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 512 })
|
|
|
|
class WithL2Capacity256 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 256 })
|
|
|
|
class WithL2Capacity128 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 128 })
|
|
|
|
class WithL2Capacity64 extends ChiselConfig(knobValues = { case "L2_CAPACITY_IN_KB" => 64 })
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
class DefaultL2Config extends ChiselConfig(new WithL2Cache ++ new DefaultConfig)
|
2015-07-07 03:21:06 +02:00
|
|
|
class DefaultL2VLSIConfig extends ChiselConfig(new WithL2Cache ++ new DefaultVLSIConfig)
|
|
|
|
class DefaultL2CPPConfig extends ChiselConfig(new WithL2Cache ++ new DefaultCPPConfig)
|
|
|
|
class DefaultL2FPGAConfig extends ChiselConfig(new WithL2Capacity64 ++ new WithL2Cache ++ new DefaultFPGAConfig)
|
2015-06-26 08:17:35 +02:00
|
|
|
|
2015-07-14 00:46:42 +02:00
|
|
|
class WithZscale extends ChiselConfig(
|
|
|
|
(pname,site,here) => pname match {
|
|
|
|
case BuildZscale => {
|
|
|
|
TestGeneration.addSuites(List(rv32ui("p"), rv32um("p")))
|
2015-07-28 04:06:06 +02:00
|
|
|
TestGeneration.addSuites(List(zscaleBmarks))
|
2015-10-06 19:47:38 +02:00
|
|
|
(r: Bool, p: Parameters) => Module(new Zscale(r)(p.alterPartial({case TLId => "L1ToL2"})))
|
2015-07-14 00:46:42 +02:00
|
|
|
}
|
|
|
|
case UseZscale => true
|
2015-07-17 21:02:02 +02:00
|
|
|
case BootROMCapacity => Dump("BOOT_CAPACITY", 16*1024)
|
|
|
|
case DRAMCapacity => Dump("DRAM_CAPACITY", 64*1024*1024)
|
2015-07-14 00:46:42 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
class ZscaleConfig extends ChiselConfig(new WithZscale ++ new DefaultConfig)
|
|
|
|
|
2014-10-06 22:43:40 +02:00
|
|
|
class FPGAConfig extends ChiselConfig (
|
|
|
|
(pname,site,here) => pname match {
|
2015-07-31 01:30:00 +02:00
|
|
|
case NAcquireTransactors => 4
|
2014-10-06 22:43:40 +02:00
|
|
|
case UseBackupMemoryPort => false
|
2014-09-24 02:05:14 +02:00
|
|
|
}
|
2014-10-06 22:43:40 +02:00
|
|
|
)
|
2014-09-24 02:05:14 +02:00
|
|
|
|
2014-10-06 22:43:40 +02:00
|
|
|
class DefaultFPGAConfig extends ChiselConfig(new FPGAConfig ++ new DefaultConfig)
|
2014-09-24 02:05:14 +02:00
|
|
|
|
2014-10-07 11:05:10 +02:00
|
|
|
class SmallConfig extends ChiselConfig (
|
2014-10-06 22:43:40 +02:00
|
|
|
topDefinitions = { (pname,site,here) => pname match {
|
2014-09-23 01:42:06 +02:00
|
|
|
case BuildFPU => None
|
2014-08-28 22:07:54 +02:00
|
|
|
case FastMulDiv => false
|
2015-06-26 08:17:35 +02:00
|
|
|
case NTLBEntries => 4
|
2015-10-06 19:47:38 +02:00
|
|
|
case BtbKey => BtbParameters(nEntries = 8)
|
2014-10-06 22:43:40 +02:00
|
|
|
}},
|
|
|
|
knobValues = {
|
2014-08-28 22:07:54 +02:00
|
|
|
case "L1D_SETS" => 64
|
|
|
|
case "L1D_WAYS" => 1
|
2014-10-06 22:43:40 +02:00
|
|
|
case "L1I_SETS" => 64
|
|
|
|
case "L1I_WAYS" => 1
|
2014-08-28 22:07:54 +02:00
|
|
|
}
|
2014-10-06 22:43:40 +02:00
|
|
|
)
|
2014-08-23 10:26:03 +02:00
|
|
|
|
2014-10-07 11:05:10 +02:00
|
|
|
class DefaultFPGASmallConfig extends ChiselConfig(new SmallConfig ++ new DefaultFPGAConfig)
|
|
|
|
|
|
|
|
class ExampleSmallConfig extends ChiselConfig(new SmallConfig ++ new DefaultConfig)
|
2015-08-06 21:51:18 +02:00
|
|
|
|
|
|
|
class MultibankConfig extends ChiselConfig(new With2Banks ++ new DefaultConfig)
|
|
|
|
class MultibankL2Config extends ChiselConfig(
|
|
|
|
new With2Banks ++ new WithL2Cache ++ new DefaultConfig)
|