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

#include <TestBenchBlock.hh>

Inheritance diagram for ProGe::TestBenchBlock:
Inheritance graph
Collaboration diagram for ProGe::TestBenchBlock:
Collaboration graph

Public Member Functions

 TestBenchBlock ()=delete
 
 TestBenchBlock (const ProGeContext &context, const BaseNetlistBlock &coreBlock)
 
virtual ~TestBenchBlock ()
 
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 Attributes

const ProGeContextcontext_
 The ProGe context for additional information. More...
 
ProcessorWrapperBlockproc_
 The block that wraps the processor and instantiates memories for the GCU and LSUs. More...
 

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 50 of file TestBenchBlock.hh.

Constructor & Destructor Documentation

◆ TestBenchBlock() [1/2]

ProGe::TestBenchBlock::TestBenchBlock ( )
delete

◆ TestBenchBlock() [2/2]

ProGe::TestBenchBlock::TestBenchBlock ( const ProGeContext context,
const BaseNetlistBlock coreBlock 
)

Construct The test bench for the core TTA processor.

The test bench creation is limited to TTAs with one address space for instruction and address spaces for data shared by one LSU at most.

Parameters
contextThe context for deriving necessary information about the core.
coreBlockThe DUT for test bench
Exceptions
Thrownif the test bench can not be created.

Definition at line 59 of file TestBenchBlock.cc.

61  : BaseNetlistBlock("testbench", ""), context_(context), proc_(nullptr) {
62  using namespace TTAMachine;
63 
64  std::map<std::string, unsigned> ASUserCounts;
65  std::map<std::string, unsigned> lockFUCounts;
66 
67  for (auto fu : MachineInfo::findLockUnits(context.adf())) {
68  if (fu->hasAddressSpace()) {
69  lockFUCounts[fu->addressSpace()->name()]++;
70  }
71  }
72 
73  for (auto fu : context.adf().functionUnitNavigator()) {
74  if (fu->hasAddressSpace()) {
75  ASUserCounts[fu->addressSpace()->name()]++;
76  }
77  }
78 
79  for (auto asUserCount : ASUserCounts) {
80  unsigned LSUCount(asUserCount.second);
81 
82  if (lockFUCounts.count(asUserCount.first) > 0) {
83  LSUCount -= lockFUCounts[asUserCount.first];
84  }
85 
86  if (LSUCount > 1) {
88  "Can not create test bench for TTA address spaces shared by "
89  "multiple LSUs.");
90  }
91  }
92  try {
93  proc_ = new ProcessorWrapperBlock(context, coreBlock);
94  } catch (Exception& e) {
96  }
97 }

References ProGe::ProGeContext::adf(), Exception::errorMessage(), MachineInfo::findLockUnits(), TTAMachine::Machine::functionUnitNavigator(), proc_, and THROW_EXCEPTION.

Here is the call graph for this function:

◆ ~TestBenchBlock()

ProGe::TestBenchBlock::~TestBenchBlock ( )
virtual

Definition at line 99 of file TestBenchBlock.cc.

99  {
100 }

Member Function Documentation

◆ write()

void ProGe::TestBenchBlock::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 103 of file TestBenchBlock.cc.

103  {
104  // Check language compatibility //
105  if (targetLang != VHDL) {
106  THROW_EXCEPTION(NotAvailable, "Only VHDL is supported.");
107  }
108 
110 
111  instantiator.replacePlaceholder("dut-entity", proc_->moduleName());
112 
113  if (context_.idf().icDecoderParameterValue("debugger") == "external") {
114  instantiator.replacePlaceholder("proc-entity-db-signals",
115  "db_pc_start : in std_logic_vector(IMEMADDRWIDTH-1 downto 0);\n"
116  "db_tta_nreset : in std_logic;\n"
117  "db_lockrq : in std_logic;");
118 
119  instantiator.replacePlaceholder("proc-instance-db-signals",
120  "db_pc_start => (others => '0'),\n"
121  "db_tta_nreset => '1',\n"
122  "db_lockrq => '0',");
123  }
124 
125  FileSystem::createDirectory(targetBaseDir/"tb");
126 
127  Path progeDataDir(Environment::dataDirPath("ProGe"));
128  instantiator.instantiateTemplateFile(
129  progeDataDir/"tb"/"testbench.vhdl.tmpl",
130  targetBaseDir/"tb"/"testbench.vhdl");
131  instantiator.instantiateTemplateFile(
132  progeDataDir/"tb"/"clkgen.vhdl",
133  targetBaseDir/"tb"/"clkgen.vhdl");
134 
135  proc_->write(targetBaseDir, targetLang);
136 }

References context_, ProGe::ProGeContext::coreEntityName(), FileSystem::createDirectory(), Environment::dataDirPath(), IDF::MachineImplementation::icDecoderParameterValue(), ProGe::ProGeContext::idf(), HDLTemplateInstantiator::instantiateTemplateFile(), ProGe::BaseNetlistBlock::moduleName(), proc_, HDLTemplateInstantiator::replacePlaceholder(), THROW_EXCEPTION, ProGe::VHDL, and ProGe::ProcessorWrapperBlock::write().

Referenced by ProGe::ProGeUI::generateTestBench().

Here is the call graph for this function:

Member Data Documentation

◆ context_

const ProGeContext& ProGe::TestBenchBlock::context_
private

The ProGe context for additional information.

Definition at line 63 of file TestBenchBlock.hh.

Referenced by write().

◆ proc_

ProcessorWrapperBlock* ProGe::TestBenchBlock::proc_
private

The block that wraps the processor and instantiates memories for the GCU and LSUs.

Definition at line 66 of file TestBenchBlock.hh.

Referenced by TestBenchBlock(), and write().


The documentation for this class was generated from the following files:
Path
Definition: FileSystem.hh:197
FileSystem::createDirectory
static bool createDirectory(const std::string &path)
Definition: FileSystem.cc:400
HDLTemplateInstantiator
Definition: HDLTemplateInstantiator.hh:45
ProGe::TestBenchBlock::context_
const ProGeContext & context_
The ProGe context for additional information.
Definition: TestBenchBlock.hh:63
MachineInfo::findLockUnits
static std::vector< const TTAMachine::FunctionUnit * > findLockUnits(const TTAMachine::Machine &machine)
Definition: MachineInfo.cc:759
NotAvailable
Definition: Exception.hh:728
IDF::MachineImplementation::icDecoderParameterValue
std::string icDecoderParameterValue(const std::string &name) const
Definition: MachineImplementation.cc:1415
ProGe::VHDL
@ VHDL
VHDL.
Definition: ProGeTypes.hh:41
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::BaseNetlistBlock
BaseNetlistBlock()
Definition: BaseNetlistBlock.cc:53
ProGe::ProGeContext::idf
const IDF::MachineImplementation & idf() const
Definition: ProGeContext.cc:62
Exception
Definition: Exception.hh:54
ProGe::ProGeContext::coreEntityName
const std::string & coreEntityName() const
Definition: ProGeContext.cc:77
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
ProGe::TestBenchBlock::proc_
ProcessorWrapperBlock * proc_
The block that wraps the processor and instantiates memories for the GCU and LSUs.
Definition: TestBenchBlock.hh:66
ProGe::ProcessorWrapperBlock::write
virtual void write(const Path &targetBaseDir, HDL targetLang=VHDL) const override
Definition: ProcessorWrapperBlock.cc:112
ProGe::BaseNetlistBlock::moduleName
const std::string & moduleName() const
Definition: BaseNetlistBlock.cc:140
TTAMachine
Definition: Assembler.hh:48
Environment::dataDirPath
static std::string dataDirPath(const std::string &prog)
Definition: Environment.cc:176