-
Notifications
You must be signed in to change notification settings - Fork 6
/
Paski_GowinDDR_AXI4.scala
95 lines (79 loc) · 3.13 KB
/
Paski_GowinDDR_AXI4.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
package paskisoc
import spinal.core._
import spinal.lib.bus.amba4.axi.{Axi4, Axi4Shared, Axi4SpecRenamer, Axi4ToAxi4Shared}
import spinal.lib.io.InOutWrapper
import spinal.lib.{master, slave}
object Generate_Paski_GowinDDR_AXI4_Compatible {
def main(args: Array[String]) {
SpinalVerilog(
InOutWrapper(
Paski_GowinDDR_AXI4_Compatible(
ClockDomain.external("sys_clk", config = ClockDomainConfig(resetKind = ASYNC, resetActiveLevel = LOW)),
ClockDomain.external("mem_clk", config = ClockDomainConfig(resetKind = ASYNC, resetActiveLevel = LOW))
)
)
).printPruned()
}
}
case class Paski_GowinDDR_AXI4_Compatible(sys_clk: ClockDomain, mem_clk: ClockDomain) extends Component{
val inst = Paski_GowinDDR_AXI4(sys_clk, mem_clk)
val axiConfig = inst.axiController.axiConfig
val io = new Bundle() {
val pll_lock = in Bool()
val axi = slave(Axi4(axiConfig))
val ddr_iface = master(DDR3_Interface())
}
Axi4SpecRenamer(io.axi)
val sys_area = new ClockingArea(sys_clk) {
inst.io.pll_lock := io.pll_lock
inst.io.axi << Axi4ToAxi4Shared(io.axi)
io.ddr_iface := inst.io.ddr_iface
}
}
case class Paski_GowinDDR_AXI4(sys_clk: ClockDomain, mem_clk: ClockDomain) extends Component{
val gowin_DDR3 = Gowin_DDR3(
sys_clk,
mem_clk
)
val ddr_ref_clk = gowin_DDR3.clk_out
val axiController = Paski_GowinDDR_AXI4WithCache(
sys_clk, 32, 27, 4 // Modify here to change the width of the data bus
)
val controller = Paski_GowinDDR14_Controller(
sys_clk,
ddr_ref_clk,
contextType = axiController.context_type,
fifo_length = 4
)
val io = new Bundle() {
val pll_lock = in Bool()
val axi = slave(Axi4Shared(axiController.axiConfig))
val ddr_iface = master(DDR3_Interface())
}
val sys_area = new ClockingArea(sys_clk) {
axiController.io.ddr_cmd >> controller.io.ddr_cmd
axiController.io.ddr_rsp << controller.io.ddr_rsp
io.axi.sharedCmd >> axiController.io.axi.sharedCmd
io.axi.writeData >> axiController.io.axi.writeData
io.axi.writeRsp << axiController.io.axi.writeRsp
io.axi.readRsp << axiController.io.axi.readRsp
gowin_DDR3.io.sr_req := False
gowin_DDR3.io.ref_req := False
gowin_DDR3.io.burst := True
gowin_DDR3.io.pll_lock := io.pll_lock
gowin_DDR3.io.app_burst_number := controller.io.app_burst_number
gowin_DDR3.io.cmd := controller.io.cmd
gowin_DDR3.io.cmd_en := controller.io.cmd_en
gowin_DDR3.io.addr := controller.io.addr
gowin_DDR3.io.wr_data := controller.io.wr_data
gowin_DDR3.io.wr_data_en := controller.io.wr_data_en
gowin_DDR3.io.wr_data_end := controller.io.wr_data_en
gowin_DDR3.io.wr_data_mask := controller.io.wr_data_mask
controller.io.cmd_ready := gowin_DDR3.io.cmd_ready
controller.io.wr_data_rdy := gowin_DDR3.io.wr_data_rdy
controller.io.rd_data := gowin_DDR3.io.rd_data
controller.io.rd_data_valid := gowin_DDR3.io.rd_data_valid
controller.io.init_calib_complete := gowin_DDR3.io.init_calib_complete
gowin_DDR3.connectDDR3Interface(io.ddr_iface)
}
}