OpenASIP 2.2
Loading...
Searching...
No Matches
BlocksLSU.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 BlocksLSU.cc
26 *
27 * Implementation of BlocksLSU Class.
28 * This class resembles a single output in the Blocks architecture.
29 *
30 * @author Maarten Molendijk 2020 (m.j.molendijk@tue.nl)
31 * @author Kanishkan Vadivel 2021 (k.vadivel@tue.nl)
32 */
33#include "BlocksLSU.hh"
34
35using namespace TTAMachine;
36
37/**
38 * BlocksLSU with default instructions
39 *
40 * @param mach The TTA machine where the LSU needs to be added.
41 * @param name The name of the LSU.
42 * @param sources A list of sources that are attached to this unit's input.
43 * @param asData The address space containing the program data.
44 * @param in1sock (shared) pointer to the TTA socket for in1 input port.
45 * @param in2sock (shared) pointer to the TTA socket for in2 input port.
46 */
48 Machine& mach, const std::string& name, std::list<std::string> sources,
49 AddressSpace& asData, std::shared_ptr<TTAMachine::Socket> in1sock,
50 std::shared_ptr<TTAMachine::Socket> in2sock)
51 : BlocksFU::BlocksFU(mach, name, sources, in1sock, in2sock) {
52 // Function unit and ports
53 lsu = this->fu;
54 // Set adress space to data
55 lsu->setAddressSpace(&asData);
56
57 // HWOps
58 ops.push_back(CreateHWLoadOp("ld32"));
59 ops.push_back(CreateHWLoadOp("ldu16"));
60 ops.push_back(CreateHWLoadOp("ldu8"));
61 ops.push_back(CreateHWStoreOp("st16"));
62 ops.push_back(CreateHWStoreOp("st8"));
63 ops.push_back(CreateHWStoreOp("st32"));
64 ops.push_back(CreateHWLoadOp("copy"));
65}
66
67/**
68 * Constructor for BlocksLSUPair
69 *
70 * @param mach The TTA machine where the LSU pair needs to be added.
71 * @param name The name of the LSU pair.
72 * @param sources A list of sources that are attached to this unit's input.
73 * @param asData The address space containing the program data.
74 * @param usesOut0 A boolean that indicates whether output port 0 of the FU is
75 * used in the Blocks.
76 * @param usesOut1 A boolean that indicates whether output port 1 of the FU is
77 * used in the Blocks.
78 */
80 TTAMachine::Machine& mach, const std::string& name,
81 std::list<std::string> sources, TTAMachine::AddressSpace& asData,
82 bool usesOut0, bool usesOut1)
83 : sources(sources) {
84 in1sock = std::make_shared<TTAMachine::Socket>(name + "_in1t");
85 in2sock = std::make_shared<TTAMachine::Socket>(name + "_in2");
86 mach.addSocket(*(in1sock.get()));
87 mach.addSocket(*(in2sock.get()));
88 if (usesOut0)
89 lsu0.reset(new BlocksLSU(
90 mach, name + "_out0", sources, asData, in1sock, in2sock));
91 if (usesOut1)
92 lsu1.reset(new BlocksLSU(
93 mach, name + "_out1", sources, asData, in1sock, in2sock));
94}
95
96/**
97 * Creates a hardware load operation.
98 *
99 * @param name The name of the hardware operation. This needs to exactly match
100 * the name in OSEd.
101 */
103BlocksLSU::CreateHWLoadOp(const std::string& name) {
104 HWOperation* op = new HWOperation(name, *lsu);
105 BindPorts(op, true);
106 ConfigurePipeline(op->pipeline(), true);
107 return op;
108}
109/**
110 * Creates a hardware store operation.
111 *
112 * @param name The name of the hardware operation. This needs to exactly match
113 * the name in OSEd.
114 */
116BlocksLSU::CreateHWStoreOp(const std::string& name) {
117 HWOperation* op = new HWOperation(name, *lsu);
118 BindPorts(op, false);
119 ConfigurePipeline(op->pipeline(), false);
120 return op;
121}
122
123/**
124 * Bind the operation's operands to FU ports.
125 *
126 * @param hwOp A pointer to the hardware operation of which the operands need
127 * to be binded to FU ports.
128 * @param isLoadOp A boolean that indicates whether the operation given is a
129 * load operation(true) or store operation(false).
130 */
131void
133 if (isLoadOp) { // Load operation
134 hwOp->bindPort(1, *in1); // Memory address to read
135 hwOp->bindPort(2, *out); // Data
136 } else { // Store operation
137 hwOp->bindPort(1, *in1); // Memory address to write
138 hwOp->bindPort(2, *in2); // Data to write
139 }
140}
141
142/**
143 * Configure the operation pipeline.
144 *
145 * @param pipeline A pointer to the execution pipeline of the operation of
146 * which the pipeline needs to be configured.
147 * @param isLoadOp A boolean that indicates whether the operation given is a
148 * load operation(true) or store operation(false).
149 */
150void
152 TTAMachine::ExecutionPipeline* pipeline, bool isLoadOp) {
153 if (isLoadOp) {
154 pipeline->addPortRead(1, 0, 1);
155 pipeline->addPortWrite(2, 0, 1);
156 } else {
157 pipeline->addPortRead(1, 0, 1);
158 pipeline->addPortRead(2, 0, 1);
159 }
160}
TTAMachine::FUPort * out
Definition BlocksFU.hh:63
TTAMachine::FUPort * in1
Definition BlocksFU.hh:61
TTAMachine::FunctionUnit * fu
Definition BlocksFU.hh:60
std::string name
Definition BlocksFU.hh:68
std::vector< TTAMachine::HWOperation * > ops
Definition BlocksFU.hh:59
TTAMachine::FUPort * in2
Definition BlocksFU.hh:62
std::shared_ptr< TTAMachine::Socket > in2sock
Definition BlocksLSU.hh:74
std::unique_ptr< BlocksLSU > lsu0
Definition BlocksLSU.hh:71
std::shared_ptr< TTAMachine::Socket > in1sock
Definition BlocksLSU.hh:73
std::unique_ptr< BlocksLSU > lsu1
Definition BlocksLSU.hh:72
std::list< std::string > sources
Definition BlocksLSU.hh:75
BlocksLSUPair(TTAMachine::Machine &mach, const std::string &name, std::list< std::string > sources, TTAMachine::AddressSpace &asData, bool usesOut0, bool usesOut1)
Definition BlocksLSU.cc:79
TTAMachine::FunctionUnit * lsu
Definition BlocksLSU.hh:43
void ConfigurePipeline(TTAMachine::ExecutionPipeline *pipeline, bool isLoadOp)
Definition BlocksLSU.cc:151
TTAMachine::HWOperation * CreateHWStoreOp(const std::string &name)
Definition BlocksLSU.cc:116
TTAMachine::HWOperation * CreateHWLoadOp(const std::string &name)
Definition BlocksLSU.cc:103
BlocksLSU(TTAMachine::Machine &mach, const std::string &name, std::list< std::string > sources, TTAMachine::AddressSpace &asData, std::shared_ptr< TTAMachine::Socket > in1sock, std::shared_ptr< TTAMachine::Socket > in2sock)
Definition BlocksLSU.cc:47
void BindPorts(TTAMachine::HWOperation *hwOp, bool isLoadOp)
Definition BlocksLSU.cc:132
void addPortRead(int operand, int start, int duration)
void addPortWrite(int operand, int start, int duration)
virtual void setAddressSpace(AddressSpace *as)
ExecutionPipeline * pipeline() const
virtual void bindPort(int operand, const FUPort &port)
virtual void addSocket(Socket &socket)
Definition Machine.cc:157