Skip to content

Commit 3362bea

Browse files
Merge pull request #77 from ucb-ucie/d2dadapter_main
D2Dadapter main
2 parents 29327dc + 5b5e3a7 commit 3362bea

23 files changed

+3785
-4
lines changed
+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
package edu.berkeley.cs.ucie.digital
2+
package d2dadapter
3+
4+
import chisel3._
5+
//import chisel3.util._
6+
//import chisel3.experimental._
7+
8+
import interfaces._
9+
import sideband._
10+
11+
class D2DAdapterIO (val fdiParams: FdiParams, val rdiParams: RdiParams) extends Bundle {
12+
val fdi = Flipped(new Fdi(fdiParams))
13+
val rdi = new Rdi(rdiParams)
14+
}
15+
16+
/**
17+
* Top module for the D2D adapter which instantiates:
18+
* 1) LinkManagement Controller
19+
* 2) SB node
20+
* 3) MB node
21+
* 4) FDI and RDI stall handlers
22+
* @param fdiParams
23+
* @param rdiParams
24+
* @param sbParams
25+
*/
26+
class D2DAdapter(val fdiParams: FdiParams, val rdiParams: RdiParams,
27+
val sbParams: SidebandParams) extends Module {
28+
val io = IO(new D2DAdapterIO(fdiParams, rdiParams))
29+
30+
assert(fdiParams.width == rdiParams.width)
31+
assert(fdiParams.sbWidth == rdiParams.sbWidth)
32+
33+
val link_manager = Module(new LinkManagementController(fdiParams, rdiParams, sbParams))
34+
val fdi_stall_handler = Module(new FDIStallHandler())
35+
val rdi_stall_handler = Module(new RDIStallHandler())
36+
37+
val d2d_sideband = Module(new D2DSidebandModule(fdiParams, sbParams))
38+
val d2d_mainband = Module(new D2DMainbandModule(fdiParams, rdiParams, sbParams))
39+
40+
val parity_generator = Module(new ParityGenerator(fdiParams))
41+
42+
// default assignments for the FDI and RDI interfaces
43+
io.fdi.plProtocolValid := true.B
44+
io.fdi.plProtocolFlitFormat := FlitFormat.raw
45+
io.fdi.plProtocol := Protocol.streaming
46+
io.fdi.plSpeedMode := io.rdi.plSpeedMode
47+
io.fdi.plLinkWidth := io.rdi.plLinkWidth
48+
io.fdi.plFlitCancel := false.B
49+
50+
io.fdi.plNfError := false.B
51+
io.fdi.plTrainError := false.B
52+
io.fdi.plError := false.B
53+
io.fdi.plCerror := false.B
54+
55+
io.fdi.plPhyInRecenter := false.B
56+
io.fdi.plPhyInL1 := false.B
57+
io.fdi.plPhyInL2 := false.B
58+
io.fdi.plDllp.bits := 0.U
59+
io.fdi.plDllp.valid := false.B
60+
io.fdi.plDllpOfc := false.B
61+
62+
io.fdi.plClkReq := true.B
63+
io.rdi.lpClkAck := true.B
64+
io.fdi.plWakeAck := true.B
65+
66+
io.fdi.plRetimerCrd := false.B
67+
68+
io.rdi.lpRetimerCrd := false.B
69+
io.rdi.lpWakeReq := true.B
70+
71+
// link management controller
72+
// FDI interface
73+
link_manager.io.fdi_lp_state_req := io.fdi.lpStateReq
74+
link_manager.io.fdi_lp_linkerror := io.fdi.lpLinkError
75+
link_manager.io.fdi_lp_rx_active_sts := io.fdi.lpRxActiveStatus
76+
io.fdi.plStateStatus := link_manager.io.fdi_pl_state_sts
77+
io.fdi.plRxActiveReq := link_manager.io.fdi_pl_rx_active_req
78+
io.fdi.plInbandPres := link_manager.io.fdi_pl_inband_pres
79+
// RDI interface
80+
io.rdi.lpLinkError := link_manager.io.rdi_lp_linkerror
81+
io.rdi.lpStateReq:= link_manager.io.rdi_lp_state_req
82+
link_manager.io.rdi_pl_state_sts := io.rdi.plStateStatus
83+
link_manager.io.rdi_pl_inband_pres := io.rdi.plInbandPres
84+
85+
// link manager <-> D2D sideband
86+
d2d_sideband.io.sideband_snt := link_manager.io.sb_snd
87+
link_manager.io.sb_rcv := d2d_sideband.io.sideband_rcv
88+
link_manager.io.sb_rdy := d2d_sideband.io.sideband_rdy
89+
90+
// stall handler <-> LinkManagementController
91+
link_manager.io.linkmgmt_stalldone := fdi_stall_handler.io.linkmgmt_stalldone
92+
fdi_stall_handler.io.linkmgmt_stallreq := link_manager.io.linkmgmt_stallreq
93+
94+
//TODO: should move this to a MMIO register
95+
link_manager.io.cycles_1us := 1000.U
96+
97+
// parity generator <-> link manager
98+
link_manager.io.parity_tx_sw_en := false.B // TODO: this should be software triggered, MMIO regs?
99+
link_manager.io.parity_rx_sw_en := false.B // TODO: this should be software triggered, MMIO regs?
100+
parity_generator.io.parity_rx_enable := link_manager.io.parity_rx_enable
101+
parity_generator.io.parity_tx_enable := link_manager.io.parity_tx_enable
102+
103+
// Sideband
104+
io.fdi.plConfig.bits := d2d_sideband.io.fdi_pl_cfg
105+
io.fdi.plConfig.valid := d2d_sideband.io.fdi_pl_cfg_vld
106+
d2d_sideband.io.fdi_pl_cfg_crd := io.fdi.plConfigCredit
107+
d2d_sideband.io.fdi_lp_cfg := io.fdi.lpConfig.bits
108+
d2d_sideband.io.fdi_lp_cfg_vld := io.fdi.lpConfig.valid
109+
io.fdi.lpConfigCredit := d2d_sideband.io.fdi_lp_cfg_crd
110+
111+
d2d_sideband.io.rdi_pl_cfg := io.rdi.plConfig.bits
112+
d2d_sideband.io.rdi_pl_cfg_vld := io.rdi.plConfig.valid
113+
io.rdi.plConfigCredit := d2d_sideband.io.rdi_pl_cfg_crd
114+
io.rdi.lpConfig.bits := d2d_sideband.io.rdi_lp_cfg
115+
io.rdi.lpConfig.valid := d2d_sideband.io.rdi_lp_cfg_vld
116+
d2d_sideband.io.rdi_lp_cfg_crd := io.rdi.lpConfigCredit
117+
118+
// stall handler
119+
io.fdi.plStallReq := fdi_stall_handler.io.fdi_pl_stallreq
120+
fdi_stall_handler.io.fdi_lp_stallack := io.fdi.lpStallAck
121+
122+
rdi_stall_handler.io.rdi_pl_stallreq := io.rdi.plStallReq
123+
io.rdi.lpStallAck := rdi_stall_handler.io.rdi_lp_stallack
124+
125+
// mainband module
126+
// FDI
127+
d2d_mainband.io.fdi_lp_irdy := io.fdi.lpData.irdy
128+
d2d_mainband.io.fdi_lp_valid := io.fdi.lpData.valid
129+
d2d_mainband.io.fdi_lp_data := io.fdi.lpData.bits
130+
d2d_mainband.io.fdi_lp_stream := io.fdi.lpStream
131+
io.fdi.lpData.ready := d2d_mainband.io.fdi_pl_trdy
132+
io.fdi.plData.valid := d2d_mainband.io.fdi_pl_valid
133+
io.fdi.plData.bits := d2d_mainband.io.fdi_pl_data
134+
io.fdi.plStream := d2d_mainband.io.fdi_pl_stream
135+
// RDI
136+
io.rdi.lpData.irdy := d2d_mainband.io.rdi_lp_irdy
137+
io.rdi.lpData.valid := d2d_mainband.io.rdi_lp_valid
138+
io.rdi.lpData.bits := d2d_mainband.io.rdi_lp_data
139+
d2d_mainband.io.rdi_pl_trdy := io.rdi.lpData.ready
140+
d2d_mainband.io.rdi_pl_valid := io.rdi.plData.valid
141+
d2d_mainband.io.rdi_pl_data := io.rdi.plData.bits
142+
143+
d2d_mainband.io.d2d_state := link_manager.io.fdi_pl_state_sts
144+
145+
// stall handler <-> mainband
146+
d2d_mainband.io.mainband_stallreq := rdi_stall_handler.io.mainband_stallreq
147+
rdi_stall_handler.io.mainband_stalldone := d2d_mainband.io.mainband_stalldone
148+
149+
// parity generator <-> mainband
150+
//(Bits((8 * fdiParams.width).W))
151+
parity_generator.io.snd_data := d2d_mainband.io.snd_data.asTypeOf(Vec(fdiParams.width, UInt(8.W)))
152+
parity_generator.io.snd_data_vld := d2d_mainband.io.snd_data_vld
153+
parity_generator.io.rcv_data := d2d_mainband.io.rcv_data.asTypeOf(Vec(fdiParams.width, UInt(8.W)))
154+
parity_generator.io.rcv_data_vld := d2d_mainband.io.rcv_data_vld
155+
d2d_mainband.io.parity_insert := parity_generator.io.parity_insert
156+
d2d_mainband.io.parity_data := parity_generator.io.parity_data.asTypeOf(Bits((8 * fdiParams.width).W))
157+
parity_generator.io.parity_rdy := d2d_mainband.io.parity_rdy
158+
d2d_mainband.io.parity_check := parity_generator.io.parity_check
159+
160+
// Parity generator submodule other IOs
161+
parity_generator.io.parity_n := ParityN.ONE
162+
parity_generator.io.rdi_state := io.rdi.plStateStatus
163+
// Store these into some MMIO based registers
164+
val parity_check_result = parity_generator.io.parity_check_result
165+
val parity_check_result_valid = parity_generator.io.parity_check_result_valid
166+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package edu.berkeley.cs.ucie.digital
2+
package d2dadapter
3+
4+
import chisel3._
5+
//import chisel3.util._
6+
//import interfaces._
7+
//import sideband._
8+
9+
// LinkInitModule constants
10+
11+
object LinkInitState extends ChiselEnum {
12+
val INIT_START = Value(0x0.U(3.W))
13+
val RDI_BRINGUP = Value(0x1.U(3.W))
14+
val PARAM_EXCH = Value(0x2.U(3.W))
15+
val FDI_BRINGUP = Value(0x3.U(3.W))
16+
val INIT_DONE = Value(0x4.U(3.W))
17+
}
18+
19+
// Sideband constants
20+
21+
object D2DAdapterSignalSize{
22+
val SIDEBAND_MESSAGE_OP_WIDTH = 6.W
23+
}
24+
25+
object SideBandMessage{
26+
// start with 01: RES
27+
// start with 00: REQ
28+
// start with 1: others
29+
val NOP: UInt = "b000000".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
30+
val REQ_ACTIVE: UInt = "b000001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
31+
val REQ_L1: UInt = "b000100".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
32+
val REQ_L2: UInt = "b001000".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
33+
val REQ_LINKRESET: UInt = "b001001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
34+
val REQ_DISABLED: UInt = "b001100".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
35+
val RSP_ACTIVE: UInt = "b010001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
36+
val RSP_PMNAK: UInt = "b010011".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
37+
val RSP_L1: UInt = "b010100".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
38+
val RSP_L2: UInt = "b011000".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
39+
val RSP_LINKRESET: UInt = "b011001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
40+
val RSP_DISABLED: UInt = "b011100".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
41+
val PARITY_FEATURE_REQ: UInt = "b100001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
42+
val PARITY_FEATURE_ACK: UInt = "b110001".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
43+
val PARITY_FEATURE_NAK: UInt = "b110010".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
44+
val ADV_CAP: UInt = "b100100".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
45+
val REGISTER_ACCESS: UInt = "b101000".U(D2DAdapterSignalSize.SIDEBAND_MESSAGE_OP_WIDTH)
46+
}
47+
48+
// Stall Handler constants
49+
50+
object StallHandlerWidth{
51+
val STATE_WIDTH = 2.W
52+
}
53+
54+
object StallHandshakeState extends ChiselEnum{
55+
val IDLE = Value(0x0.U(StallHandlerWidth.STATE_WIDTH))
56+
val REQSNT = Value(0x1.U(StallHandlerWidth.STATE_WIDTH))
57+
val REQFALL = Value(0x2.U(StallHandlerWidth.STATE_WIDTH))
58+
val COMPLETE = Value(0x3.U(StallHandlerWidth.STATE_WIDTH))
59+
}
60+
61+
// Parity module constants
62+
63+
object ParityGeneratorWidth{
64+
val PARITY_N_WIDTH = 3.W
65+
}
66+
67+
object ParityAmount{
68+
val BASESIZE: Int = 64
69+
val PARITY_DATA_NBYTE_1: Int = 64
70+
val DATA_NBYTE_1: Int = 256 * 256 * 1
71+
val PARITY_DATA_NBYTE_2: Int = 64 * 2
72+
val DATA_NBYTE_2: Int = 256 * 256 * 2
73+
val PARITY_DATA_NBYTE_4: Int = 64 * 4
74+
val DATA_NBYTE_4: Int = 256 * 256 * 4
75+
val CORRECT_REG_WIDTH = 256.W // 4 * 64 for maximum four 64Bytes parity
76+
}
77+
78+
object ParityN{
79+
val ONE: UInt = "b000".U
80+
val TWO: UInt = "b001".U
81+
val FOUR: UInt = "b010".U
82+
}

0 commit comments

Comments
 (0)