1 | /* -*- c++ -*- |
---|
2 | * File : vci_synthetic_initiator.h |
---|
3 | * Date : 26/08/2010 |
---|
4 | * Copyright : UPMC / LIP6 |
---|
5 | * Authors : Christophe Choichillon |
---|
6 | * |
---|
7 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
8 | * |
---|
9 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
10 | * |
---|
11 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU Lesser General Public License as published |
---|
13 | * by the Free Software Foundation; version 2.1 of the License. |
---|
14 | * |
---|
15 | * SoCLib is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * Lesser General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU Lesser General Public |
---|
21 | * License along with SoCLib; if not, write to the Free Software |
---|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
23 | * 02110-1301 USA |
---|
24 | * |
---|
25 | * SOCLIB_LGPL_HEADER_END |
---|
26 | * |
---|
27 | * Maintainers: christophe.choichillon@lip6.fr |
---|
28 | */ |
---|
29 | |
---|
30 | #ifndef SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
31 | #define SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
32 | |
---|
33 | #include <systemc> |
---|
34 | #include <inttypes.h> |
---|
35 | #include "generic_fifo.h" |
---|
36 | #include "vci_initiator.h" |
---|
37 | #include "soclib_endian.h" |
---|
38 | #include "caba_base_module.h" |
---|
39 | #include "int_tab.h" |
---|
40 | #include "mapping_table.h" |
---|
41 | |
---|
42 | namespace soclib { namespace caba { |
---|
43 | using namespace sc_core; |
---|
44 | |
---|
45 | template<typename vci_param> |
---|
46 | class VciSyntheticInitiator |
---|
47 | : public soclib::caba::BaseModule |
---|
48 | { |
---|
49 | //typedef sc_dt::sc_uint<40> addr_t; |
---|
50 | typedef typename vci_param::fast_addr_t vci_addr_t; |
---|
51 | typedef uint32_t data_t; |
---|
52 | typedef uint32_t tag_t; |
---|
53 | typedef uint32_t size_t; |
---|
54 | typedef uint32_t be_t; |
---|
55 | typedef uint32_t copy_t; |
---|
56 | |
---|
57 | // Type of the addr_t and access of the fields |
---|
58 | typedef union{ |
---|
59 | PACKED_BITFIELD( |
---|
60 | vci_addr_t srcid:vci_param::S, |
---|
61 | vci_addr_t null:(8*sizeof(vci_addr_t)-(2*vci_param::S)), |
---|
62 | ) normal_address; |
---|
63 | PACKED_BITFIELD( |
---|
64 | vci_addr_t xmin:vci_param::S, |
---|
65 | vci_addr_t xmax:vci_param::S, |
---|
66 | vci_addr_t ymin:vci_param::S, |
---|
67 | vci_addr_t ymax:vci_param::S, |
---|
68 | vci_addr_t null_:(8*sizeof(vci_addr_t)-(4*vci_param::S)), |
---|
69 | vci_addr_t bc:2, |
---|
70 | ) broadcast_address; |
---|
71 | } addr_t; |
---|
72 | |
---|
73 | |
---|
74 | /* States of the GENERATOR fsm */ |
---|
75 | enum vci_fsm_state_e{ |
---|
76 | VCI_IDLE, |
---|
77 | VCI_SINGLE_SEND, |
---|
78 | VCI_SINGLE_RECEIVE, |
---|
79 | VCI_BC_SEND, |
---|
80 | VCI_BC_RECEIVE |
---|
81 | }; |
---|
82 | enum gen_fsm_state_e{ |
---|
83 | A_IDLE, |
---|
84 | A_DATA |
---|
85 | }; |
---|
86 | |
---|
87 | uint64_t m_cpt_cycles; // Counter of cycles |
---|
88 | |
---|
89 | |
---|
90 | protected: |
---|
91 | |
---|
92 | SC_HAS_PROCESS(VciSyntheticInitiator); |
---|
93 | |
---|
94 | public: |
---|
95 | sc_in<bool> p_clk; |
---|
96 | sc_in<bool> p_resetn; |
---|
97 | soclib::caba::VciInitiator<vci_param> p_vci; |
---|
98 | |
---|
99 | VciSyntheticInitiator( |
---|
100 | sc_module_name name, |
---|
101 | const soclib::common::MappingTable &mt, |
---|
102 | const soclib::common::IntTab &vci_index, |
---|
103 | size_t length, // Packet length (flit numbers) |
---|
104 | float rho, // Packets ratio on the network |
---|
105 | size_t depth, // Fifo depth |
---|
106 | size_t xmesh, |
---|
107 | size_t ymesh, |
---|
108 | size_t bc_period = 0, // Broadcast period, if no broadcast => 0 |
---|
109 | size_t xmin = 0, |
---|
110 | size_t xmax = 0, |
---|
111 | size_t ymin = 0, |
---|
112 | size_t ymax = 0, |
---|
113 | ); |
---|
114 | |
---|
115 | ~VciSyntheticInitiator(); |
---|
116 | |
---|
117 | void transition(); |
---|
118 | |
---|
119 | void genMoore(); |
---|
120 | |
---|
121 | void destAdress(size_t X_local, size_t Y_local, size_t &X_dest, size_t &Y_dest); |
---|
122 | |
---|
123 | private: |
---|
124 | |
---|
125 | // Component attributes |
---|
126 | const size_t m_length; // Number of words to write |
---|
127 | const size_t m_rho; // Rate of packets in the network wanted |
---|
128 | const size_t m_depth; // Fifo depth |
---|
129 | const size_t m_xmesh; |
---|
130 | const size_t m_ymesh; |
---|
131 | const size_t m_bc_period; // Broadcast period, if no broadcast => 0 |
---|
132 | const size_t m_xmin; |
---|
133 | const size_t m_xmax; |
---|
134 | const size_t m_ymin; |
---|
135 | const size_t m_ymax; |
---|
136 | const size_t m_srcid; |
---|
137 | const size_t m_coord; |
---|
138 | |
---|
139 | size_t m_count; // Numbers of words sent |
---|
140 | size_t m_npackets; // Total number of packets already sent |
---|
141 | uint64_t m_start_latency1; // Start time of sending packet wanted |
---|
142 | uint64_t m_start_latency2; // Start time of sending packet |
---|
143 | addr_t m_address_to_send; // Address to send the write command |
---|
144 | float m_rhos; // Effective Rho during the simulation |
---|
145 | size_t m_bc_nrsp; // Expected number of responses for a broadcast command |
---|
146 | |
---|
147 | // Fifo transmitting date to the VCI FSM |
---|
148 | GenericFifo<uint64_t> m_date_fifo; |
---|
149 | |
---|
150 | sc_signal<int> r_vci_fsm; |
---|
151 | |
---|
152 | sc_signal<size_t> r_index; |
---|
153 | |
---|
154 | sc_signal<bool> r_broadcast_req; |
---|
155 | |
---|
156 | }; // end class VciSyntheticInitiator |
---|
157 | |
---|
158 | }} |
---|
159 | |
---|
160 | #endif |
---|