-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
DevNull.scala
57 lines (53 loc) · 2.3 KB
/
DevNull.scala
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// See LICENSE.SiFive for license details.
package freechips.rocketchip.devices.tilelink
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
case class DevNullParams(
address: Seq[AddressSet],
maxAtomic: Int,
maxTransfer: Int,
region: RegionType.T = RegionType.VOLATILE,
executable: Boolean = true,
mayDenyGet: Boolean = true,
mayDenyPut: Boolean = true,
hint: Boolean = true
) {
require (maxAtomic <= maxTransfer, s"Atomic transfer size must be <= max transfer (but $maxAtomic > $maxTransfer)")
require (maxTransfer <= 4096, s"Max transfer size must be <= 4096 (was $maxTransfer)")
def acquire: Boolean = region == RegionType.TRACKED
}
/** DevNullDevices don't obey standard memory operation semantics.
* They may discard writes, refuse to respond to requests, issue error responses,
* or otherwise violate 'expected' memory behavior.
*/
abstract class DevNullDevice(params: DevNullParams, beatBytes: Int, device: SimpleDevice)
(implicit p: Parameters)
extends LazyModule with HasClockDomainCrossing {
val xfer = if (params.maxTransfer > 0) TransferSizes(1, params.maxTransfer) else TransferSizes.none
val atom = if (params.maxAtomic > 0) TransferSizes(1, params.maxAtomic) else TransferSizes.none
val acq = if (params.acquire) xfer else TransferSizes.none
val hint = if (params.hint) xfer else TransferSizes.none
val node = TLManagerNode(Seq(TLManagerPortParameters(
Seq(TLManagerParameters(
address = params.address,
resources = device.reg,
regionType = params.region,
executable = params.executable,
supportsAcquireT = acq,
supportsAcquireB = acq,
supportsGet = xfer,
supportsPutPartial = xfer,
supportsPutFull = xfer,
supportsArithmetic = atom,
supportsLogical = atom,
supportsHint = hint,
fifoId = Some(0), // requests are handled in order
mayDenyGet = params.mayDenyGet,
mayDenyPut = params.mayDenyPut,
alwaysGrantsT = params.acquire)),
beatBytes = beatBytes,
endSinkId = if (params.acquire) 1 else 0,
minLatency = 1))) // no bypass needed for this device
val tl_xing = this.crossIn(node)
}