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 | #include "arithmetics.h" |
---|
42 | |
---|
43 | namespace soclib { namespace caba { |
---|
44 | using namespace sc_core; |
---|
45 | |
---|
46 | template<typename vci_param> |
---|
47 | class VciSyntheticInitiator |
---|
48 | : public soclib::caba::BaseModule |
---|
49 | { |
---|
50 | typedef uint32_t 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 | |
---|
58 | /* States of the GENERATOR fsm */ |
---|
59 | enum vci_fsm_state_e{ |
---|
60 | VCI_IDLE, |
---|
61 | VCI_SINGLE_SEND, |
---|
62 | VCI_SINGLE_RECEIVE, |
---|
63 | VCI_BC_SEND, |
---|
64 | VCI_BC_RECEIVE |
---|
65 | }; |
---|
66 | enum gen_fsm_state_e{ |
---|
67 | A_IDLE, |
---|
68 | A_DATA |
---|
69 | }; |
---|
70 | |
---|
71 | uint32_t m_cpt_cycles; // Counter of cycles |
---|
72 | |
---|
73 | |
---|
74 | protected: |
---|
75 | |
---|
76 | SC_HAS_PROCESS(VciSyntheticInitiator); |
---|
77 | |
---|
78 | public: |
---|
79 | sc_in<bool> p_clk; |
---|
80 | sc_in<bool> p_resetn; |
---|
81 | soclib::caba::VciInitiator<vci_param> p_vci; |
---|
82 | |
---|
83 | VciSyntheticInitiator( |
---|
84 | sc_module_name name, |
---|
85 | const soclib::common::MappingTable &mt, |
---|
86 | const soclib::common::IntTab &vci_index, |
---|
87 | const uint32_t length, // Packet length (flit numbers) |
---|
88 | const uint32_t rho, // Packets ratio on the network |
---|
89 | //const float rho, // Packets ratio on the network |
---|
90 | const uint32_t depth, // Fifo depth |
---|
91 | const uint32_t xmesh, |
---|
92 | const uint32_t ymesh, |
---|
93 | const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0 |
---|
94 | const uint32_t xmin = 0, |
---|
95 | const uint32_t xmax = 0, |
---|
96 | const uint32_t ymin = 0, |
---|
97 | const uint32_t ymax = 0 |
---|
98 | ); |
---|
99 | |
---|
100 | ~VciSyntheticInitiator(); |
---|
101 | |
---|
102 | void transition(); |
---|
103 | |
---|
104 | void genMoore(); |
---|
105 | |
---|
106 | size_t destAdress(); |
---|
107 | |
---|
108 | void printStats(); |
---|
109 | |
---|
110 | void print_trace(); |
---|
111 | |
---|
112 | private: |
---|
113 | |
---|
114 | // Component attributes |
---|
115 | const size_t m_length; // Number of words to write |
---|
116 | const size_t m_rho; // Rate of packets in the network wanted |
---|
117 | //const float m_rho; // Rate of packets in the network wanted |
---|
118 | const size_t m_depth; // Fifo depth |
---|
119 | const size_t m_xmesh; |
---|
120 | const size_t m_ymesh; |
---|
121 | const size_t m_bc_period; // Broadcast period, if no broadcast => 0 |
---|
122 | const size_t m_xmin; |
---|
123 | const size_t m_xmax; |
---|
124 | const size_t m_ymin; |
---|
125 | const size_t m_ymax; |
---|
126 | const size_t m_srcid; |
---|
127 | |
---|
128 | size_t m_count; // Numbers of words sent |
---|
129 | size_t m_npackets; // Total number of packets already sent |
---|
130 | uint64_t m_start_latency1; // Start time of sending packet wanted |
---|
131 | uint64_t m_start_latency2; // Start time of sending packet |
---|
132 | // float m_rhos; // Effective Rho during the simulation |
---|
133 | size_t m_bc_nrsp; // Expected number of responses for a broadcast command |
---|
134 | addr_t m_address_to_send; // Address to send the write command |
---|
135 | |
---|
136 | // Fifo transmitting date to the VCI FSM |
---|
137 | GenericFifo<uint32_t> m_date_fifo; |
---|
138 | |
---|
139 | sc_signal<int> r_vci_fsm; |
---|
140 | |
---|
141 | sc_signal<size_t> r_index; |
---|
142 | |
---|
143 | sc_signal<bool> r_broadcast_req; |
---|
144 | |
---|
145 | |
---|
146 | }; // end class VciSyntheticInitiator |
---|
147 | |
---|
148 | }} |
---|
149 | |
---|
150 | #endif |
---|