OpenASIP 2.2
Loading...
Searching...
No Matches
BlocksGCU.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2021 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file BlocksGCU.cc
26 *
27 * Implementation of BlocksGCU Class.
28 * This class describes the GCU unit of the Blocks (ABU of the TTA).
29 *
30 * @author Maarten Molendijk 2020 (m.j.molendijk@tue.nl)
31 * @author Kanishkan Vadivel 2021 (k.vadivel@tue.nl)
32 */
33
34#include "BlocksGCU.hh"
35
36using namespace TTAMachine;
37/**
38 * BlocksGCU with default instructions
39 *
40 * @param mach The TTA machine where the GCU(ABU) needs to be added.
41 * @param name The name of the GCU.
42 * @param asInstr The address space containing the program instructions.
43 */
45 Machine& mach, const std::string& name, AddressSpace& asInstr) {
46 int delaySlots = 2;
47 int globalGuardLatency = 1;
48 gcu = new ControlUnit(name, delaySlots, globalGuardLatency);
49 mach.setGlobalControl(*gcu);
50 gcu->setAddressSpace(&asInstr);
51
52 // TODO(mm): add check if there is not already a GCU present
53 pc = new FUPort("pc", 32, *gcu, true, true, true);
54 val = new FUPort("value", 32, *gcu, false, false, true);
55 ra = new SpecialRegisterPort("ra", 32, *gcu);
56
57 // Create in and ouput sockets for 'special RA port'
58 raIn = new Socket("raIn");
59 raOut = new Socket("abu_out0");
60 valIn = new Socket("value");
61 pcIn = new Socket("pc");
62 mach.addSocket(*raIn);
63 mach.addSocket(*raOut);
64 mach.addSocket(*valIn);
65 mach.addSocket(*pcIn);
70
71 // Connect in and out socket to bus
72 const int busWidth = 32;
73 const int immWidth = 0;
74 Machine::Extension busExt = Machine::Extension::ZERO;
75 Bus* raBus = new Bus("ra_out_to_ra_in", busWidth, immWidth, busExt);
76 mach.addBus(*raBus);
77 new UnconditionalGuard(false, *raBus);
78 new Segment("seg1", *raBus);
82 raOut->setDirection(Socket::Direction::OUTPUT);
83
84 // set RA port
86
87 // Add HWops
88 ops.push_back(CreateHWOp("bnz", 2));
89 ops.push_back(CreateHWOp("bz", 2));
90 ops.push_back(CreateHWOp("call", 1));
91 ops.push_back(CreateHWOp("jump", 1));
92}
93
94/**
95 * Configure the operation pipeline.
96 *
97 * @param pipeline A pointer to the execution pipeline of the operation of
98 * which the pipeline needs to be configured.
99 * @param numOfOperands The number of operands of the given hwOp.
100 */
101void
103 TTAMachine::ExecutionPipeline* pipeline, int numOfOperands) {
104 if (numOfOperands == 1) {
105 pipeline->addPortRead(1, 0, 1);
106 } else if (numOfOperands == 2) {
107 pipeline->addPortRead(1, 0, 1);
108 pipeline->addPortRead(2, 0, 1);
109 } else {
110 // Currently no operation known that uses a different numbers of
111 // operands.
112 assert(
113 false &&
114 "Trying to add a GCU operation with a different number of "
115 "operands than 1 or 2.");
116 }
117}
118
119/**
120 * Bind the operation's operands to GCU ports.
121 *
122 * @param hwOp A pointer to the hardware operation of which the operands need
123 * to be binded to GCU ports.
124 * @param numOfOperands The number of operands of the given hwOp.
125 */
126void
128 if (numOfOperands < 2) {
129 hwOp->bindPort(1, *pc);
130 } else {
131 hwOp->bindPort(2, *pc); // Program counter is operand 2, therfore
132 // port binding is switched.
133 hwOp->bindPort(1, *val);
134 }
135}
136
137/**
138 * Creates a hardware operation.
139 *
140 * @param name The name of the hardware operation. This needs to exactly match
141 * the name in OSEd.
142 * @param numOfOperands The number of operands that this hardware operation
143 * requires.
144 */
146BlocksGCU::CreateHWOp(const std::string& name, int numOfOperands) {
147 HWOperation* op = new HWOperation(name, *gcu);
148 BindPorts(op, numOfOperands);
149 ConfigurePipeline(op->pipeline(), numOfOperands);
150 return op;
151}
#define assert(condition)
void ConfigurePipeline(TTAMachine::ExecutionPipeline *pipeline, int numOfOperands)
Definition BlocksGCU.cc:102
TTAMachine::Socket * raOut
Definition BlocksGCU.hh:56
BlocksGCU(TTAMachine::Machine &mach, const std::string &name, TTAMachine::AddressSpace &asInstr)
Definition BlocksGCU.cc:44
TTAMachine::Bus * raBus
Definition BlocksGCU.hh:59
TTAMachine::FUPort * pc
Definition BlocksGCU.hh:52
TTAMachine::SpecialRegisterPort * ra
Definition BlocksGCU.hh:54
TTAMachine::Socket * pcIn
Definition BlocksGCU.hh:57
TTAMachine::FUPort * val
Definition BlocksGCU.hh:53
TTAMachine::HWOperation * CreateHWOp(const std::string &name, int numOfOperands)
Definition BlocksGCU.cc:146
TTAMachine::Socket * raIn
Definition BlocksGCU.hh:55
void BindPorts(TTAMachine::HWOperation *hwOp, int numOfOperands)
Definition BlocksGCU.cc:127
TTAMachine::Socket * valIn
Definition BlocksGCU.hh:58
std::vector< TTAMachine::HWOperation * > ops
Definition BlocksGCU.hh:77
TTAMachine::ControlUnit * gcu
Definition BlocksGCU.hh:48
void setReturnAddressPort(const SpecialRegisterPort &port)
void addPortRead(int operand, int start, int duration)
virtual void setAddressSpace(AddressSpace *as)
ExecutionPipeline * pipeline() const
virtual void bindPort(int operand, const FUPort &port)
virtual void addBus(Bus &bus)
Definition Machine.cc:139
virtual void setGlobalControl(ControlUnit &unit)
Definition Machine.cc:317
virtual void addSocket(Socket &socket)
Definition Machine.cc:157
virtual void attachSocket(Socket &socket)
Definition Port.cc:191
void setDirection(Direction direction)
Definition Socket.cc:130
void attachBus(Segment &bus)
Definition Socket.cc:166