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