OpenASIP  2.0
AvalonMMMasterInterface.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 AvalonMMMasterInterface.hh
26  *
27  * Implementation of AvalonMMMasterInterface class.
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
34 
41  "byteenable";
44 
50 const int AvalonMMMasterInterface::BYTE_ENABLE_DEF_WIDTH = WDATA_DEF_WIDTH/8;
53 
55  const TCEString& name,
56  const TCEString& declaration,
57  const TCEString& avalonPrefix,
58  const SOPCInterface& clock):
59  SOPCInterface(name, declaration), avalonPrefix_(avalonPrefix),
60  clock_(&clock) {
61 
63  masterPorts_.push_back(addr);
65  masterPorts_.push_back(wdata);
67  masterPorts_.push_back(rdata);
69  masterPorts_.push_back(read);
71  masterPorts_.push_back(write);
72  SOPCPort bEnable =
74  masterPorts_.push_back(bEnable);
75  SOPCPort waitReq =
77  masterPorts_.push_back(waitReq);
79  masterPorts_.push_back(irqRecv);
80 
81  // add default properties
82  setProperty("linewrapBursts", "false");
83  setProperty("adaptsTo", "\"\"");
84  setProperty("doStreamReads","false");
85  setProperty("doStreamWrites","false");
86  setProperty("burstOnBurstBoundariesOnly", "false");
88 }
89 
91 
92  for (unsigned int i = 0; i < childInterfaces_.size(); i++) {
93  if (childInterfaces_.at(i) != NULL) {
94  delete childInterfaces_.at(i);
95  }
96  }
97 }
98 
99 bool
101 
102  return findInterfacePort(port.name(), port.direction()) != NULL;
103 }
104 
105 void
107 
108  const SOPCPort* avalonPort =
109  findInterfacePort(port.name(), port.direction());
110  if (avalonPort->interfaceName == AVALON_MM_IRQ_RECV) {
111  addIrqInterface(port, *avalonPort);
112  } else {
113  int width = avalonPort->width;
114  if (port.realWidthAvailable()) {
115  width = port.realWidth();
116  }
117  setPort(port.name(), avalonPort->interfaceName,
118  avalonPort->direction, width);
119  }
120 }
121 
122 
123 void
124 AvalonMMMasterInterface::writeInterface(std::ostream& stream) const {
125 
127  for (unsigned int i = 0; i < childInterfaces_.size(); i++) {
128  childInterfaces_.at(i)->writeInterface(stream);
129  }
130 }
131 
134  TCEString hdlName,
135  ProGe::Direction direction) const {
136 
137  const SOPCPort* found = NULL;
138  for (unsigned int i = 0; i < masterPorts_.size(); i++) {
139  TCEString search = avalonPrefix_ + masterPorts_.at(i).interfaceName;
140  if (hdlName.find(search) != TCEString::npos) {
141  if (direction == masterPorts_.at(i).direction) {
142  found = &masterPorts_.at(i);
143  break;
144  }
145  }
146  }
147  return found;
148 }
149 
150 void
152  const ProGe::NetlistPort& port,
153  const SOPCPort& avalonPort) {
154 
155  TCEString irqName = name() + SOPC_IRQ_RECV_INT_NAME;
157  SOPCInterface* irq = new SOPCInterface(irqName, declr);
158  irq->setProperty("associatedAddressablePoint", name());
159  irq->setProperty("irqScheme", "INDIVIDUAL_REQUESTS");
161 
162  int width = avalonPort.width;
163  if (port.realWidthAvailable()) {
164  width = port.realWidth();
165  }
166  irq->setPort(port.name(), avalonPort.interfaceName,
167  avalonPort.direction, width);
168 
169  childInterfaces_.push_back(irq);
170 }
AvalonMMMasterInterface::AVALON_MM_WDATA
static const TCEString AVALON_MM_WDATA
Definition: AvalonMMMasterInterface.hh:57
AvalonMMMasterInterface::addIrqInterface
void addIrqInterface(const ProGe::NetlistPort &port, const SOPCPort &avalonPort)
Definition: AvalonMMMasterInterface.cc:151
SOPCInterface::setProperty
void setProperty(const TCEString &propertyName, const TCEString &propertyValue)
Definition: SOPCInterface.cc:73
AvalonMMMasterInterface::READ_DEF_WIDTH
static const int READ_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:86
AvalonMMMasterInterface::AVALON_MM_WRITE
static const TCEString AVALON_MM_WRITE
Definition: AvalonMMMasterInterface.hh:60
AvalonMMMasterInterface::addPort
void addPort(const ProGe::NetlistPort &port)
Definition: AvalonMMMasterInterface.cc:106
SOPCInterface::SOPCPort
Definition: SOPCInterface.hh:91
AvalonMMMasterInterface::BYTE_ENABLE_DEF_WIDTH
static const int BYTE_ENABLE_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:88
SOPCInterface::SOPC_ASSOCIATED_CLOCK
static const TCEString SOPC_ASSOCIATED_CLOCK
Definition: SOPCInterface.hh:70
AvalonMMMasterInterface::AVALON_MM_READ
static const TCEString AVALON_MM_READ
Definition: AvalonMMMasterInterface.hh:59
SOPCInterface
Definition: SOPCInterface.hh:41
ProGe::NetlistPort::direction
Direction direction() const
Definition: NetlistPort.cc:373
AvalonMMMasterInterface::AVALON_MM_ADDRESS
static const TCEString AVALON_MM_ADDRESS
Definition: AvalonMMMasterInterface.hh:56
AvalonMMMasterInterface::avalonPrefix_
TCEString avalonPrefix_
Definition: AvalonMMMasterInterface.hh:75
AvalonMMMasterInterface::RDATA_DEF_WIDTH
static const int RDATA_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:85
SOPCInterface::SOPC_IRQ_RECV_INT_NAME
static const TCEString SOPC_IRQ_RECV_INT_NAME
Definition: SOPCInterface.hh:82
AvalonMMMasterInterface::findInterfacePort
const SOPCPort * findInterfacePort(TCEString hdlName, ProGe::Direction direction) const
Definition: AvalonMMMasterInterface.cc:133
SOPCInterface::writeInterface
virtual void writeInterface(std::ostream &stream) const
Definition: SOPCInterface.cc:110
SOPCInterface::SOPCPort::width
int width
Definition: SOPCInterface.hh:95
AvalonMMMasterInterface.hh
AvalonMMMasterInterface::AVALON_MM_BYTE_ENABLE
static const TCEString AVALON_MM_BYTE_ENABLE
Definition: AvalonMMMasterInterface.hh:61
AvalonMMMasterInterface::isValidPort
bool isValidPort(const ProGe::NetlistPort &port) const
Definition: AvalonMMMasterInterface.cc:100
ProGe::NetlistPort::realWidthAvailable
bool realWidthAvailable() const
Definition: NetlistPort.cc:334
AvalonMMMasterInterface::WDATA_DEF_WIDTH
static const int WDATA_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:84
AvalonMMMasterInterface::~AvalonMMMasterInterface
virtual ~AvalonMMMasterInterface()
Definition: AvalonMMMasterInterface.cc:90
SOPCInterface::setPort
void setPort(const TCEString &hdlName, const TCEString &interfaceName, ProGe::Direction direction, int width)
Definition: SOPCInterface.cc:90
AvalonMMMasterInterface::AVALON_MM_IRQ_RECV
static const TCEString AVALON_MM_IRQ_RECV
Definition: AvalonMMMasterInterface.hh:63
AvalonMMMasterInterface::writeInterface
virtual void writeInterface(std::ostream &stream) const
Definition: AvalonMMMasterInterface.cc:124
SOPCInterface::name
TCEString name() const
Definition: SOPCInterface.cc:98
AvalonMMMasterInterface::masterPorts_
PortList masterPorts_
Definition: AvalonMMMasterInterface.hh:77
SOPCInterface::SOPC_IRQ_RECV_INT_DECLR
static const TCEString SOPC_IRQ_RECV_INT_DECLR
Definition: SOPCInterface.hh:83
AvalonMMMasterInterface::childInterfaces_
std::vector< SOPCInterface * > childInterfaces_
Definition: AvalonMMMasterInterface.hh:81
AvalonMMMasterInterface::AVALON_MM_RDATA
static const TCEString AVALON_MM_RDATA
Definition: AvalonMMMasterInterface.hh:58
ProGe::NetlistPort::name
std::string name() const
Definition: NetlistPort.cc:283
SOPCInterface::SOPCInterface
SOPCInterface()
ProGe::OUT
@ OUT
Output port.
Definition: ProGeTypes.hh:54
AvalonMMMasterInterface::WRITE_DEF_WIDTH
static const int WRITE_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:87
ProGe::NetlistPort::realWidth
int realWidth() const
Definition: NetlistPort.cc:348
SOPCInterface::SOPCPort::interfaceName
TCEString interfaceName
Definition: SOPCInterface.hh:93
TCEString
Definition: TCEString.hh:53
AvalonMMMasterInterface::AvalonMMMasterInterface
AvalonMMMasterInterface(const TCEString &name, const TCEString &declaration, const TCEString &avalonPrefix, const SOPCInterface &clock)
Definition: AvalonMMMasterInterface.cc:54
ProGe::NetlistPort
Definition: NetlistPort.hh:70
SOPCInterface::SOPCPort::direction
ProGe::Direction direction
Definition: SOPCInterface.hh:94
AvalonMMMasterInterface::ADDRESS_DEF_WIDTH
static const int ADDRESS_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:83
AvalonMMMasterInterface::IRQ_RECV_DEF_WIDTH
static const int IRQ_RECV_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:90
AvalonMMMasterInterface::WAIT_REQ_DEF_WIDTH
static const int WAIT_REQ_DEF_WIDTH
Definition: AvalonMMMasterInterface.hh:89
AvalonMMMasterInterface::clock_
const SOPCInterface * clock_
Definition: AvalonMMMasterInterface.hh:80
ProGe::Direction
Direction
Direction of the port.
Definition: ProGeTypes.hh:52
ProGe::IN
@ IN
Input port.
Definition: ProGeTypes.hh:53
AvalonMMMasterInterface::AVALON_MM_WAIT_REQ
static const TCEString AVALON_MM_WAIT_REQ
Definition: AvalonMMMasterInterface.hh:62