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

Last change on this file since 123 was 123, checked in by choichil, 13 years ago

Synthetic Initiator with parallel transactions

File size: 4.7 KB
Line 
1/* -*- c++ -*-
2 * File         : vci_synthetic_initiator.h
3 * Date         : 26/08/2010
4 * Copyright    : UPMC / LIP6
5 * Authors      : Christophe Choichillon
6 * Version      : 2.0
7 *
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 *
28 * Maintainers: christophe.choichillon@lip6.fr
29 */
30
31#ifndef SOCLIB_CABA_SYNTHETIC_INITIATOR_H
32#define SOCLIB_CABA_SYNTHETIC_INITIATOR_H
33
34#include <systemc>
35#include <inttypes.h>
36#include "generic_fifo.h"
37#include "vci_initiator.h"
38#include "soclib_endian.h"
39#include "caba_base_module.h"
40#include "int_tab.h"
41#include "mapping_table.h"
42#include "arithmetics.h"
43//#include <cmath>
44
45namespace soclib {  namespace caba {
46    using namespace sc_core;
47
48    template<typename vci_param>
49    class VciSyntheticInitiator
50      : public soclib::caba::BaseModule
51    {
52      typedef uint32_t addr_t;
53      typedef uint32_t data_t;
54      typedef uint32_t tag_t;
55      typedef uint32_t size_t;
56      typedef uint32_t be_t;
57      typedef uint32_t copy_t;
58
59
60      /* States of the GENERATOR fsm */
61      enum vci_fsm_state_e{
62        VCI_IDLE,
63        VCI_SINGLE_SEND,
64        VCI_BC_SEND,
65      };
66
67      enum bc_rsp_fsm_state_e{
68        BC_RSP_IDLE,
69        BC_RSP_WAIT_RSP
70      };
71
72
73      uint64_t     m_cpt_cycles;            // Counter of cycles
74     
75
76    protected:
77
78      SC_HAS_PROCESS(VciSyntheticInitiator);
79   
80    public:
81      sc_in<bool>                               p_clk;
82      sc_in<bool>                               p_resetn;
83      soclib::caba::VciInitiator<vci_param>     p_vci; 
84
85      VciSyntheticInitiator(
86                sc_module_name name,
87                const soclib::common::MappingTable &mt,
88                const soclib::common::IntTab       &vci_index,
89                const uint32_t length,    // Packet length (flit numbers)
90                const uint32_t rho,       // Packets ratio on the network
91                const uint32_t depth,     // Fifo depth
92                const uint32_t xmesh,   
93                const uint32_t ymesh,
94                const uint32_t bc_period = 0, // Broadcast period, if no broadcast => 0
95                const uint32_t xmin = 0, 
96                const uint32_t xmax = 0,
97                const uint32_t ymin = 0,
98                const uint32_t ymax = 0
99                );                                 
100
101      ~VciSyntheticInitiator();
102
103      void transition();
104
105      void genMoore();
106
107      uint32_t destAdress();
108
109      uint32_t destAdress(uint32_t *rand_seed);
110
111      void printStats();
112
113      void print_trace();
114
115    private:
116
117      // Component attributes
118      const size_t                        m_length;             // Number of words to write
119      const size_t                        m_rho;                // Rate of packets in the network wanted
120      //const float                       m_rho;                // Rate of packets in the network wanted
121      const size_t                        m_depth;              // Fifo depth
122      const size_t                        m_xmesh;     
123      const size_t                        m_ymesh;
124      const size_t                        m_bc_period;          // Broadcast period, if no broadcast => 0
125      const size_t                        m_xmin; 
126      const size_t                        m_xmax;
127      const size_t                        m_ymin;
128      const size_t                        m_ymax;
129      const size_t                        m_srcid;
130
131      size_t                              m_count;                  // Numbers of words sent
132      size_t                              m_npackets;               // Total number of packets already sent
133      uint64_t                            m_start_latency1;         // Start time of sending packet wanted
134      uint64_t                            m_start_latency2;         // Start time of sending packet
135      uint64_t                            m_latency1;               // Average latency wanted
136      uint64_t                            m_latency2;               // Average latency
137      addr_t                              m_address_to_send;        // Address to send the write command
138      uint32_t                            m_local_seed;
139      int                                 m_id_to_send;
140
141      uint64_t                            m_start_latency_bc;
142      uint64_t                            m_latency_bc;
143      uint64_t                            m_nb_bc;
144
145      static const int                    tab_size = 1 << vci_param::T;
146      // Fifo transmitting date to the VCI FSM
147      GenericFifo<uint32_t>     m_date_fifo;
148
149      sc_signal<int>            r_cmd_fsm;
150
151      sc_signal<int>            r_bc_rsp_fsm;
152       
153      sc_signal<size_t>         r_index;
154
155      sc_signal<bool>           r_broadcast_req;
156
157      sc_signal<bool>           r_broadcast_rsp;
158
159      sc_signal<uint32_t>       r_bc_nrsp;                  // Expected number of responses for a broadcast command
160
161      sc_signal<uint64_t>       **r_req_id;
162
163
164    }; // end class VciSyntheticInitiator
165 
166  }}
167
168#endif
Note: See TracBrowser for help on using the repository browser.