OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ProGe::ProcessorWrapperBlock Class Reference

#include <ProcessorWrapperBlock.hh>

Inheritance diagram for ProGe::ProcessorWrapperBlock:
Inheritance graph
Collaboration diagram for ProGe::ProcessorWrapperBlock:
Collaboration graph

Public Member Functions

 ProcessorWrapperBlock ()=delete
 
 ProcessorWrapperBlock (const ProGeContext &context, const BaseNetlistBlock &processorBlock)
 
virtual ~ProcessorWrapperBlock ()
 
virtual void write (const Path &targetBaseDir, HDL targetLang=VHDL) const override
 
- Public Member Functions inherited from ProGe::BaseNetlistBlock
 BaseNetlistBlock ()
 
 BaseNetlistBlock (BaseNetlistBlock *parent)
 
 BaseNetlistBlock (const std::string &moduleName, const std::string &instanceName, BaseNetlistBlock *parent=nullptr)
 
virtual ~BaseNetlistBlock ()
 
const std::string & instanceName () const
 
void setInstanceName (const std::string &name)
 
const std::string & moduleName () const
 
const std::string name () const
 
virtual size_t subBlockCount () const
 
virtual const BaseNetlistBlocksubBlock (size_t index) const
 
virtual bool hasSubBlock (const std::string &instanceName) const
 
virtual bool isSubBlock (const BaseNetlistBlock &block) const
 
virtual bool hasParameter (const std::string &name) const
 
virtual const Parameterparameter (const std::string &name) const
 
virtual size_t parameterCount () const
 
virtual const Parameterparameter (size_t index) const
 
virtual size_t portCount () const
 
virtual const NetlistPortport (size_t index) const
 
virtual std::vector< const NetlistPort * > portsBy (SignalType type) const
 
virtual const NetlistPortportBy (SignalType type, size_t index=0) const
 
virtual bool hasPortsBy (SignalType type) const
 
virtual const NetlistPortport (const std::string &portName, bool partialMatch=true) const
 
virtual size_t portGroupCount () const
 
virtual const NetlistPortGroupportGroup (size_t index) const
 
virtual std::vector< const NetlistPortGroup * > portGroupsBy (SignalGroupType type) const
 
virtual const Netlistnetlist () const
 
virtual bool hasParentBlock () const
 
virtual const BaseNetlistBlockparentBlock () const
 
virtual bool isVirtual () const
 
virtual void build () override
 
virtual void connect () override
 
virtual void finalize () override
 
virtual void writeSelf (const Path &targetBaseDir, HDL targetLang=VHDL) const
 
virtual size_t packageCount () const
 
virtual const std::string & package (size_t idx) const
 
PortContainerTypeports ()
 
virtual bool isLeaf () const
 
BaseNetlistBlockshallowCopy (const std::string &instanceName="") const
 
- Public Member Functions inherited from ProGe::IGenerationPhases
virtual ~IGenerationPhases ()
 

Private Member Functions

void addInstructionMemory (const NetlistPortGroup &)
 
void addDataMemory (const MemoryBusInterface &)
 
void addDataMemory2 (const MemoryBusInterface &)
 
void connectLockStatus (const NetlistPort &topPCInitPort)
 
void connectPCInit (const NetlistPort &topPCInitPort)
 
void handleUnconnectedPorts ()
 

Private Attributes

const ProGeContextcontext_
 
BaseNetlistBlockcoreBlock_
 The target TTA processor. More...
 
unsigned imemCount_ = 0
 

Additional Inherited Members

- Public Types inherited from ProGe::BaseNetlistBlock
typedef std::vector< BaseNetlistBlock * > BlockContainerType
 
typedef std::vector< ParameterParameterContainerType
 
typedef std::vector< NetlistPort * > PortContainerType
 
typedef std::vector< NetlistPortGroup * > PortGroupContainerType
 
- Protected Member Functions inherited from ProGe::BaseNetlistBlock
Netlistnetlist ()
 
virtual NetlistPortport (size_t index)
 
virtual BaseNetlistBlocksubBlock (size_t index)
 
virtual BaseNetlistBlockparentBlock ()
 
void setModuleName (const std::string &name)
 
void addSubBlock (BaseNetlistBlock *subBlock, const std::string &instanceName="")
 
void deleteSubBlock (BaseNetlistBlock *subBlock)
 
void removeSubBlock (BaseNetlistBlock *subBlock)
 
NetlistPortaddPort (NetlistPort *port)
 
void removePort (NetlistPort *port)
 
void addPortGroup (NetlistPortGroup *portGroup)
 
void removePortGroup (NetlistPortGroup *portGroup)
 
void setParameter (const Parameter &param)
 
void addParameter (const Parameter &param)
 
Parameterparameter (const std::string &name)
 
NetlistPortfindPort (const std::string &portName, bool recursiveSearch=false, bool partialMatch=true) const
 
void addPackage (const std::string &packageName)
 
void connectClocks ()
 
void connectResets ()
 

Detailed Description

Definition at line 51 of file ProcessorWrapperBlock.hh.

Constructor & Destructor Documentation

◆ ProcessorWrapperBlock() [1/2]

ProGe::ProcessorWrapperBlock::ProcessorWrapperBlock ( )
delete

◆ ProcessorWrapperBlock() [2/2]

ProGe::ProcessorWrapperBlock::ProcessorWrapperBlock ( const ProGeContext context,
const BaseNetlistBlock processorBlock 
)

Definition at line 53 of file ProcessorWrapperBlock.cc.

55  : BaseNetlistBlock("proc", ""),
56  context_(context),
57  coreBlock_(processorBlock.shallowCopy()) {
58  assert(processorBlock.portCount() > 0);
59  assert(coreBlock_->portCount() > 0);
60 
61  // Wrapper interface //
64  NetlistPort* coreLocked = new OutPort("locked", "1");
65  addPort(coreLocked);
66 
67  // Instantiate core //
69 
70  // Memory instantiations and connections //
71  for (size_t i = 0; i < coreBlock_->portGroupCount(); i++) {
72  const NetlistPortGroup& portGrp = coreBlock_->portGroup(i);
73  SignalGroupType type = portGrp.assignedSignalGroup().type();
75  addInstructionMemory(portGrp);
76  } else if (type == SignalGroupType::BITMASKED_SRAM_PORT) {
77  auto dmemIf = dynamic_cast<const MemoryBusInterface*>(&portGrp);
78  assert(dmemIf != nullptr);
79  addDataMemory(*dmemIf);
80  } else if (type == SignalGroupType::BYTEMASKED_SRAM_PORT) {
81  auto dmemIf = dynamic_cast<const MemoryBusInterface*>(&portGrp);
82  assert(dmemIf != nullptr);
83  addDataMemory2(*dmemIf);
84  }
85  }
86 
87  connectClocks();
88  connectResets();
89  connectLockStatus(*coreLocked);
90 
91  // Package holding instruction bus constants
92  std::set<std::string> procPackages{context.globalPackage().name()};
93 
94  // Other packages possibly holding constants used in core ports.
95  for (size_t i = 0; i < processorBlock.packageCount(); i++) {
96  procPackages.insert(processorBlock.package(i));
97  }
98 
99  for (auto packageStr : procPackages) {
100  addPackage(packageStr);
101  }
102 
103  addPackage(context.coreEntityName() + "_params");
104 
105  // Handle unknown ports
107 }

References addDataMemory(), addDataMemory2(), addInstructionMemory(), ProGe::BaseNetlistBlock::addPackage(), ProGe::BaseNetlistBlock::addPort(), ProGe::BaseNetlistBlock::addSubBlock(), assert, ProGe::NetlistPortGroup::assignedSignalGroup(), ProGe::BITMASKED_SRAM_PORT, ProGe::BYTEMASKED_SRAM_PORT, ProGe::PortFactory::clockPort(), ProGe::BaseNetlistBlock::connectClocks(), connectLockStatus(), ProGe::BaseNetlistBlock::connectResets(), coreBlock_, ProGe::ProGeContext::coreEntityName(), ProGe::ProGeContext::globalPackage(), handleUnconnectedPorts(), ProGe::INSTRUCTION_LINE, ProGe::GlobalPackage::name(), ProGe::BaseNetlistBlock::package(), ProGe::BaseNetlistBlock::packageCount(), ProGe::BaseNetlistBlock::portCount(), ProGe::BaseNetlistBlock::portGroup(), ProGe::BaseNetlistBlock::portGroupCount(), ProGe::PortFactory::resetPort(), and ProGe::SignalGroup::type().

Here is the call graph for this function:

◆ ~ProcessorWrapperBlock()

ProGe::ProcessorWrapperBlock::~ProcessorWrapperBlock ( )
virtual

Definition at line 109 of file ProcessorWrapperBlock.cc.

109 {}

Member Function Documentation

◆ addDataMemory()

void ProGe::ProcessorWrapperBlock::addDataMemory ( const MemoryBusInterface coreDmemPort)
private

Definition at line 178 of file ProcessorWrapperBlock.cc.

178  {
179  using SigT = SignalType;
180 
181  const NetlistPort& addrPort = coreDmemPort.portBySignal(SigT::ADDRESS);
182  const NetlistPort& dataPort = coreDmemPort.portBySignal(SigT::WRITE_DATA);
183 
184  SinglePortSSRAMBlock* dmemBlock = new SinglePortSSRAMBlock(
185  addrPort.widthFormula(), dataPort.widthFormula(),
186  TCEString("tb/dmem_") + coreDmemPort.addressSpace() + "_init.img",
187  /* isForSmulation = */ true);
188  addSubBlock(dmemBlock, TCEString("dmem_") + coreDmemPort.addressSpace());
189 
190  if (!netlist().connect(dmemBlock->memoryPort(), coreDmemPort)) {
193  "Could not connect two port groups together.");
194  }
195 }

References ProGe::MemoryBusInterface::addressSpace(), ProGe::SinglePortSSRAMBlock::memoryPort(), ProGe::NetlistPortGroup::portBySignal(), THROW_EXCEPTION, and ProGe::NetlistPort::widthFormula().

Referenced by ProcessorWrapperBlock().

Here is the call graph for this function:

◆ addDataMemory2()

void ProGe::ProcessorWrapperBlock::addDataMemory2 ( const MemoryBusInterface coreDmemPort)
private

Definition at line 198 of file ProcessorWrapperBlock.cc.

199  {
200  using SigT = SignalType;
201 
202  const NetlistPort& addrPort = coreDmemPort.portBySignal(SigT::AADDR);
203  const NetlistPort& dataPort = coreDmemPort.portBySignal(SigT::RDATA);
204 
205  SinglePortByteMaskSSRAMBlock* dmemBlock =
206  new SinglePortByteMaskSSRAMBlock(
207  addrPort.widthFormula(), dataPort.widthFormula(),
208  TCEString("tb/dmem_") + coreDmemPort.addressSpace() + "_init.img",
209  /* isForSmulation = */ true);
210  addSubBlock(dmemBlock, TCEString("dmem_") + coreDmemPort.addressSpace());
211 
212  if (!netlist().connect(dmemBlock->memoryPort(), coreDmemPort)) {
215  "Could not connect two port groups together.");
216  }
217 }

References ProGe::MemoryBusInterface::addressSpace(), ProGe::SinglePortByteMaskSSRAMBlock::memoryPort(), ProGe::NetlistPortGroup::portBySignal(), THROW_EXCEPTION, and ProGe::NetlistPort::widthFormula().

Referenced by ProcessorWrapperBlock().

Here is the call graph for this function:

◆ addInstructionMemory()

void ProGe::ProcessorWrapperBlock::addInstructionMemory ( const NetlistPortGroup coreImemPort)
private

Definition at line 119 of file ProcessorWrapperBlock.cc.

120  {
121  using SigT = SignalType;
122  bool isRISCV = context_.adf().isRISCVMachine();
123 
124  const int imemWidthInMaus = (context_.adf().isRISCVMachine()) ? 4 : 1;
125  const int unusedBits = std::ceil(std::log2(imemWidthInMaus));
126 
127  std::string addrWidth = context_.globalPackage().fetchBlockAddressWidth();
128  if (isRISCV) {
129  const int unusedBits = std::ceil(std::log2(imemWidthInMaus));
130  addrWidth = context_.globalPackage().fetchBlockAddressWidth() + "-" +
131  std::to_string(unusedBits);
132  }
133 
134  SinglePortSSRAMBlock* imemBlock = new SinglePortSSRAMBlock(
136  "tb/imem_init.img", true);
137  addSubBlock(imemBlock, "imem0");
138  // todo: use core id instead of counter value.
139  std::string accessTrace = std::string("core") +
141  "_imem_access_trace.dump";
142  imemBlock->setAccessTraceFile(accessTrace);
143 
144  if (isRISCV) {
145  // With RISC-V the two lower bits are unused
146  const int realAddrWidth = MathTools::requiredBits(
148  netlist().connect(
149  imemBlock->memoryPort(), coreImemPort,
150  {{SigT::READ_DATA, SigT::FETCHBLOCK},
151  {SigT::READ_WRITE_REQUEST, SigT::READ_REQUEST}});
152  netlist().connect(
153  imemBlock->memoryPort().portBySignal(SigT::ADDRESS),
154  coreImemPort.portBySignal(SigT::ADDRESS), 0, unusedBits,
155  realAddrWidth - unusedBits);
156  } else {
157  netlist().connect(
158  imemBlock->memoryPort(), coreImemPort,
159  {{SigT::ADDRESS, SigT::ADDRESS},
160  {SigT::READ_DATA, SigT::FETCHBLOCK},
161  {SigT::READ_WRITE_REQUEST, SigT::READ_REQUEST}});
162  }
163 
164  imemBlock->memoryPort()
165  .portBySignal(SigT::WRITE_BITMASK)
166  .setToStatic(StaticSignal::VCC);
167  imemBlock->memoryPort()
168  .portBySignal(SigT::WRITEMODE)
169  .setToStatic(StaticSignal::VCC);
170  imemBlock->memoryPort()
171  .portBySignal(SigT::WRITE_DATA)
172  .setToStatic(StaticSignal::GND);
173  coreImemPort.portBySignal(SigT::READ_REQUEST_READY)
174  .setToStatic(StaticSignal::GND); // Active low
175 }

References TTAMachine::FunctionUnit::addressSpace(), ProGe::BaseNetlistBlock::addSubBlock(), ProGe::ProGeContext::adf(), ProGe::Netlist::connect(), context_, TTAMachine::Machine::controlUnit(), TTAMachine::AddressSpace::end(), ProGe::GlobalPackage::fetchBlockAddressWidth(), ProGe::GlobalPackage::fetchBlockDataWidth(), ProGe::ProGeContext::globalPackage(), imemCount_, TTAMachine::Machine::isRISCVMachine(), ProGe::SinglePortSSRAMBlock::memoryPort(), ProGe::BaseNetlistBlock::netlist(), ProGe::NetlistPortGroup::portBySignal(), MathTools::requiredBits(), ProGe::SinglePortSSRAMBlock::setAccessTraceFile(), and Conversion::toString().

Referenced by ProcessorWrapperBlock().

Here is the call graph for this function:

◆ connectLockStatus()

void ProGe::ProcessorWrapperBlock::connectLockStatus ( const NetlistPort topPCInitPort)
private

Definition at line 220 of file ProcessorWrapperBlock.cc.

221  {
222  assert(
223  coreBlock_->port("locked") != nullptr &&
224  "Could not found lock status port.");
225  if (!netlist().connect(*coreBlock_->port("locked"), topLockStatusPort)) {
228  "Could not connect \"locked\" signal to the toplevel");
229  }
230 }

References assert, and THROW_EXCEPTION.

Referenced by ProcessorWrapperBlock().

◆ connectPCInit()

void ProGe::ProcessorWrapperBlock::connectPCInit ( const NetlistPort topPCInitPort)
private

◆ handleUnconnectedPorts()

void ProGe::ProcessorWrapperBlock::handleUnconnectedPorts ( )
private

Handles unconnected ports of the top-level TTA processor by connecting them to the toplevel

Definition at line 237 of file ProcessorWrapperBlock.cc.

237  {
238  for (size_t i = 0; i < coreBlock_->portCount(); i++) {
239  const NetlistPort& port =
240  ((const BaseNetlistBlock*)coreBlock_)->port(i);
242  NetlistPort* topPort = port.clone();
243  addPort(topPort);
244  netlist().connect(*topPort, port);
245  }
246  }
247 }

References ProGe::NetlistPort::clone(), and ProGe::NetlistPort::hasStaticValue().

Referenced by ProcessorWrapperBlock().

Here is the call graph for this function:

◆ write()

void ProGe::ProcessorWrapperBlock::write ( const Path targetBaseDir,
HDL  targetLang = VHDL 
) const
overridevirtual

Does nothing on self but calls write function on each sub block.

Reimplemented from ProGe::BaseNetlistBlock.

Definition at line 112 of file ProcessorWrapperBlock.cc.

113  {
114  BaseNetlistBlock::writeSelf(targetBaseDir / "tb", targetLang);
115  BaseNetlistBlock::write(targetBaseDir, targetLang);
116 }

References ProGe::BaseNetlistBlock::write(), and ProGe::BaseNetlistBlock::writeSelf().

Referenced by ProGe::TestBenchBlock::write().

Here is the call graph for this function:

Member Data Documentation

◆ context_

const ProGeContext& ProGe::ProcessorWrapperBlock::context_
private

Definition at line 74 of file ProcessorWrapperBlock.hh.

Referenced by addInstructionMemory().

◆ coreBlock_

BaseNetlistBlock* ProGe::ProcessorWrapperBlock::coreBlock_
private

The target TTA processor.

Definition at line 76 of file ProcessorWrapperBlock.hh.

Referenced by ProcessorWrapperBlock().

◆ imemCount_

unsigned ProGe::ProcessorWrapperBlock::imemCount_ = 0
private

Definition at line 77 of file ProcessorWrapperBlock.hh.

Referenced by addInstructionMemory().


The documentation for this class was generated from the following files:
ProGe::BaseNetlistBlock::addPort
NetlistPort * addPort(NetlistPort *port)
Definition: BaseNetlistBlock.cc:467
ProGe::StaticSignal::GND
@ GND
All port signals set to low.
Definition: NetlistPort.hh:50
ProGe::BaseNetlistBlock::addSubBlock
void addSubBlock(BaseNetlistBlock *subBlock, const std::string &instanceName="")
Definition: BaseNetlistBlock.cc:405
ProGe::GlobalPackage::fetchBlockDataWidth
const std::string fetchBlockDataWidth() const
Definition: GlobalPackage.cc:65
ProGe::BaseNetlistBlock::NetlistPortGroup
friend class NetlistPortGroup
Definition: BaseNetlistBlock.hh:62
ProGe::ProcessorWrapperBlock::context_
const ProGeContext & context_
Definition: ProcessorWrapperBlock.hh:74
ProGe::SignalGroupType::BYTEMASKED_SRAM_PORT
@ BYTEMASKED_SRAM_PORT
Signal group type for one port SRAM having read and write capability and bitmask for writing with sep...
ProGe::ProcessorWrapperBlock::connectLockStatus
void connectLockStatus(const NetlistPort &topPCInitPort)
Definition: ProcessorWrapperBlock.cc:220
ProGe::BaseNetlistBlock::writeSelf
virtual void writeSelf(const Path &targetBaseDir, HDL targetLang=VHDL) const
Definition: BaseNetlistBlock.cc:625
TTAMachine::Machine::isRISCVMachine
bool isRISCVMachine() const
Definition: Machine.cc:1063
ProGe::ProGeContext::adf
const TTAMachine::Machine & adf() const
Definition: ProGeContext.cc:57
ProGe::PortFactory::resetPort
static NetlistPort * resetPort(Direction direction=IN)
Definition: NetlistFactories.cc:209
ProGe::Netlist::isPortConnected
bool isPortConnected(const NetlistPort &port) const
Definition: Netlist.cc:273
ProGe::ProcessorWrapperBlock::addInstructionMemory
void addInstructionMemory(const NetlistPortGroup &)
Definition: ProcessorWrapperBlock.cc:119
ProGe::BaseNetlistBlock::connectClocks
void connectClocks()
Definition: BaseNetlistBlock.cc:722
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
ProGe::ProcessorWrapperBlock::coreBlock_
BaseNetlistBlock * coreBlock_
The target TTA processor.
Definition: ProcessorWrapperBlock.hh:76
ProGe::StaticSignal::VCC
@ VCC
All port signals set to high.
Definition: NetlistPort.hh:51
ProGe::BaseNetlistBlock::connect
virtual void connect() override
Definition: BaseNetlistBlock.cc:605
ProGe::BaseNetlistBlock::netlist
virtual const Netlist & netlist() const
Definition: BaseNetlistBlock.cc:348
ProGe::ProcessorWrapperBlock::addDataMemory2
void addDataMemory2(const MemoryBusInterface &)
Definition: ProcessorWrapperBlock.cc:198
Conversion::toString
static std::string toString(const T &source)
ProGe::Netlist::connect
bool connect(const NetlistPort &port1, const NetlistPort &port2, int port1FirstBit, int port2FirstBit, int width=1)
Definition: Netlist.cc:83
ProGe::SignalGroupType::INSTRUCTION_LINE
@ INSTRUCTION_LINE
Signal group type for serial TTA instruction bus.
ProGe::BaseNetlistBlock::portGroupCount
virtual size_t portGroupCount() const
Definition: BaseNetlistBlock.cc:327
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
THROW_EXCEPTION
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition: Exception.hh:39
ProGe::BaseNetlistBlock::portCount
virtual size_t portCount() const
Definition: BaseNetlistBlock.cc:248
ProGe::BaseNetlistBlock::BaseNetlistBlock
BaseNetlistBlock()
Definition: BaseNetlistBlock.cc:53
ProGe::BaseNetlistBlock::addPackage
void addPackage(const std::string &packageName)
Definition: BaseNetlistBlock.cc:687
ProGe::ProGeContext::globalPackage
const GlobalPackage & globalPackage() const
Definition: ProGeContext.cc:87
ProGe::ProcessorWrapperBlock::addDataMemory
void addDataMemory(const MemoryBusInterface &)
Definition: ProcessorWrapperBlock.cc:178
ProGe::ProcessorWrapperBlock::imemCount_
unsigned imemCount_
Definition: ProcessorWrapperBlock.hh:77
MathTools::requiredBits
static int requiredBits(unsigned long int number)
ProGe::BaseNetlistBlock::portGroup
virtual const NetlistPortGroup & portGroup(size_t index) const
Definition: BaseNetlistBlock.cc:332
ProGe::SignalGroupType::BITMASKED_SRAM_PORT
@ BITMASKED_SRAM_PORT
Signal group type for one port SRAM having read and write capability and bitmask for writing.
ProGe::NetlistPort::clone
virtual NetlistPort * clone(bool asMirrored=false) const
Definition: NetlistPort.cc:258
ProGe::PortFactory::clockPort
static NetlistPort * clockPort(Direction direction=IN)
Definition: NetlistFactories.cc:200
ProGe::SignalType
SignalType
Definition: SignalTypes.hh:42
ProGe::BaseNetlistBlock::connectResets
void connectResets()
Definition: BaseNetlistBlock.cc:743
ProGe::GlobalPackage::fetchBlockAddressWidth
const std::string fetchBlockAddressWidth() const
Definition: GlobalPackage.cc:56
ProGe::ProcessorWrapperBlock::handleUnconnectedPorts
void handleUnconnectedPorts()
Definition: ProcessorWrapperBlock.cc:237
ProGe::NetlistPort::hasStaticValue
bool hasStaticValue() const
Definition: NetlistPort.cc:423
TCEString
Definition: TCEString.hh:53
IllegalConnectivity
Definition: Exception.hh:473
ProGe::SignalGroupType
SignalGroupType
Definition: SignalGroupTypes.hh:43
TTAMachine::AddressSpace::end
virtual ULongWord end() const
Definition: AddressSpace.cc:177
ProGe::BaseNetlistBlock::NetlistPort
friend class NetlistPort
Definition: BaseNetlistBlock.hh:61
ProGe::BaseNetlistBlock::port
virtual const NetlistPort & port(size_t index) const
Definition: BaseNetlistBlock.cc:253
ProGe::BaseNetlistBlock::write
virtual void write(const Path &targetBaseDir, HDL targetLang=VHDL) const override
Definition: BaseNetlistBlock.cc:614