source: trunk/modules/vci_synthetic_initator/caba/sources/include/vci_synthetic_initiator.h @ 190

Last change on this file since 190 was 190, checked in by zzhang, 12 years ago

fix some bugs in vdspin platform

File size: 5.2 KB
RevLine 
[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
51namespace 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
[77]79    protected:
80
81      SC_HAS_PROCESS(VciSyntheticInitiator);
82   
83    public:
84      sc_in<bool>                               p_clk;
85      sc_in<bool>                               p_resetn;
86      soclib::caba::VciInitiator<vci_param>     p_vci; 
87
88      VciSyntheticInitiator(
[78]89                sc_module_name name,
[102]90                const soclib::common::MappingTable &mt,
91                const soclib::common::IntTab       &vci_index,
92                const uint32_t length,    // Packet length (flit numbers)
[106]93                const uint32_t rho,       // Packets ratio on the network
[102]94                const uint32_t depth,     // Fifo depth
95                const uint32_t xmesh,   
96                const uint32_t ymesh,
97                const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0
98                const uint32_t xmin = 0, 
99                const uint32_t xmax = 0,
100                const uint32_t ymin = 0,
101                const uint32_t ymax = 0
[78]102                );                                 
[77]103
104      ~VciSyntheticInitiator();
105
106      void transition();
107
108      void genMoore();
109
[115]110      uint32_t destAdress();
[77]111
[115]112      uint32_t destAdress(uint32_t *rand_seed);
113
[106]114      void printStats();
115
[145]116      double getLatencySingle();
117
118      double getLatencyBC();
119
[106]120      void print_trace();
121
[77]122    private:
123
124      // Component attributes
[128]125      const size_t                m_length;             // Number of words to write
126      const size_t                m_rho;                // offered load * 1000
127      const size_t                m_depth;              // Fifo depth
128      const size_t                m_xmesh;     
129      const size_t                m_ymesh;
130      const size_t                m_bc_period;          // Broadcast period, if no broadcast => 0
131      const size_t                m_xmin; 
132      const size_t                m_xmax;
133      const size_t                m_ymin;
134      const size_t                m_ymax;
135      const size_t                m_srcid;
[135]136      static const size_t         m_tab_size = 1 << vci_param::T;
[77]137
[81]138
[128]139      // Fifo transmitting requests from the generator FSM to the VCI FSM
140      GenericFifo<uint64_t>     r_date_fifo;
141      GenericFifo<bool>         r_bc_fifo;
[122]142
[128]143      // VCI CMD FSM
[123]144      sc_signal<int>            r_cmd_fsm;
[128]145      sc_signal<addr_t>         r_cmd_address;  // Address for the single transaction
146      sc_signal<int>            r_cmd_trdid;    // TRDID for the single transaction
147      sc_signal<size_t>         r_cmd_count;    // Numbers of words sent
148      sc_signal<uint32_t>       r_cmd_seed;     // seed for reproducible address generation
[122]149
[128]150      // Broadcast FSM
[146]151      sc_signal<uint32_t>       r_bc_nrsp;         // Expected number of responses for a broadcast command
152      sc_signal<uint32_t>       r_time_to_next_bc; // Time to wait between 2 BC
[77]153       
[128]154      // Pending transaction FSMs
155      sc_signal<bool>*          r_pending_fsm;  // FSM states
156      sc_signal<uint64_t>*      r_pending_date; // single transaction requested date
[77]157
[128]158      // Instrumentation registers
159      sc_signal<uint64_t>       r_cpt_cycles;   // Local time
160      sc_signal<uint64_t>       r_cpt_period;   // Number of cycles between 2 broadcast transactions
161      sc_signal<size_t>         r_nb_single;    // Total number of single transactions
162      sc_signal<uint64_t>       r_latency_single;       // Total cumulated latency for single transactions
163      sc_signal<size_t>         r_nb_bc;        // Total number of bc transactions
164      sc_signal<uint64_t>       r_latency_bc;   // Total cumulated latency for broadcast transactions
[81]165
[78]166    }; // end class VciSyntheticInitiator
[77]167 
168  }}
169
170#endif
Note: See TracBrowser for help on using the repository browser.