orca-sim
HermesRouter.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * This file is part of project ORCA. More information on the project
3  * can be found at the following repositories at GitHub's website.
4  *
5  * http://https://github.com/andersondomingues/orca-sim
6  * http://https://github.com/andersondomingues/orca-software
7  * http://https://github.com/andersondomingues/orca-mpsoc
8  * http://https://github.com/andersondomingues/orca-tools
9  *
10  * Copyright (C) 2018-2020 Anderson Domingues, <ti.andersondomingues@gmail.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 ******************************************************************************/
26 #ifndef MODELS_HERMES_ROUTER_INCLUDE_HERMESROUTER_HPP_
27 #define MODELS_HERMES_ROUTER_INCLUDE_HERMESROUTER_HPP_
28 
29 // std API
30 #include <iostream>
31 #include <string>
32 
33 // simulator API
34 #include "TimedModel.hpp"
35 #include "Buffer.hpp"
36 #include "Signal.hpp"
37 #include "FlitType.hpp"
38 
39 #ifndef BUFFER_CAPACITY
40 #define BUFFER_CAPACITY 8
41 #pragma message "Buffer capacity not defined in HermesRouter, set to 8 flits"
42 #endif
43 
44 namespace orcasim::models::hermes {
45 
46 enum class RouterState{
48 };
49 
50 // routing ports
51 #define NORTH 0
52 #define WEST 1
53 #define SOUTH 2
54 #define EAST 3
55 #define LOCAL 4
56 
60 
61 class HermesRouter: public TimedModel{
62  private:
63  #ifdef ROUTER_ENABLE_COUNTERS
64  Signal<uint32_t>* _counter_active;
65  #endif
66 
67  #ifdef ROUTER_ENABLE_COUNTERS
68  bool is_active = false;
69  #endif
70 
71  // stores info about actively sending ports. For intance, position zero
72  // representing the status of LOCAL port. The value in the position indicate
73  // to which port the LOCAL port is sending to. Inactive ports have -1
74  // written to their position.
75  int16_t _switch_control[5];
76 
77  // stores how many flits the must be forwarded to the destination port
78  int16_t _flits_to_send[5];
79 
80  // stores which port has the priority acconding to the round robin policy
81  uint32_t _round_robin;
82 
83  // address of the router
84  uint32_t _x, _y;
85 
86  // output buffers
88 
89  // input buffers
91 
92  public:
93  #ifdef ROUTER_ENABLE_COUNTERS
94  Signal<uint32_t>* GetSignalCounterActive();
95  #endif
96 
97  uint32_t GetRR();
98 
99  Buffer<FlitType>* GetOutputBuffer(uint32_t p);
100  Buffer<FlitType>* GetInputBuffer(uint32_t p);
101 
102  void SetOutputBuffer(Buffer<FlitType>* b, uint32_t port);
103 
106  SimulationTime Run();
107 
109  uint32_t GetRouteXY(FlitType flit);
110 
112  HermesRouter(std::string name, uint32_t x_pos, uint32_t y_pos);
113 
115  ~HermesRouter();
116 
121  std::string GetPortName(int port);
122 
123  void Reset();
124  std::string ToString();
125 };
126 
127 } // namespace orcasim::models::hermes
128 #endif // MODELS_HERMES_ROUTER_INCLUDE_HERMESROUTER_HPP_
This class models a TimedModel.
Definition: TimedModel.hpp:42
uint32_t SimulationTime