orca-sim
ProcessingTile.cpp
Go to the documentation of this file.
1 
22 #include <iostream>
23 #include <sstream>
24 
25 //model API
26 #include <THFRiscV.h>
27 #include <TDmaNetif.h>
28 #include <TRouter.h>
29 #include <UMemory.h>
30 
31 #include <ProcessingTile.h>
32 
37 ProcessingTile::ProcessingTile(uint32_t x, uint32_t y) : Tile(x, y) {
38 
39  //ni sig wires
40  _signal_stall = new Signal<uint8_t>(this->GetName() + ".stall");
41  _signal_intr = new Signal<uint8_t>(this->GetName() + ".intr");
42  _signal_send_status = new Signal<uint8_t>(this->GetName() + ".send_status");
43  _signal_recv_status = new Signal<uint32_t>(this->GetName() + ".recv_status");
44  _signal_prog_send = new Signal<uint8_t>(this->GetName() + ".progr_send");
45  _signal_prog_recv = new Signal<uint8_t>(this->GetName() + ".progr_recv");
46  _signal_prog_addr = new Signal<uint32_t>(this->GetName() + ".progr_addr");
47  _signal_prog_size = new Signal<uint32_t>(this->GetName() + ".progr_size");
48 
49  //create a cpu and memory in addition to current tile hardware
50  _mem0 = new Memory(this->GetName() + ".mem0", MEM0_SIZE, MEM0_BASE); //main
51  _cpu = new HFRiscV(this->GetName() + ".cpu", _signal_intr, _signal_stall, _mem0);
52  _netif = new DmaNetif (this->GetName() + ".netif");
53 
54  //binds netif to mem
55  _netif->SetMem0(_mem0);
56 
57  //bind control signals to hardware (netif side)
58  _netif->SetSignalStall(_signal_stall);
59  _netif->SetSignalIntr(_signal_intr);
60  _netif->SetSignalSendStatus(_signal_send_status);
61  _netif->SetSignalRecvStatus(_signal_recv_status);
62  _netif->SetSignalProgSend(_signal_prog_send);
63  _netif->SetSignalProgRecv(_signal_prog_recv);
64  _netif->SetSignalProgAddr(_signal_prog_addr);
65  _netif->SetSignalProgSize(_signal_prog_size);
66 
67  //bind netif to router
68  this->GetRouter()->SetOutputBuffer(_netif->GetInputBuffer(), LOCAL);
69  _netif->SetOutputBuffer(this->GetRouter()->GetInputBuffer(LOCAL));
70 
71  //create new memories for the NI
72  _mem1 = new Memory(this->GetName() + ".mem1", MEM1_SIZE, 0); //read from noc
73  _mem2 = new Memory(this->GetName() + ".mem2", MEM2_SIZE, 0); //write to noc
74 
75  //bind memories
76  _netif->SetMem1(_mem1);
77  _netif->SetMem2(_mem2);
78 
79  //bind self-id wire (care to save the value before the bind)
80  this->GetSignalId()->MapTo(_mem0->GetMap(MAGIC_TILE_ID), MAGIC_TILE_ID);
81 
82  //update naming of internal hardware parts (from internal class)
83  this->GetRouter()->SetName(this->GetName() + ".router");
84  this->GetDmaNetif()->SetName(this->GetName() + ".netif");
85  this->GetMem1()->SetName(this->GetName() + ".mem1");
86  this->GetMem2()->SetName(this->GetName() + ".mem2");
87 
88  //bind control signals to hardware (cpu side)
89  this->GetSignalStall()->MapTo(_mem0->GetMap(SIGNAL_CPU_STALL), SIGNAL_CPU_STALL);
90  this->GetSignalIntr()->MapTo(_mem0->GetMap(SIGNAL_CPU_INTR), SIGNAL_CPU_INTR);
93 
94  this->GetSignalProgSend()->MapTo(_mem0->GetMap(SIGNAL_PROG_SEND), SIGNAL_PROG_SEND);
95  this->GetSignalProgRecv()->MapTo(_mem0->GetMap(SIGNAL_PROG_RECV), SIGNAL_PROG_RECV);
96 
97  this->GetSignalProgAddr()->MapTo(_mem0->GetMap(SIGNAL_PROG_ADDR), SIGNAL_PROG_ADDR);
98  this->GetSignalProgSize()->MapTo(_mem0->GetMap(SIGNAL_PROG_SIZE), SIGNAL_PROG_SIZE);
99 
100  //reset control wires
101  _signal_stall->Write(0);
102  _signal_intr->Write(0);
103 
104  _signal_send_status->Write(0);
105  _signal_recv_status->Write(0);
106  _signal_prog_send->Write(0);
107  _signal_prog_recv->Write(0);
108  _signal_prog_addr->Write(0);
109  _signal_prog_size->Write(0);
110 
111  #ifdef MEMORY_ENABLE_COUNTERS
112  //map main memory counter
113  _mem0->GetSignalCounterStore()->MapTo(_mem0->GetMap(M0_COUNTER_STORE_ADDR), M0_COUNTER_STORE_ADDR);
114  _mem0->GetSignalCounterLoad()->MapTo(_mem0->GetMap(M0_COUNTER_LOAD_ADDR), M0_COUNTER_LOAD_ADDR);
115 
116  //map secondary memory counters
117  _mem1->GetSignalCounterStore()->MapTo(_mem0->GetMap(M1_COUNTER_STORE_ADDR), M1_COUNTER_STORE_ADDR);
118  _mem1->GetSignalCounterLoad()->MapTo(_mem0->GetMap(M1_COUNTER_LOAD_ADDR), M1_COUNTER_LOAD_ADDR);
119  _mem2->GetSignalCounterStore()->MapTo(_mem0->GetMap(M2_COUNTER_STORE_ADDR), M2_COUNTER_STORE_ADDR);
120  _mem2->GetSignalCounterLoad()->MapTo(_mem0->GetMap(M2_COUNTER_LOAD_ADDR), M2_COUNTER_LOAD_ADDR);
121  #endif
122 
123  #ifdef ROUTER_ENABLE_COUNTERS
124  GetRouter()->GetSignalCounterActive()->MapTo(_mem0->GetMap(ROUTER_COUNTER_ACTIVE_ADDR), ROUTER_COUNTER_ACTIVE_ADDR);
125  #endif
126 
127  //----------------- initialize counters for the cpu
128  #ifdef HFRISCV_ENABLE_COUNTERS
129  _cpu->GetSignalCounterArith()->MapTo(_mem0->GetMap(CPU_COUNTER_ARITH_ADDR), CPU_COUNTER_ARITH_ADDR);
130  _cpu->GetSignalCounterLogical()->MapTo(_mem0->GetMap(CPU_COUNTER_LOGICAL_ADDR), CPU_COUNTER_LOGICAL_ADDR);
131  _cpu->GetSignalCounterShift()->MapTo(_mem0->GetMap(CPU_COUNTER_SHIFT_ADDR), CPU_COUNTER_SHIFT_ADDR);
132  _cpu->GetSignalCounterBranches()->MapTo(_mem0->GetMap(CPU_COUNTER_BRANCHES_ADDR), CPU_COUNTER_BRANCHES_ADDR);
133  _cpu->GetSignalCounterJumps()->MapTo(_mem0->GetMap(CPU_COUNTER_JUMPS_ADDR), CPU_COUNTER_JUMPS_ADDR);
134  _cpu->GetSignalCounterLoadStore()->MapTo(_mem0->GetMap(CPU_COUNTER_LOADSTORE_ADDR), CPU_COUNTER_LOADSTORE_ADDR);
135  _cpu->GetSignalCounterCyclesTotal()->MapTo(_mem0->GetMap(CPU_COUNTER_CYCLES_TOTAL_ADDR), CPU_COUNTER_CYCLES_TOTAL_ADDR);
136  _cpu->GetSignalCounterCyclesStall()->MapTo(_mem0->GetMap(CPU_COUNTER_CYCLES_STALL_ADDR), CPU_COUNTER_CYCLES_STALL_ADDR);
137  _cpu->GetSignalHostTime()->MapTo(_mem0->GetMap(CPU_COUNTER_HOSTTIME_ADDR), CPU_COUNTER_HOSTTIME_ADDR);
138  #endif
139 }
140 
142 
143  delete(_cpu);
144  delete(_mem0);
145 
146  delete(_netif);
147  delete(_mem1);
148  delete(_mem2);
149 
150  //delete signals
151  delete(_signal_stall);
152  delete(_signal_intr);
153  delete(_signal_send_status);
154  delete(_signal_recv_status);
155  delete(_signal_prog_send);
156  delete(_signal_prog_recv);
157  delete(_signal_prog_addr);
158  delete(_signal_prog_size);
159 }
160 
162  return _cpu;
163 }
164 
165 
171  return _netif;
172 }
173 
179  return _mem1;
180 }
181 
187  return _mem2;
188 }
189 
190 /************************************* GETTERS **************************************/
191 Signal<uint8_t>* ProcessingTile::GetSignalStall(){ return _signal_stall; }
192 Signal<uint8_t>* ProcessingTile::GetSignalIntr(){ return _signal_intr; }
193 
196 
199 
202 
208  return _signal_hosttime;
209 }
210 
212  return _mem0;
213 }
214 
216  stringstream ss;
217  ss << this->GetName() << "={" << _cpu->GetName()
218  << ", " << this->GetRouter()->GetName()
219  << ", " << this->GetDmaNetif()->GetName() << "}";
220 
221  return ss.str();
222 }
#define MEM0_BASE
Signal< uint8_t > * GetSignalIntr()
#define MAGIC_TILE_ID
Definition: _MemoryMap.h:28
#define SIGNAL_PROG_RECV
Definition: _MemoryMap.h:21
void MapTo(bool keep_val=true)
Maps current Signal to the internal storage.
Definition: Signal.cpp:79
#define MEM0_SIZE
This file is part of project URSA.
Signal< uint8_t > * _signal_prog_send
Memory * GetMem2()
Get recv memory module.
#define SIGNAL_PROG_SEND
Definition: _MemoryMap.h:20
#define SIGNAL_PROG_ADDR
Definition: _MemoryMap.h:24
Signal< uint8_t > * GetSignalSendStatus()
Signal< uint8_t > * _signal_send_status
Signal< uint8_t > * _signal_intr
Signal< uint32_t > * _signal_hosttime
#define SIGNAL_CPU_STALL
Definition: _MemoryMap.h:12
Signal< uint8_t > * GetSignalStall()
ProcessingTile()
This file is part of project URSA.
#define SIGNAL_SEND_STATUS
Definition: _MemoryMap.h:14
std::string GetName()
Memory * GetMem1()
Get sender memory module.
#define MEM1_SIZE
This file is part of project URSA.
Definition: Tile.h:38
#define MEM2_SIZE
Definition: Tile.h:41
#define LOCAL
Signal< uint32_t > * GetSignalProgSize()
void Write(T val)
Writes some value to the bus.
Definition: Signal.cpp:127
Signal< uint32_t > * _signal_prog_size
HermesRouter * GetRouter()
Get current router of the PE.
Definition: Tile.cpp:83
#define SIGNAL_PROG_SIZE
Definition: _MemoryMap.h:25
HFRiscV * _cpu
Definition: Tile.h:44
Signal< uint32_t > * GetSignalId()
Get current signal for tile ID.
Definition: Tile.cpp:100
Signal< uint32_t > * GetSignalHostTime()
Get current signal for systime signal.
Signal< uint8_t > * GetSignalProgRecv()
Signal< uint8_t > * GetSignalProgSend()
Signal< uint8_t > * _signal_prog_recv
Signal< uint8_t > * _signal_stall
Memory * GetMem0()
HFRiscV * GetCpu()
DmaNetif * _netif
#define SIGNAL_RECV_STATUS
Definition: _MemoryMap.h:16
Signal< uint32_t > * GetSignalProgAddr()
std::string ToString()
Signal< uint32_t > * _signal_prog_addr
DmaNetif * GetDmaNetif()
Get current NI module.
Signal< uint32_t > * GetSignalRecvStatus()
Signal< uint32_t > * _signal_recv_status
This class models an entire processing element that contains RAM memory (3x), DMA, NoC Router, HFRiscV core.
#define SIGNAL_CPU_INTR
Definition: _MemoryMap.h:13