[77] | 1 | /* -*- c++ -*- |
---|
| 2 | * File : vci_synthetic_initiator.h |
---|
| 3 | * Date : 26/08/2010 |
---|
| 4 | * Copyright : UPMC / LIP6 |
---|
| 5 | * Authors : Christophe Choichillon |
---|
[131] | 6 | * Version : 2.1 |
---|
[123] | 7 | * |
---|
[77] | 8 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
| 9 | * |
---|
| 10 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
| 11 | * |
---|
| 12 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
| 13 | * under the terms of the GNU Lesser General Public License as published |
---|
| 14 | * by the Free Software Foundation; version 2.1 of the License. |
---|
| 15 | * |
---|
| 16 | * SoCLib is distributed in the hope that it will be useful, but |
---|
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 19 | * Lesser General Public License for more details. |
---|
| 20 | * |
---|
| 21 | * You should have received a copy of the GNU Lesser General Public |
---|
| 22 | * License along with SoCLib; if not, write to the Free Software |
---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 24 | * 02110-1301 USA |
---|
| 25 | * |
---|
| 26 | * SOCLIB_LGPL_HEADER_END |
---|
| 27 | * |
---|
[131] | 28 | * Versions : |
---|
| 29 | * - 1.0 Sending only one request at a time |
---|
| 30 | * - 2.0 Sending multiple transactions and broadcast responses |
---|
| 31 | * identified with pktid (deprecated) |
---|
| 32 | * - 2.1 Broadcast responses identified with the value 0 of trdid |
---|
| 33 | * |
---|
[77] | 34 | * Maintainers: christophe.choichillon@lip6.fr |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | #ifndef SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
| 38 | #define SOCLIB_CABA_SYNTHETIC_INITIATOR_H |
---|
| 39 | |
---|
[131] | 40 | #include <cassert> |
---|
[77] | 41 | #include <systemc> |
---|
[98] | 42 | #include <inttypes.h> |
---|
| 43 | #include "generic_fifo.h" |
---|
| 44 | #include "vci_initiator.h" |
---|
| 45 | #include "soclib_endian.h" |
---|
| 46 | #include "caba_base_module.h" |
---|
| 47 | #include "int_tab.h" |
---|
| 48 | #include "mapping_table.h" |
---|
[111] | 49 | #include "arithmetics.h" |
---|
[77] | 50 | |
---|
| 51 | namespace soclib { namespace caba { |
---|
| 52 | using namespace sc_core; |
---|
| 53 | |
---|
| 54 | template<typename vci_param> |
---|
| 55 | class VciSyntheticInitiator |
---|
| 56 | : public soclib::caba::BaseModule |
---|
| 57 | { |
---|
[106] | 58 | typedef uint32_t addr_t; |
---|
[77] | 59 | typedef uint32_t data_t; |
---|
| 60 | typedef uint32_t tag_t; |
---|
| 61 | typedef uint32_t size_t; |
---|
| 62 | typedef uint32_t be_t; |
---|
| 63 | typedef uint32_t copy_t; |
---|
| 64 | |
---|
| 65 | |
---|
[128] | 66 | /* States of the VCI CMD fsm */ |
---|
[77] | 67 | enum vci_fsm_state_e{ |
---|
| 68 | VCI_IDLE, |
---|
| 69 | VCI_SINGLE_SEND, |
---|
| 70 | VCI_BC_SEND, |
---|
[131] | 71 | VCI_SINGLE_REGISTER |
---|
[77] | 72 | }; |
---|
| 73 | |
---|
[128] | 74 | enum bc_fsm_state_e{ |
---|
[123] | 75 | BC_RSP_IDLE, |
---|
| 76 | BC_RSP_WAIT_RSP |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | |
---|
[81] | 80 | |
---|
[77] | 81 | |
---|
| 82 | protected: |
---|
| 83 | |
---|
| 84 | SC_HAS_PROCESS(VciSyntheticInitiator); |
---|
| 85 | |
---|
| 86 | public: |
---|
| 87 | sc_in<bool> p_clk; |
---|
| 88 | sc_in<bool> p_resetn; |
---|
| 89 | soclib::caba::VciInitiator<vci_param> p_vci; |
---|
| 90 | |
---|
| 91 | VciSyntheticInitiator( |
---|
[78] | 92 | sc_module_name name, |
---|
[102] | 93 | const soclib::common::MappingTable &mt, |
---|
| 94 | const soclib::common::IntTab &vci_index, |
---|
| 95 | const uint32_t length, // Packet length (flit numbers) |
---|
[106] | 96 | const uint32_t rho, // Packets ratio on the network |
---|
[102] | 97 | const uint32_t depth, // Fifo depth |
---|
| 98 | const uint32_t xmesh, |
---|
| 99 | const uint32_t ymesh, |
---|
| 100 | const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0 |
---|
| 101 | const uint32_t xmin = 0, |
---|
| 102 | const uint32_t xmax = 0, |
---|
| 103 | const uint32_t ymin = 0, |
---|
| 104 | const uint32_t ymax = 0 |
---|
[78] | 105 | ); |
---|
[77] | 106 | |
---|
| 107 | ~VciSyntheticInitiator(); |
---|
| 108 | |
---|
| 109 | void transition(); |
---|
| 110 | |
---|
| 111 | void genMoore(); |
---|
| 112 | |
---|
[115] | 113 | uint32_t destAdress(); |
---|
[77] | 114 | |
---|
[115] | 115 | uint32_t destAdress(uint32_t *rand_seed); |
---|
| 116 | |
---|
[106] | 117 | void printStats(); |
---|
| 118 | |
---|
[145] | 119 | double getLatencySingle(); |
---|
| 120 | |
---|
| 121 | double getLatencyBC(); |
---|
| 122 | |
---|
[106] | 123 | void print_trace(); |
---|
| 124 | |
---|
[77] | 125 | private: |
---|
| 126 | |
---|
| 127 | // Component attributes |
---|
[128] | 128 | const size_t m_length; // Number of words to write |
---|
| 129 | const size_t m_rho; // offered load * 1000 |
---|
| 130 | const size_t m_depth; // Fifo depth |
---|
| 131 | const size_t m_xmesh; |
---|
| 132 | const size_t m_ymesh; |
---|
| 133 | const size_t m_bc_period; // Broadcast period, if no broadcast => 0 |
---|
| 134 | const size_t m_xmin; |
---|
| 135 | const size_t m_xmax; |
---|
| 136 | const size_t m_ymin; |
---|
| 137 | const size_t m_ymax; |
---|
| 138 | const size_t m_srcid; |
---|
[135] | 139 | static const size_t m_tab_size = 1 << vci_param::T; |
---|
[77] | 140 | |
---|
[81] | 141 | |
---|
[128] | 142 | // Fifo transmitting requests from the generator FSM to the VCI FSM |
---|
| 143 | GenericFifo<uint64_t> r_date_fifo; |
---|
| 144 | GenericFifo<bool> r_bc_fifo; |
---|
[122] | 145 | |
---|
[128] | 146 | // VCI CMD FSM |
---|
[123] | 147 | sc_signal<int> r_cmd_fsm; |
---|
[128] | 148 | sc_signal<addr_t> r_cmd_address; // Address for the single transaction |
---|
| 149 | sc_signal<int> r_cmd_trdid; // TRDID for the single transaction |
---|
| 150 | sc_signal<size_t> r_cmd_count; // Numbers of words sent |
---|
| 151 | sc_signal<uint32_t> r_cmd_seed; // seed for reproducible address generation |
---|
[122] | 152 | |
---|
[128] | 153 | // Broadcast FSM |
---|
[146] | 154 | sc_signal<uint32_t> r_bc_nrsp; // Expected number of responses for a broadcast command |
---|
| 155 | sc_signal<uint32_t> r_time_to_next_bc; // Time to wait between 2 BC |
---|
[77] | 156 | |
---|
[128] | 157 | // Pending transaction FSMs |
---|
| 158 | sc_signal<bool>* r_pending_fsm; // FSM states |
---|
| 159 | sc_signal<uint64_t>* r_pending_date; // single transaction requested date |
---|
[77] | 160 | |
---|
[128] | 161 | // Instrumentation registers |
---|
| 162 | sc_signal<uint64_t> r_cpt_cycles; // Local time |
---|
| 163 | sc_signal<uint64_t> r_cpt_period; // Number of cycles between 2 broadcast transactions |
---|
| 164 | sc_signal<size_t> r_nb_single; // Total number of single transactions |
---|
| 165 | sc_signal<uint64_t> r_latency_single; // Total cumulated latency for single transactions |
---|
| 166 | sc_signal<size_t> r_nb_bc; // Total number of bc transactions |
---|
| 167 | sc_signal<uint64_t> r_latency_bc; // Total cumulated latency for broadcast transactions |
---|
[81] | 168 | |
---|
[78] | 169 | }; // end class VciSyntheticInitiator |
---|
[77] | 170 | |
---|
| 171 | }} |
---|
| 172 | |
---|
| 173 | #endif |
---|