OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
QuartusProjectGenerator Class Reference

#include <QuartusProjectGenerator.hh>

Inheritance diagram for QuartusProjectGenerator:
Inheritance graph
Collaboration diagram for QuartusProjectGenerator:
Collaboration graph

Public Member Functions

 QuartusProjectGenerator (TCEString toplevelEntity, const PlatformIntegrator *integrator)
 
virtual ~QuartusProjectGenerator ()
 
virtual void writeProjectFiles ()
 
- Public Member Functions inherited from ProjectFileGenerator
 ProjectFileGenerator (TCEString coreEntity, const PlatformIntegrator *integrator)
 
virtual ~ProjectFileGenerator ()
 
void addHdlFile (const TCEString &file)
 
void addHdlFiles (const std::vector< TCEString > &files)
 
void addMemInitFile (const TCEString &memInit)
 
void addSignalMapping (const PlatInt::SignalMapping &mapping)
 

Private Member Functions

void writeQPFFile ()
 
void writeQSFFile ()
 
void writeScripts ()
 

Additional Inherited Members

- Protected Member Functions inherited from ProjectFileGenerator
const std::vector< TCEString > & hdlFileList () const
 
const std::vector< TCEString > & memInitFileList () const
 
const PlatformIntegratorintegrator () const
 
TCEString coreEntity () const
 
TCEString toplevelEntity () const
 
int signalMappingCount () const
 
const PlatInt::SignalMappingsignalMapping (int index) const
 
TCEString extractFUName (const TCEString &port, const TCEString &delimiter) const
 

Detailed Description

Definition at line 41 of file QuartusProjectGenerator.hh.

Constructor & Destructor Documentation

◆ QuartusProjectGenerator()

QuartusProjectGenerator::QuartusProjectGenerator ( TCEString  toplevelEntity,
const PlatformIntegrator integrator 
)

Definition at line 46 of file QuartusProjectGenerator.cc.

◆ ~QuartusProjectGenerator()

QuartusProjectGenerator::~QuartusProjectGenerator ( )
virtual

Definition at line 52 of file QuartusProjectGenerator.cc.

52 {
53}

Member Function Documentation

◆ writeProjectFiles()

void QuartusProjectGenerator::writeProjectFiles ( )
virtual

Implements ProjectFileGenerator.

Definition at line 56 of file QuartusProjectGenerator.cc.

References writeQPFFile(), writeQSFFile(), and writeScripts().

Here is the call graph for this function:

◆ writeQPFFile()

void QuartusProjectGenerator::writeQPFFile ( )
private

Definition at line 67 of file QuartusProjectGenerator.cc.

67 {
68
69 TCEString qpfFileName = toplevelEntity() + ".qpf";
70 ofstream qpfFile;
71 qpfFile.open(qpfFileName.c_str());
72 if (!qpfFile) {
73 TCEString msg = "Couldn't open file " + qpfFileName + " for writing";
74 IOException exc(__FILE__, __LINE__, "QuartusProjectGenerator", msg);
75 throw exc;
76 }
77 qpfFile
78 << "# Generated by QuartusProject Generator" << endl << endl
79 << "QUARTUS_VERSION = \"8.0\"" << endl << endl
80 << "PROJECT_REVISION = \"" << toplevelEntity() << "\"" << endl;
81 qpfFile.close();
82}
TCEString toplevelEntity() const

References ProjectFileGenerator::toplevelEntity().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeQSFFile()

void QuartusProjectGenerator::writeQSFFile ( )
private

Definition at line 86 of file QuartusProjectGenerator.cc.

86 {
87
88 TCEString qsfFileName = toplevelEntity() + ".qsf";
89 ofstream qsfFile;
90 qsfFile.open(qsfFileName.c_str());
91 if (!qsfFile) {
92 TCEString msg = "Couldn't open file " + qsfFileName + " for writing";
93 IOException exc(__FILE__, __LINE__, "QuartusProjectGenerator", msg);
94 throw exc;
95 }
96
97 TCEString deviceFamily = integrator()->deviceFamily();
98 TCEString deviceName = integrator()->deviceName();
99 int fmax = integrator()->targetClockFrequency();
100 qsfFile
101 << "# Generated by QuartusProjectGenerator" << endl << endl
102 << "set_global_assignment -name FAMILY \"" << deviceFamily << "\""
103 << endl
104 << "set_global_assignment -name DEVICE " << deviceName << endl
105 << "set_global_assignment -name TOP_LEVEL_ENTITY " << toplevelEntity()
106 << endl
107 << "set_global_assignment -name ORIGINAL_QUARTUS_VERSION 8.0" << endl
108 << "set_global_assignment -name LAST_QUARTUS_VERSION 8.0" << endl
109 << "set_global_assignment -name USE_GENERATED_PHYSICAL_CONSTRAINTS "
110 << "OFF -section_id eda_palace" << endl
111 << "set_global_assignment -name USE_CONFIGURATION_DEVICE ON" << endl
112 << "set_global_assignment -name RESERVE_ALL_UNUSED_PINS \"AS "
113 << "INPUT TRI-STATED\"" << endl
114 << "set_global_assignment -name FMAX_REQUIREMENT \"" << fmax
115 << " MHz\"" << endl;
116
117 for (unsigned int i = 0; i < hdlFileList().size(); i++) {
118 qsfFile << "set_global_assignment -name VHDL_FILE \""
119 << hdlFileList().at(i) << "\"" << endl;
120 }
121
122 for (unsigned int i = 0; i < memInitFileList().size(); i++) {
123 if (StringTools::endsWith(memInitFileList().at(i), ".mif")) {
124 qsfFile << "set_global_assignment -name MIF_FILE \""
125 << memInitFileList().at(i) << "\"" << endl;
126 } else if (StringTools::endsWith(memInitFileList().at(i), ".hex")) {
127 qsfFile << "set_global_assignment -name HEX_FILE \""
128 << memInitFileList().at(i) << "\"" << endl;
129 }
130 }
131
132 for (int i = 0; i < signalMappingCount(); i++) {
133 const SignalMapping* mapping = signalMapping(i);
134 qsfFile << "set_location_assignment " << mapping->first
135 << " -to " << mapping->second << endl;
136 }
137 qsfFile.close();
138}
TCEString deviceName() const
virtual int targetClockFrequency() const
virtual TCEString deviceFamily() const =0
const std::vector< TCEString > & hdlFileList() const
const std::vector< TCEString > & memInitFileList() const
const PlatInt::SignalMapping * signalMapping(int index) const
static bool endsWith(const std::string &source, const std::string &searchString)
std::pair< TCEString, TCEString > SignalMapping

References PlatformIntegrator::deviceFamily(), PlatformIntegrator::deviceName(), StringTools::endsWith(), ProjectFileGenerator::hdlFileList(), ProjectFileGenerator::integrator(), ProjectFileGenerator::memInitFileList(), ProjectFileGenerator::signalMapping(), ProjectFileGenerator::signalMappingCount(), PlatformIntegrator::targetClockFrequency(), and ProjectFileGenerator::toplevelEntity().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeScripts()

void QuartusProjectGenerator::writeScripts ( )
private

Definition at line 142 of file QuartusProjectGenerator.cc.

142 {
143
144 TCEString exportCommand = "";
145 TCEString alteraLibPath =
147 "ALTERA_LIBRARY_PATH");
148
149 if (alteraLibPath != "") {
150 exportCommand << "export LD_LIBRARY_PATH=" << alteraLibPath << "\n";
151 }
152
153
154 TCEString synthesisScript = "quartus_synthesize.sh";
155 ofstream synthesis;
156 synthesis.open(synthesisScript.c_str());
157 if (!synthesis) {
158 TCEString msg =
159 "Couldn't open file " + synthesisScript + " for writing";
160 IOException exc(__FILE__, __LINE__, "QuartusProjectGenerator", msg);
161 throw exc;
162 }
163 synthesis
164 << "#!/bin/bash" << endl
165 << "# Generated by QuartusProjectGenerator of TCE" << endl << endl
166 << exportCommand
167 << "quartus_sh --flow compile " << toplevelEntity() << endl;
168 synthesis.close();
169 FileSystem::setFileExecutable(synthesisScript);
170
171 TCEString programmingScript = "quartus_program_fpga.sh";
172 ofstream programming;
173 programming.open(programmingScript.c_str());
174 if (!programming) {
175 TCEString msg = "Couldn't open file " + programmingScript
176 + " for writing";
177 IOException exc(__FILE__, __LINE__, "QuartusProjectGenerator", msg);
178 throw exc;
179 }
180 programming
181 << "#!/bin/bash" << endl
182 << "# Generated by QuartusProjectGenerator of TCE" << endl << endl
183 << exportCommand
184 << "quartus_pgm -c USB-Blaster -m JTAG -o p\\;"
185 << toplevelEntity() << ".sof" << endl << endl;
186 programming.close();
187 FileSystem::setFileExecutable(programmingScript);
188}
static std::string environmentVariable(const std::string &variable)
static bool setFileExecutable(const std::string fileName)

References Environment::environmentVariable(), FileSystem::setFileExecutable(), and ProjectFileGenerator::toplevelEntity().

Referenced by writeProjectFiles().

Here is the call graph for this function:

The documentation for this class was generated from the following files: