OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
VhdlRomGenerator Class Reference

#include <VhdlRomGenerator.hh>

Inheritance diagram for VhdlRomGenerator:
Inheritance graph
Collaboration diagram for VhdlRomGenerator:
Collaboration graph

Public Member Functions

 VhdlRomGenerator (int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
 
virtual ~VhdlRomGenerator ()
 
virtual bool generatesComponentHdlFile () const
 
virtual std::vector< TCEStringgenerateComponentFile (TCEString outputPath)
 
- Public Member Functions inherited from MemoryGenerator
 MemoryGenerator (int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
 
virtual ~MemoryGenerator ()
 
virtual bool isCompatible (const ProGe::NetlistBlock &ttaCore, int coreId, std::vector< TCEString > &reasons) const
 
virtual void addMemory (const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
 
int memoryTotalWidth () const
 
int memoryMauSize () const
 
int memoryWidthInMaus () const
 
int memoryAddrWidth () const
 
TCEString initializationFile () const
 
void addLsu (TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
 

Protected Member Functions

virtual TCEString moduleName () const
 
virtual TCEString instanceName (int coreId, int memIndex) const
 
- Protected Member Functions inherited from MemoryGenerator
virtual bool checkFuPort (const std::string fuPort, std::vector< TCEString > &reasons) const
 
virtual void connectPorts (ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
 
virtual MemoryGenerator::BlockPair createMemoryNetlistBlock (ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
 
const PlatformIntegratorplatformIntegrator () const
 
std::ostream & warningStream ()
 
std::ostream & errorStream ()
 
int portCount () const
 
const HDLPortport (int index) const
 
const HDLPortportByKeyName (TCEString name) const
 
TCEString portKeyName (const HDLPort *port) const
 
void addPort (const TCEString &name, HDLPort *port)
 
int parameterCount () const
 
const ProGe::Parameterparameter (int index) const
 
void addParameter (const ProGe::Parameter &add)
 
TCEString ttaCoreName () const
 
TCEString memoryIndexString (int coreId, int memIndex) const
 
TCEString templatePath () const
 
void instantiateTemplate (const TCEString &inFile, const TCEString &outFile, const TCEString &entity) const
 
bool hasLSUArchitecture () const
 
const TTAMachine::FunctionUnitlsuArchitecture () const
 
TCEString corePortName (const TCEString &portBaseName, int coreId) const
 

Private Member Functions

TCEString imagePackageName () const
 

Additional Inherited Members

- Protected Types inherited from MemoryGenerator
typedef std::multimap< TCEString, HDLPort * > PortMap
 
typedef std::pair< ProGe::NetlistBlock *, ProGe::VirtualNetlistBlock * > BlockPair
 

Detailed Description

Definition at line 42 of file VhdlRomGenerator.hh.

Constructor & Destructor Documentation

◆ VhdlRomGenerator()

VhdlRomGenerator::VhdlRomGenerator ( int  memMauWidth,
int  widthInMaus,
int  addrWidth,
TCEString  initFile,
const PlatformIntegrator integrator,
std::ostream &  warningStream,
std::ostream &  errorStream 
)

Definition at line 50 of file VhdlRomGenerator.cc.

57  :
58  MemoryGenerator(memMauWidth, widthInMaus, addrWidth, initFile,
59  integrator, warningStream, errorStream) {
60 
61  addPort("clk", new HDLPort("clock", "1", ProGe::BIT, ProGe::IN, false, 1));
62  addPort("imem_addr", new HDLPort("addr", "addrw", ProGe::BIT_VECTOR,
63  ProGe::IN, false, memoryAddrWidth()));
64 
65  addPort("imem_en_x", new HDLPort("en_x", "1", ProGe::BIT,
66  ProGe::IN, false, 1));
67 
68  addPort("imem_data", new HDLPort("dataout", "instrw", ProGe::BIT_VECTOR,
69  ProGe::OUT, false, memoryTotalWidth()));
70 
71  HDLPort* busyToGnd = new HDLPort("wait", "1", ProGe::BIT, ProGe::OUT,
72  false, 1);
74  addPort("busy", busyToGnd);
75 
76  ProGe::Parameter addr("addrw", "integer", "IMEMADDRWIDTH");
77  ProGe::Parameter data("instrw", "integer", "IMEMMAUWIDTH*IMEMWIDTHINMAUS");
78 
79  addParameter(addr);
80  addParameter(data);
81 }

References MemoryGenerator::addParameter(), MemoryGenerator::addPort(), ProGe::BIT, ProGe::BIT_VECTOR, ProGe::StaticSignal::GND, ProGe::IN, MemoryGenerator::memoryAddrWidth(), MemoryGenerator::memoryTotalWidth(), ProGe::OUT, and HDLPort::setToStatic().

Here is the call graph for this function:

◆ ~VhdlRomGenerator()

VhdlRomGenerator::~VhdlRomGenerator ( )
virtual

Definition at line 83 of file VhdlRomGenerator.cc.

83  {
84 }

Member Function Documentation

◆ generateComponentFile()

std::vector< TCEString > VhdlRomGenerator::generateComponentFile ( TCEString  outputPath)
virtual

Implements MemoryGenerator.

Definition at line 94 of file VhdlRomGenerator.cc.

94  {
95 
96  TCEString outputFile =
98  << ".vhd";
99 
100  std::ofstream file;
101  file.open(outputFile.c_str());
102  if (!file) {
103  TCEString msg = "Couldn't open file " + outputFile + " for writing";
104  IOException exc(__FILE__, __LINE__, "VhdlRomGenerator", msg);
105  throw exc;
106  }
107 
108  TCEString indentL1 = StringTools::indent(1);
109  TCEString indentL2 = StringTools::indent(2);
110  std::ostringstream stream;
111  stream
112  << "library ieee;" << endl
113  << "use ieee.std_logic_1164.all;" << endl
114  << "use ieee.std_logic_arith.all;" << endl
115  << "use work." << imagePackageName() << ".all;" << endl << endl
116  << "entity " << moduleName() << " is" << endl << endl
117  << indentL1 << "generic (" << endl
118  << indentL2 << "addrw : integer := 10;" << endl
119  << indentL2 << "instrw : integer := 100);" << endl
120  << indentL1 << "port (" << endl
121  << indentL2 << "clock : in std_logic;" << endl
122  << indentL2 << "en_x : in std_logic; -- not used" << endl
123  << indentL2 << "addr : in std_logic_vector(addrw-1 downto 0);"
124  << endl << indentL2
125  << "dataout : out std_logic_vector(instrw-1 downto 0));" << endl
126  << "end " << moduleName() << ";" << endl << endl;
127 
128  stream
129  << "architecture rtl of " << moduleName() << " is" << endl << endl
130  << indentL1
131  << "subtype imem_index is integer range 0 to imem_array'length-1;"
132  << endl
133  << indentL1 << "constant imem : std_logic_imem_matrix"
134  << "(0 to imem_array'length-1) := imem_array;" << endl
135  << indentL1 << "signal en_x_dummy : std_logic;" << endl << endl
136  << "begin --rtl" << endl << endl
137  << indentL1 << "process" << endl
138  << indentL2 << "variable imem_line : imem_index;" << endl
139  << indentL1 << "begin -- process" << endl
140  << indentL2 << "wait until clock'event and clock='1';" << endl
141  << indentL2 << "imem_line := conv_integer(unsigned(addr));" << endl
142  << indentL2 << "dataout <= imem(imem_line);" << endl
143  << indentL1 << "end process;" << endl << endl
144  << indentL1 << "en_x_dummy <= en_x; -- dummy connection" << endl
145  << endl << "end rtl;" << endl;
146 
147  file << stream.str();
148  file.close();
149 
150  std::vector<TCEString> componentFiles;
151  componentFiles.push_back(outputFile);
152  componentFiles.push_back(initializationFile());
153  return componentFiles;
154 }

References FileSystem::DIRECTORY_SEPARATOR, imagePackageName(), StringTools::indent(), MemoryGenerator::initializationFile(), and moduleName().

Here is the call graph for this function:

◆ generatesComponentHdlFile()

bool VhdlRomGenerator::generatesComponentHdlFile ( ) const
virtual

Implements MemoryGenerator.

Definition at line 88 of file VhdlRomGenerator.cc.

88  {
89  return true;
90 }

◆ imagePackageName()

TCEString VhdlRomGenerator::imagePackageName ( ) const
private

Definition at line 172 of file VhdlRomGenerator.cc.

172  {
173 
174  return ttaCoreName() + "_imem_image";
175 }

References MemoryGenerator::ttaCoreName().

Referenced by generateComponentFile().

Here is the call graph for this function:

◆ instanceName()

TCEString VhdlRomGenerator::instanceName ( int  coreId,
int  memIndex 
) const
protectedvirtual

Implements MemoryGenerator.

Definition at line 165 of file VhdlRomGenerator.cc.

165  {
166 
167  TCEString iname("imem_array_instance_");
168  return iname << memoryIndexString(coreId, memIndex);
169 }

References MemoryGenerator::memoryIndexString().

Here is the call graph for this function:

◆ moduleName()

TCEString VhdlRomGenerator::moduleName ( ) const
protectedvirtual

Implements MemoryGenerator.

Definition at line 158 of file VhdlRomGenerator.cc.

158  {
159 
160  return ttaCoreName() + "_rom_array_comp";
161 }

References MemoryGenerator::ttaCoreName().

Referenced by generateComponentFile().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
ProGe::StaticSignal::GND
@ GND
All port signals set to low.
Definition: NetlistPort.hh:50
MemoryGenerator::initializationFile
TCEString initializationFile() const
Definition: MemoryGenerator.cc:219
MemoryGenerator::addPort
void addPort(const TCEString &name, HDLPort *port)
Definition: MemoryGenerator.cc:294
HDLPort
Definition: PlatformIntegrator/HDLPort.hh:48
ProGe::BIT_VECTOR
@ BIT_VECTOR
Several bits.
Definition: ProGeTypes.hh:48
MemoryGenerator::ttaCoreName
TCEString ttaCoreName() const
Definition: MemoryGenerator.cc:319
MemoryGenerator::MemoryGenerator
MemoryGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
Definition: MemoryGenerator.cc:59
StringTools::indent
static std::string indent(int level)
Definition: StringTools.cc:319
MemoryGenerator::memoryIndexString
TCEString memoryIndexString(int coreId, int memIndex) const
Definition: MemoryGenerator.cc:383
ProGe::Parameter
Definition: Parameter.hh:62
VhdlRomGenerator::moduleName
virtual TCEString moduleName() const
Definition: VhdlRomGenerator.cc:158
ProGe::BIT
@ BIT
One bit.
Definition: ProGeTypes.hh:47
MemoryGenerator::warningStream
std::ostream & warningStream()
Definition: MemoryGenerator.cc:231
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
ProGe::OUT
@ OUT
Output port.
Definition: ProGeTypes.hh:54
VhdlRomGenerator::imagePackageName
TCEString imagePackageName() const
Definition: VhdlRomGenerator.cc:172
HDLPort::setToStatic
void setToStatic(ProGe::StaticSignal value)
Definition: HDLPort.cc:145
TCEString
Definition: TCEString.hh:53
MemoryGenerator::addParameter
void addParameter(const ProGe::Parameter &add)
Definition: MemoryGenerator.cc:313
MemoryGenerator::errorStream
std::ostream & errorStream()
Definition: MemoryGenerator.cc:237
IOException
Definition: Exception.hh:130
MemoryGenerator::memoryTotalWidth
int memoryTotalWidth() const
Definition: MemoryGenerator.cc:193
MemoryGenerator::memoryAddrWidth
int memoryAddrWidth() const
Definition: MemoryGenerator.cc:212
ProGe::IN
@ IN
Input port.
Definition: ProGeTypes.hh:53