add peripherals
[shakti-peripherals.git] / src / uncore / tilelink / Tilelink.bsv
1 package Tilelink;
2
3 import Tilelink_Types.bsv ::*;
4 import defined_types.bsv ::*;
5
6 // ================================================================
7 // The interface for the fabric module
8
9 interface Tilelink_Fabric_IFC #(numeric type num_masters,
10 numeric type num_slaves);
11
12 method Action reset;
13 method Action set_verbosity (Bit #(4) verbosity);
14
15 // From masters
16 interface Vector #(num_masters, Ifc_Master_tilelink) v_from_masters;
17
18 // To slaves
19 interface Vector #(num_slaves, Ifc_Slave_link) v_to_slaves;
20 endinterface
21
22 module mkTilelinkFabric(Tilelink_Fabric_IFC);
23
24 // Transactors facing masters
25 Vector #(num_masters, AXI4_Slave_Xactor_IFC #(wd_addr, wd_data, wd_user))
26 xactors_masters <- replicateM (mkMasterFabric);
27
28 // Transactors facing slaves
29 Vector #(num_slaves, AXI4_Master_Xactor_IFC #(wd_addr, wd_data, wd_user))
30 xactors_slaves <- replicateM (mkSizedFIFO);
31
32 //These rules connect the masters and the slaves. If the sender is valid and the receiver is ready the
33 //the packet is exchanged. In addition the route must valid.
34
35 //The slave destination is determined by address map function
36 for(Integer m = 0; m < Num_masters; m = m+1) begin
37 for(Integer s = 0; s < Num_masters; s = s+1) begin
38 rule rl_fabric_requests;
39 let req = xactors_masters[m].fabric_side_request.fabric_a_channel;
40 {valid, slave_id} = fn_addr_slave_num(req.a_address, fromInteger(m)); //address map function
41 if(xactors_masters[m].fabric_side_request.fabric_a_channel_valid &&
42 xactors_slaves[s].fabric_side_request.fabric_a_channel_ready &&
43 valid && slave_id==s) begin
44 xactors_masters[m].fabric_side_request.fabric_a_channel_ready(True);
45 xactors_slaves[s].fabric_side_request.fabric_a_channel(req);
46 end
47 else if() //TODO send the slave error
48 endrule
49 end
50 end
51
52 //The master destination is determined by the signal in the D channel - d_source
53 for(Integer m = 0; m < Num_masters; m = m+1) begin
54 for(Integer s = 0; s < Num_masters; s = s+1) begin
55 rule rl_fabric_responses;
56 let resp = xactors_slaves[s].fabric_side_request.fabric_d_channel;
57 if(xactors_slaves[s].fabric_side_request.fabric_d_channel_valid &&
58 xactors_masters[m].fabric_side_request.fabric_d_channel_ready &&
59 resp.d_source==m) begin
60 xactors_slaves[s].fabric_side_request.fabric_a_channel_ready(True);
61 xactors_master[m].fabric_side_request.fabric_a_channel(resp);
62 end
63 else if() //TODO send the slave error
64 endrule
65 end
66 end
67
68 endmodule
69
70 endpackage