forked from maltanar/axi-in-chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AXILiteDefs.scala
115 lines (96 loc) · 4.21 KB
/
AXILiteDefs.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package AXILiteDefs
{
import Chisel._
import Literal._
import Node._
// Part I: Definitions for the actual data carried over AXI channels
// in part II we will provide definitions for the actual AXI interfaces
// by wrapping the part I types in Decoupled (ready/valid) bundles
// AXI Lite channel data definitions
class AXILiteAddress(addrWidthBits: Int) extends Bundle {
val addr = UInt(width = addrWidthBits)
val prot = UInt(width = 3)
override def clone = { new AXILiteAddress(addrWidthBits).asInstanceOf[this.type] }
}
class AXILiteWriteData(dataWidthBits: Int) extends Bundle {
val data = UInt(width = dataWidthBits)
val strb = UInt(width = dataWidthBits/8)
override def clone = { new AXILiteWriteData(dataWidthBits).asInstanceOf[this.type] }
}
class AXILiteReadData(dataWidthBits: Int) extends Bundle {
val data = UInt(width = dataWidthBits)
val resp = UInt(width = 2)
override def clone = { new AXILiteReadData(dataWidthBits).asInstanceOf[this.type] }
}
// Part II: Definitions for the actual AXI interfaces
class AXILiteSlaveIF(addrWidthBits: Int, dataWidthBits: Int) extends Bundle {
// write address channel
val writeAddr = Decoupled(new AXILiteAddress(addrWidthBits)).flip
// write data channel
val writeData = Decoupled(new AXILiteWriteData(dataWidthBits)).flip
// write response channel (for memory consistency)
val writeResp = Decoupled(UInt(width = 2))
// read address channel
val readAddr = Decoupled(new AXILiteAddress(addrWidthBits)).flip
// read data channel
val readData = Decoupled(new AXILiteReadData(dataWidthBits))
// rename signals to be compatible with those in the Xilinx template
def renameSignals() {
writeAddr.bits.addr.setName("S_AXI_AWADDR")
writeAddr.bits.prot.setName("S_AXI_AWPROT")
writeAddr.valid.setName("S_AXI_AWVALID")
writeAddr.ready.setName("S_AXI_AWREADY")
writeData.bits.data.setName("S_AXI_WDATA")
writeData.bits.strb.setName("S_AXI_WSTRB")
writeData.valid.setName("S_AXI_WVALID")
writeData.ready.setName("S_AXI_WREADY")
writeResp.bits.setName("S_AXI_BRESP")
writeResp.valid.setName("S_AXI_BVALID")
writeResp.ready.setName("S_AXI_BREADY")
readAddr.bits.addr.setName("S_AXI_ARADDR")
readAddr.bits.prot.setName("S_AXI_ARPROT")
readAddr.valid.setName("S_AXI_ARVALID")
readAddr.ready.setName("S_AXI_ARREADY")
readData.bits.data.setName("S_AXI_RDATA")
readData.bits.resp.setName("S_AXI_RRESP")
readData.valid.setName("S_AXI_RVALID")
readData.ready.setName("S_AXI_RREADY")
}
override def clone = { new AXILiteSlaveIF(addrWidthBits, dataWidthBits).asInstanceOf[this.type] }
}
class AXILiteMasterIF(addrWidthBits: Int, dataWidthBits: Int) extends Bundle {
// write address channel
val writeAddr = Decoupled(new AXILiteAddress(addrWidthBits))
// write data channel
val writeData = Decoupled(new AXILiteWriteData(dataWidthBits))
// write response channel (for memory consistency)
val writeResp = Decoupled(UInt(width = 2)).flip
// read address channel
val readAddr = Decoupled(new AXILiteAddress(addrWidthBits))
// read data channel
val readData = Decoupled(new AXILiteReadData(dataWidthBits)).flip
// rename signals to be compatible with those in the Xilinx template
def renameSignals() {
writeAddr.bits.addr.setName("M_AXI_AWADDR")
writeAddr.bits.prot.setName("M_AXI_AWPROT")
writeAddr.valid.setName("M_AXI_AWVALID")
writeAddr.ready.setName("M_AXI_AWREADY")
writeData.bits.data.setName("M_AXI_WDATA")
writeData.bits.strb.setName("M_AXI_WSTRB")
writeData.valid.setName("M_AXI_WVALID")
writeData.ready.setName("M_AXI_WREADY")
writeResp.bits.setName("M_AXI_BRESP")
writeResp.valid.setName("M_AXI_BVALID")
writeResp.ready.setName("M_AXI_BREADY")
readAddr.bits.addr.setName("M_AXI_ARADDR")
readAddr.bits.prot.setName("M_AXI_ARPROT")
readAddr.valid.setName("M_AXI_ARVALID")
readAddr.ready.setName("M_AXI_ARREADY")
readData.bits.data.setName("M_AXI_RDATA")
readData.bits.resp.setName("M_AXI_RRESP")
readData.valid.setName("M_AXI_RVALID")
readData.ready.setName("M_AXI_RREADY")
}
override def clone = { new AXILiteMasterIF(addrWidthBits, dataWidthBits).asInstanceOf[this.type] }
}
}