46#include <boost/format.hpp>
86 for (
unsigned int i = 0; i <
dictionary_.size(); i++) {
102 for (
unsigned int i = 0; i <
dictionary_.size(); i++) {
144 stream <<
"Generates the program image using move slot based "
145 <<
"dictionary compression." << endl << endl
146 <<
"Warning! This compressor works correctly only when "
147 <<
"there is one instruction per MAU in the final program "
148 <<
"image. That is, the MAU of the address space should be "
149 <<
"the same as the width of the compressed instructions or "
150 <<
"wider. Otherwise jump and call addresses are invalid in "
151 <<
"the code. This compressor creates the dictionary on the "
152 <<
"move slot level." << endl << endl;
169 string name = iter->first;
184 while (instruction != &NullInstruction::instance()) {
188 unsigned int end = begin;
191 BitVector moveSlot(*instructionBits, begin, end);
195 instruction = &
program.nextInstruction(*instruction);
196 delete instructionBits;
210 unsigned int code =
dictionary_.at(slotIndex)->size();
212 std::pair<BitVector, unsigned int>(instructionBits, code));
222 while (instruction != &NullInstruction::instance()) {
229 static_cast<BitVector*
>(compressedInstruction);
239 unsigned int end = begin;
258 stream <<
"library ieee;" << endl;
259 stream <<
"use ieee.std_logic_1164.all;" << endl;
260 stream <<
"use ieee.std_logic_arith.all;" << endl << endl;
262 TCEString packageName = entityStr +
"_dict_init";
264 stream <<
"package " << packageName <<
" is" << endl << endl;
269 <<
"type std_logic_dict_matrix_" << i
270 <<
" is array (natural range <>) "
272 <<
" downto 0);" << endl << endl;
280 <<
"constant dict_init_slot_" << i
281 <<
" : std_logic_dict_matrix_" << i <<
" := (" << endl;
282 for (
unsigned int j = 0; j <
dictionary_.at(i)->size(); j++) {
290 stream <<
"," << endl;
292 stream <<
");" << endl;
297 unsigned int index = 0;
302 <<
"constant dict_init_slot_" << i
303 <<
" : std_logic_vector("
307 stream <<
"\");" << endl;
311 stream <<
"end " << packageName <<
";" << endl << endl;
316 stream <<
"library ieee;" << endl;
317 stream <<
"use ieee.std_logic_1164.all;" << endl;
318 stream <<
"use ieee.std_logic_arith.all;" << endl;
319 stream <<
"use work." << entityStr <<
"_globals.all;" << endl;
320 stream <<
"use work." << entityStr <<
"_dict_init.all;" << endl;
321 stream <<
"use work." << entityStr <<
"_imem_mau.all;" << endl << endl;
323 stream <<
"entity " << entityStr <<
"_decompressor is" << endl;
325 stream <<
indentation(2) <<
"fetch_en : out std_logic;" << endl;
326 stream <<
indentation(2) <<
"lock : in std_logic;" << endl;
328 <<
"fetchblock : in std_logic_vector("
329 <<
"IMEMWIDTHINMAUS*IMEMMAUWIDTH-1 downto 0);" << endl;
331 <<
"instructionword : out std_logic_vector("
332 <<
"INSTRUCTIONWIDTH-1 downto 0);" << endl;
333 stream <<
indentation(2) <<
"glock : out std_logic;" << endl;
334 stream <<
indentation(2) <<
"lock_r : in std_logic;" << endl;
335 stream <<
indentation(2) <<
"clk : in std_logic;" << endl;
336 stream <<
indentation(2) <<
"rstx : in std_logic);" << endl << endl;
337 stream <<
"end " << entityStr <<
"_decompressor;" << endl << endl;
341 std::ostream& stream,
TCEString entityStr) {
342 stream <<
"architecture move_slot_dict of " << entityStr
343 <<
"_decompressor is" << endl << endl;
345 bool haveLimm =
false;
350 stream <<
"end move_slot_dict;" << endl;
358 <<
"subtype dict_index_"<< i
359 <<
" is integer range 0 to "
360 <<
"dict_init_slot_" << i
361 <<
"'length-1;" << endl;
363 <<
"signal dict_line_"
364 << i <<
" : dict_index_" << i <<
";" << endl;
366 <<
"constant dict_" << i
367 <<
" : std_logic_dict_matrix_"
368 << i <<
"(0 to dict_init_slot_" << i
369 <<
"'length-1) := dict_init_slot_"
370 << i <<
";" << endl << endl;
373 <<
"constant dict_" << i
374 <<
" : std_logic_vector("
376 <<
"-1 downto 0) := dict_init_slot_"
377 << i <<
";" << endl << endl;
381 int limmEndIndex = 0;
386 <<
"signal limm_field : std_logic_vector("
387 << limmEndIndex <<
"-1 downto 0);" << endl << endl;
392 stream <<
indentation(1) <<
"begin" << endl << endl;
393 stream <<
indentation(1) <<
"glock <= lock;" << endl;
394 stream <<
indentation(1) <<
"fetch_en <= not lock_r;" << endl << endl;
400 <<
"limm_field <= fetchblock(fetchblock'length-1 downto "
401 <<
"fetchblock'length-" << limmEndIndex <<
");" << endl
405 vector<pair<int,int> > moveSlotBoundaries;
412 <<
" <= conv_integer(unsigned(fetchblock("
413 <<
"fetchblock'length-"
414 << moveSlotBoundaries.at(i).first
415 <<
" downto fetchblock'length-"
416 << moveSlotBoundaries.at(i).second
417 <<
")));" << endl << endl;
427 if (boundaries.size() == 0) {
431 temp = boundaries.at(boundaries.size()-1).second;
433 int begin = temp + 1;
435 boundaries.push_back(std::make_pair(begin,end));
442 stream <<
"limm_field, ";
446 stream <<
"dict_line_" << i;
453 stream <<
")" << endl
457 stream <<
"limm_field&";
461 stream <<
"dict_" << i <<
"(dict_line_" << i <<
")";
463 stream <<
"dict_" << i;
469 stream <<
";" << endl
470 <<
indentation(1) <<
"end process;" << endl << endl;
474 int widthInBytes =
static_cast<int>(
478 << widthInBytes <<
" bytes)" << endl;
479 std::size_t totalSize = 0;
480 for (
unsigned int i = 0; i <
dictionary_.size(); i++) {
481 std::size_t index =
static_cast<std::size_t
>(i);
482 std::size_t keyWidth =
486 totalSize += entries * entrySize;
490 "dictionary width: %d bits, entries: %d, "
491 "dictionary size: %d bits (%d bytes)\n")
492 % index % keyWidth % entries % (entries * entrySize)
494 std::ceil(entries * entrySize / 8.0))).str();
498 "Total dictionary size: %d bits (%d bytes)\n\n")
500 % std::size_t(std::ceil(totalSize / 8.0))).str();
#define EXPORT_CODE_COMPRESSOR(PLUGIN_NAME__)
find Finds info of the inner loops in the program
find Finds info of the inner loops in the false
static int verboseLevel()
static std::ostream & logStream()
virtual void writeImage(std::ostream &stream) const
virtual int width(const TCEString &templateName) const
void pushBack(long long unsigned int integer, int size)
InstructionBitVector * bemBits(const TTAProgram::Program &program)
void setImemWidth(int mau, int widthInMaus=1)
TPEFMap::const_iterator programElement(int index) const
void startNewProgram(const std::string &programName)
int moveSlotWidth(int index) const
std::string indentation(int level)
void addInstruction(const TTAProgram::Instruction &instruction, InstructionBitVector *bits)
TTAProgram::Program & currentProgram() const
const BinaryEncoding & binaryEncoding() const
int firstMoveSlotIndex() const
int numberOfPrograms() const
InstructionBitVector * bemInstructionBits(const TTAProgram::Instruction &)
InstructionBitVector * programBits() const
void setAllInstructionsToStartAtBeginningOfMAU()
int moveSlotCount() const
virtual void printDescription(std::ostream &stream)
void generateDecompressorSignals(std::ostream &stream, bool &haveLimm)
void generateDecompressorArchitecture(std::ostream &stream, TCEString entityStr)
void evaluateMoveSlotBoundaries(vector< pair< int, int > > &boundaries)
void updateDictionary(const Program &program)
virtual void generateDecompressor(std::ostream &stream, TCEString entityStr)
unsigned int compressedWidth_
Total width of compressed instruction (limm fields + move slots)
vector< Dictionary * > dictionary_
The dictionary.
void addToDictionary(const BitVector &instructionBits, int slotIndex)
void generateDecompressorProcess(std::ostream &stream, bool &haveLimm)
void generateDecompressorEntity(std::ostream &stream, TCEString entityStr)
void generateDictionaryVhdl(std::ostream &stream, TCEString entityStr)
bool dictionaryCreated_
Indicates whether the dictionary has been created.
std::map< BitVector, unsigned int > Dictionary
Map type for dictionary.
void generateDecompressorBody(std::ostream &stream, bool &haveLimm)
virtual InstructionBitVector * compress(const string &programName)
Instruction & nextInstruction(const Instruction &) const
Instruction & firstInstruction() const