2 `include "defined_parameters"
19 } Opcode deriving(Bits, Eq, FShow);
26 } Param_arith deriving(Bits, Eq, FShow);
33 } Param_logical deriving(Bits, Eq, FShow);
36 typedef Bit#(4) Data_size //In bytes
37 typedef Bit#(2) M_source
38 typedef Bit#(5) S_sink
39 typedef Bit#(`PADDR) Address_width
40 typedef Bit#(`LANE_WIDTH) Mask
41 typedef Bit#(TMul#(8,`LANE_WIDTH)) Data
43 /* The A-channel is responsible for the master requests. The channel is A is split in control section(c)
44 data section(d) where the read masters only use control section and write masters use both. For the slave side
45 where it receives the request has the channel A intact.
48 Opcode a_opcode; //The opcode specifies if write or read requests
50 Param a_param; //Has the encodings for atomic transfers
52 Data_size a_size; //The transfer size in 2^a_size bytes. The burst is calculated from here. if this is >3 then its a burst
53 M_source a_source; //Master ID
54 Address_width a_address; //Address for the request
55 } A_channel_control deriving(Bits, Eq);
58 Mask a_mask; //8x(bytes in data lane) 1 bit mask for each byte
59 Data a_data; //data for the request
60 } A_channel_data deriving(Bits, Eq);
69 Address_width a_address;
72 } A_channel deriving(Bits, Eq);
74 //cache-coherence channels
80 Address_width b_address;
83 } B_channel deriving(Bits, Eq);
85 //cache-coherence channels
91 Address_width c_address;
94 } C_channel deriving(Bits, Eq);
96 //The channel D is responsible for the slave responses. It has the master ids and slave ids carried through the channel
98 Opcode d_opcode; //Opcode encodings for response with data or just ack
105 } D_channel deriving(Bits, Eq);
109 } E_channel deriving(Bits, Eq);
112 //--------------------------------------MASTER XACTOR--------------------------------------//
113 /* This is a xactor interface which connects core and master side of the fabric*/
114 interface Ifc_Master_link;
117 interface Put#(A_channel_control) master_request_control;
118 interface Put#(A_channel_data) master_request_data;
119 interface Get#(D_channel) master_response;
122 interface Get#(A_channel_control) fabric_request_control;
123 interface Get#(A_channel_data) fabric_request_data;
124 interface Put#(D_channel) fabric_response;
128 /* Master transactor - should be instantiated in the core side and the fabric side interface of
129 of the xactor should be exposed out of the core*/
130 module mkMasterXactor#(Bool xactor_guarded, Bool fabric_guarded)(Ifc_Master_link);
132 //Created a pipelined version that will have a critical path all along the bus. If we want to break the path we can
133 //make the bus stall-less
134 `ifdef TILELINK_LIGHT
135 FIFOF#(A_channel_control) ff_xactor_request_c <- mkGFIFOF(xactor_guarded, fabric_guarded, 2); //control split of A-channel
136 FIFOF#(A_channel_data) ff_xactor_request_d <- mkGFIFOF(xactor_guarded, fabric_guarded, 2); //data split of A-channel
137 FIFOF#(D_channel) ff_xactor_response <- mkGFIFOF(xactor_guarded, fabric_guarded, 2); //response channel D-channel exposed out
139 FIFO#(A_channel_control) ff_xactor_request_c <- mkSizedFIFO(2);
140 FIFO#(A_channel_data) ff_xactor_request_d <- mkSizedFIFO(2);
141 FIFO#(D_channel) ff_xactor_response <- mkSizedFIFO(2);
144 Reg#(Data_size) rg_burst_counter <- mkReg(0);
145 Reg#(Bool) rg_burst[2] <- mkCReg(2,False);
147 // If it is a burst dont ask for address again. This rule about calculating the burst and telling the control split of A-channel to keep
148 //quite till the burst finishes.
149 rule rl_xactor_to_fabric_data;
150 let req_addr = ff_xactor_c_request.first;
151 Data_size burst_size = 1; //The total number of bursts
152 Data_size transfer_size = req_addr.a_size; //This is the total transfer size including the bursts
153 if(!rg_burst[0]) begin
154 if(transfer_size > 3) begin
156 transfer_size = transfer_size - 3;
157 rg_burst_counter <= burst_size << transfer_size;
161 rg_burst_counter <= rg_burst_counter - 1;
162 if(rg_burst_counter==1)
163 rg_burst[0] <= False;
168 interface master_request_control = Get#(ff_xactor_c_request);
169 interface master_request_data = Get#(ff_xactor_d_request);
170 interface master_request_control = interface Get
171 method ActionValue#(A_channel_control) get; //Deque the control split of a channel if only burst is finished
172 let req_addr = ff_xactor_c_request.first;
174 ff_xactor_c_request.deq;
178 interface fabric_request_data = Get#(ff_xactor_d_request);
179 interface fabric_response = Put#(ff_xactor_d_response);
183 //------------------------------------------------------------------------------------------------------------------//
186 //------------------------------------------------------Slave Xactor------------------------------------------------//
188 interface Ifc_Slave_link;
190 interface Put#(A_channel) xactor_request;
191 interface Get#(D_channel) xactor_response;
193 interface Get#(A_channel) xactor_request;
194 interface Put#(D_channel) xactor_response;
198 module mkSlave_xactor(Ifc_Slave_link);
200 `ifdef TILELINK_LIGHT
201 FIFOF#(A_channel) ff_xactor_request <- mkGFIFOF(xactor_guarded, fabric_guarded, 2);
202 FIFOF#(D_channel) ff_xactor_response <- mkGFIFOF(xactor_guarded, fabric_guarded, 2);
204 FIFO#(A_channel) ff_xactor_request <- mkSizedFIFO(2);
205 FIFO#(D_channel) ff_xactor_response <- mkSizedFIFO(2);
208 //rule rl_xactor_to_fabric(!isValid(rg_d_channel));
209 // let lv_response = ff_xactor_response.first;
210 // rg_d_channel <= tagged Valid lv_response;
211 // ff_xactor_response.deq;
214 //rule rl_fabric_to_xactor(rg_a_channel matches tagged Valid .req);
216 // ff_xactor_request.enq(req);
217 // rg_a_channel <= tagged Invalid
220 interface master_request = Put#(ff_xactor_request);
221 interface master_response = Get#(ff_xactor_response);
223 interface fabric_request = Get#(ff_xactor_request);
224 interface fabric_response = Put#(ff_xactor_response);
228 //----------------------------------------------- Master Fabric -------------------------------------//
230 interface Ifc_Master_fabric_side_a_channel;
232 method A_channel fabric_a_channel;
234 method Bool fabric_a_channel_valid;
235 (* always_ready, always_enabled *);
236 method Action fabric_a_channel_ready;
239 interface Ifc_Master_fabric_side_d_channel;
240 (* always_ready, always_enabled *);
241 method Action fabric_d_channel;
243 method Bool fabric_d_channel_ready;
246 interface Ifc_Master_tilelink;
248 //Communication with the xactor
249 interface Put#(A_channel_control) xactor_request_control;
250 interface Put#(A_channel_data) xactor_request_data;
251 interface Get#(D_channel) xactor_response;
253 //communication with the fabric
254 interface Ifc_Master_fabric_side_d_channel fabric_side_response;
255 interface Ifc_Master_fabric_side_a_channel fabric_side_request;
258 module mkMasterFabric(Ifc_Master_Fabric);
260 Reg#(A_channel_control) rg_a_channel[3] <- mkCReg(3, A_channel { a_opcode : ?,
265 Reg#(Maybe#(A_channel_data)) rg_a_channel_d[3] <- mkCReg(3, tagged Invalid);
266 Reg#(Maybe#(D_channel)) rg_d_channel[3] <- mkCReg(3, tagged Invalid);
269 interface xactor_request_control = interface Put
270 method Action put(A_channel_control req_control);
271 rg_a_channel_c <= req_control;
275 interface xactor_request_data = interface Put
276 method Action put(A_channel_data req_data);
277 rg_a_channel_d <= req_data;
281 interface xactor_response = interface Get;
282 method ActionValue#(D_channel) get if(isValid(rg_d_channel));
283 let resp = validValue(rg_d_channel);
284 rg_d_channel <= tagged Invalid;
289 interface fabric_side_response = interface Ifc_Master_fabric_side_d_channel
290 (* always_ready, always_enabled *);
291 method Action fabric_d_channel(D_channel resp);
292 rg_d_channel <= tagged Valid resp;
295 method Bool fabric_d_channel_ready;
296 return !isValid(rg_d_channel);
299 //while sending it to the fabric the control section and the data section should be merged
300 interface fabric_side_request = interface Ifc_Master_fabric_side_a_channel
302 method A_channel fabric_a_channel;
303 A_channel req = A_channel {a_opcode : rg_a_channel_c.a_opcode,
304 a_param : rg_a_channel_c.a_param,
305 a_size : rg_a_channel_c.a_size,
306 a_source : rg_a_channel_c.a_source,
307 a_address : rg_a_channel_c.a_address,
308 a_mask : rg_c_channel_c.a_mask,
309 a_data : rg_c_channel_c.a_data};
310 return validValue(req);
313 method Bool fabric_a_channel_valid; //master valid signal to the fabric
314 return isValid(rg_a_channel_d);
316 (* always_ready, always_enabled *);
317 method Action fabric_a_channel_ready(Bool req_ready); //master ready signal to the fabric
319 rg_a_channel <= tagged Invalid;
325 //----------------------------------------------- Slave Fabric -------------------------------------//
327 interface Ifc_Master_fabric_side_a_channel;
328 (* always_ready, always_enabled *);
329 method Action fabric_a_channel(A_channel req);
331 method Bool fabric_a_channel_ready;
334 interface Ifc_Master_fabric_side_d_channel;
336 method D_channel fabric_d_channel;
338 method Bool fabric_d_channel_valid;
339 (* always_ready, always_enabled *);
340 method Action fabric_a_channel_ready;
343 interface Ifc_Slave_tilelink;
345 //communication with the xactors
346 interface Get#(A_channel) xactor_request;
347 interface Put#(D_channel) xactor_response;
349 //communication with the fabric
350 interface Ifc_slave fabric_side_response;
351 interface Ifc_Slave_fabric_side_a_channel fabric_side_request;
355 module mkSlaveFabric(Ifc_Slave_Fabric);
357 Reg#(Maybe#(A_channel)) rg_a_channel_d[3] <- mkCReg(3, tagged Invalid);
358 Reg#(Maybe#(D_channel)) rg_d_channel[3] <- mkCReg(3, tagged Invalid);
361 interface xactor_request_control = interface Get
362 method ActionValue#(A_channel) get if(isValid(rg_a_channel);
363 let req = validValue(rg_a_channel);
364 rg_a_channel <= tagged Invalid;
369 interface xactor_response = interface Put;
370 method Action put(D_channel resp) if(!isValid(rg_d_channel));
371 rg_d_channel <= tagged resp;
375 interface fabric_side_response = interface Ifc_Slave_fabric_side_d_channel
377 method D_channel fabric_d_channel(D_channel resp);
378 return validValue(rg_d_channel);
381 method Bool fabric_d_channel_valid;
382 return isValid(rg_d_channel);
384 (* always_ready, always_enabled *);
385 //if the beat has been exchanged the packet can be invalidated on the sending side
386 method Action fabric_d_channel_ready(Bool req_ready);
388 rg_d_channel <= tagged Invalid;
392 interface fabric_side_request = interface Ifc_Master_fabric_side_a_channel
393 //if the beat has been exchanged the packet can be invalidated on the sending side
394 (* always_ready, always_enabled *);
395 method Action fabric_a_channel(A_channel req);
399 method Bool fabric_a_channel_ready;
400 return !isValid(rg_a_channel_d);