UGRAMM
Loading...
Searching...
No Matches
utilities.h File Reference
#include <boost/config.hpp>
#include <iostream>
#include <fstream>
#include <boost/graph/graph_traits.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/copy.hpp>
#include <queue>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>
Include dependency graph for utilities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VISUAL_SCALE   6.5
 
#define FunCell_Visual_Enable   1
 
#define PinCell_Visual_Enable   1
 
#define RouteCell_Visual_Enable   0
 

Functions

std::string removeCurlyBrackets (const std::string &input)
 
std::string gNames_deliemter_changes (std::string gNames)
 
std::string string_remover (std::string original_string, std::string toRemove)
 
void jsonUppercase (json &j)
 
std::string readCommentSection (std::ifstream &inputFile)
 
bool skipPlacement (std::string hOpcode, json &jsonParsed)
 
bool needLocking (int HID, json &jsonParsed, std::string &jsonLockNode)
 
void readDeviceModelPragma (std::ifstream &deviceModelFile, json &UgrammPragmaConfig)
 
void readApplicationGraphPragma (std::ifstream &applicationGraphFile, json &UgrammPragmaConfig)
 
bool widthCheck (int hWidth, int gWidth)
 Checks if the application graph's node width is less than or equal to the device model's node width.
 
bool compatibilityCheck (int gID, int hID, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
 
void printRoutingResults (int y, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
 
void mandatoryFunCellConnections (int gNumber, std::string FunCellName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile)
 
void printPlacementResults (int gNumber, std::string gName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map< int, NodeConfig > *gConfig, json &ugrammConfig)
 
void printMappedResults (DirectedGraph *H, DirectedGraph *G, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig, json &UgrammPragmaConfig)
 
void printName (int n)
 
void printVertexModels (DirectedGraph *H, DirectedGraph *G, std::map< int, NodeConfig > *hConfig, std::map< int, int > &invUsers)
 
void printRouting (int signal)
 
void readDeviceModel (DirectedGraph *G, std::map< int, NodeConfig > *gConfig)
 
void readApplicationGraph (DirectedGraph *H, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
 

Variables

std::vector< std::string > colors
 
std::string input_pin_color
 
std::string output_pin_color
 
std::string unused_cell_color
 
std::map< std::string, std::string > funCellMapping
 

Macro Definition Documentation

◆ FunCell_Visual_Enable

#define FunCell_Visual_Enable   1

◆ PinCell_Visual_Enable

#define PinCell_Visual_Enable   1

◆ RouteCell_Visual_Enable

#define RouteCell_Visual_Enable   0

◆ VISUAL_SCALE

#define VISUAL_SCALE   6.5

Function Documentation

◆ compatibilityCheck()

bool compatibilityCheck ( int gID,
int hID,
std::map< int, NodeConfig > * hConfig,
std::map< int, NodeConfig > * gConfig )

Checks whether the current opcode required by the application node is supported by the device model node.

This function determines if the opcode needed by the application node (represented by hOpcode) is compatible with or supported by the device model node type (represented by gType).

Parameters
gTypeThe type of the device model node. [ALU, MemPort etc..]
hOpcodeThe opcode required by the application node. [FMUL, FADD, INPUT, OUTPUT]
hConfigA map containing node configuration details of device-model graph.
gConfigA map containing node configuration details of device-model graph.
Returns
bool Returns true if the opcode is supported by the device model node, false otherwise.

◆ gNames_deliemter_changes()

std::string gNames_deliemter_changes ( std::string gNames)

Changes the delimiters in the given string from "." to "_" (neato dot format does not support "." delimiter in the node name)

Parameters
gNamesThe input string to modify.
Returns
A new string with updated delimiters.

Changes the delimiters in the given string from "." to "_" (neato dot format does not support "." delimiter in the node name)

◆ jsonUppercase()

void jsonUppercase ( json & j)

Converts all keys and values of the parsed JSON object to uppercase for normalization.

Parameters
jReference to the JSON object to be normalized.

Converts all keys and values of the parsed JSON object to uppercase for normalization.

◆ mandatoryFunCellConnections()

void mandatoryFunCellConnections ( int gNumber,
std::string FunCellName,
DirectedGraph * G,
std::ofstream & positionedOutputFile,
std::ofstream & unpositionedOutputFile )

Connects associated pins to the specified FunCell in the device model graph.

Parameters
gNumberA boost node id from the device-model graph.
FunCellNameThe name of the FunCell to connect.
GPointer to the directed graph representing the device model.
positionedOutputFileOutput file stream for positioned connections.
unpositionedOutputFileOutput file stream for unpositioned connections.

Connects associated pins to the specified FunCell in the device model graph.

◆ needLocking()

bool needLocking ( int HID,
json & jsonParsed,
std::string & jsonLockNode )

Checks whether locking is required for the given hNamed based on the information given in the JSON. In JSON, we define the locking code as "hName::gName"

Parameters
HIDCurrent HID of the application graph
jsonParsedReference to the parsed JSON object containing node type information.
jsonLockNodeRetrieved full string of the lock node from the JSON file only is a lock exist for a specific node in application graph
Returns
bool Returns true if locking is required, false otherwise.

Checks whether locking is required for the given hNamed based on the information given in the JSON. In JSON, we define the locking code as "hName::gName"

◆ printMappedResults()

void printMappedResults ( DirectedGraph * H,
DirectedGraph * G,
std::map< int, NodeConfig > * hConfig,
std::map< int, NodeConfig > * gConfig,
json & UgrammPragmaConfig )

Prints mapping results in neato format: First displays the layout and then shows connections between the nodes.

Parameters
HA pointer to the application graph.
GA pointer to the device-model graph.
hConfigA map containing node configuration details of application graph.
gConfigA map containing node configuration details of device-model graph.
ugrammConfigA map containing parsed pragma and config related information.

Prints mapping results in neato format: First displays the layout and then shows connections between the nodes.

◆ printName()

void printName ( int n)

Prints the device model cell name corresponding to a given boost id number from device model graph.

Parameters
nThe boost integer id.

Prints the device model cell name corresponding to a given boost id number from device model graph.

◆ printPlacementResults()

void printPlacementResults ( int gNumber,
std::string gName,
DirectedGraph * G,
std::ofstream & positionedOutputFile,
std::ofstream & unpositionedOutputFile,
std::map< int, NodeConfig > * gConfig,
json & UgrammPragmaConfig )

Prints placement information to a mapping-output file.

Parameters
gNumberA boost node id from the device-model graph.
gNameAn integer used in the output.
GA pointer to the device-model graph.
positionedOutputFileThe positioned-output dot file stream (this dot-file contains actual co-ordinates of the node cells).
unpositionedOutputFileThe unpositioned-output dot file stream (this dot-file does not contain any co-ordinates of the node cells).
gConfigA map containing node configuration details of device-model graph.
ugrammConfigA map containing parsed pragma and config related information.

Prints placement information to a mapping-output file.

◆ printRouting()

void printRouting ( int signal)

Prints the routing details for the given signal.

Parameters
signalThe signal for which to print routing details.

Prints the routing details for the given signal.

◆ printRoutingResults()

void printRoutingResults ( int y,
std::ofstream & positionedOutputFile,
std::ofstream & unpositionedOutputFile,
std::map< int, NodeConfig > * hConfig,
std::map< int, NodeConfig > * gConfig )

Prints routing information to a mapping-output file.

Parameters
gNumberA boost node id from the device-model graph.
yA boost node id from the application graph.
positionedOutputFileThe positioned-output dot file stream (this dot-file contains actual co-ordinates of the node cells).
unpositionedOutputFileThe unpositioned-output dot file stream (this dot-file does not contain any co-ordinates of the node cells).
hConfigA map containing node configuration details of device-model graph.
gConfigA map containing node configuration details of device-model graph.

Prints routing information to a mapping-output file.

◆ printVertexModels()

void printVertexModels ( DirectedGraph * H,
DirectedGraph * G,
std::map< int, NodeConfig > * hConfig,
std::map< int, int > & invUsers )

Prints vertex models of the application graph's nodes.

Parameters
HA pointer to the application graph.
GA pointer to the device-model graph.
hConfigA map containing node configuration details of device-model graph.
invUsersA map of hIDs to mapped gIDs.

Prints vertex models of the application graph's nodes.

◆ readApplicationGraph()

void readApplicationGraph ( DirectedGraph * H,
std::map< int, NodeConfig > * hConfig,
std::map< int, NodeConfig > * gConfig )

Reads a DOT file and stores attributes into the application graph.

Parameters
HPointer to the directed graph representing the application graph.
hConfigPointer to the map where node attributes will be stored.
gConfigPointer to the map where node attributes will be stored.

Reads a DOT file and stores attributes into the application graph.

◆ readApplicationGraphPragma()

void readApplicationGraphPragma ( std::ifstream & applicationGraphFile,
json & UgrammPragmaConfig )

Reads, checks, and stores PRAGMA directives from the application graph file.

Parameters
applicationGraphFileReference to the input file stream for the application graph.
UgrammPragmaConfigReference to the map where PRAGMA directives will be stored.

Reads, checks, and stores PRAGMA directives from the application graph file.

◆ readCommentSection()

std::string readCommentSection ( std::ifstream & inputFile)

Reads a multi-line comment containing PRAGMA from the given file.

Parameters
inputFileReference to the input file stream from which to read the comment section.
Returns
std::string Returns the content of the multi-line comment as a string.

Reads a multi-line comment containing PRAGMA from the given file.

◆ readDeviceModel()

void readDeviceModel ( DirectedGraph * G,
std::map< int, NodeConfig > * gConfig )

Reads a DOT file and stores attributes into the device model graph.

Parameters
GPointer to the directed graph representing the device model.
gConfigPointer to the map where node attributes will be stored.

Reads a DOT file and stores attributes into the device model graph.

◆ readDeviceModelPragma()

void readDeviceModelPragma ( std::ifstream & deviceModelFile,
json & UgrammPragmaConfig )

Reads, checks, and stores PRAGMA directives from the device model file.

Parameters
deviceModelFileReference to the input file stream for the device model.
UgrammPragmaConfigReference to the map where PRAGMA directives will be stored.

Reads, checks, and stores PRAGMA directives from the device model file.

◆ removeCurlyBrackets()

std::string removeCurlyBrackets ( const std::string & input)

Removes the curly brackets '{' and '}' from the given string. The kernels present in CGRA-ME have {} included in the node names, which hinders dot visualization.

Parameters
inputThe input string from which curly brackets should be removed.
Returns
A new string with the curly brackets removed. If no curly brackets are found, the original string is returned unchanged.

Removes the curly brackets '{' and '}' from the given string. The kernels present in CGRA-ME have {} included in the node names, which hinders dot visualization.

◆ skipPlacement()

bool skipPlacement ( std::string hOpcode,
json & jsonParsed )

Checks whether placement is required for the given opcode based on the information given in the JSON. In JSON, we can either have opcode("Reg") or nodeType("ALU/Memport") to be skipped.

Parameters
hOpcodeThe opcode from the application graph to check.
jsonParsedReference to the parsed JSON object containing node type information.
Returns
bool Returns true if placement is required, false otherwise.

Checks whether placement is required for the given opcode based on the information given in the JSON. In JSON, we can either have opcode("Reg") or nodeType("ALU/Memport") to be skipped.

◆ string_remover()

std::string string_remover ( std::string original_string,
std::string toRemove )

Removes a specified substring from the original string.

Parameters
original_stringThe original string.
toRemoveThe substring to remove.
Returns
A new string with the substring removed.

Removes a specified substring from the original string.

◆ widthCheck()

bool widthCheck ( int hWidth,
int gWidth )

Checks if the application graph's node width is less than or equal to the device model's node width.

Parameters
hWidthWidth of node in the application graph.
gWidthWidth of node in the device model.
Returns
true if hWidth is less than or equal to gWidth, otherwise false.

Checks if the application graph's node width is less than or equal to the device model's node width.

Variable Documentation

◆ colors

std::vector<std::string> colors
extern

◆ funCellMapping

std::map<std::string, std::string> funCellMapping
extern

◆ input_pin_color

std::string input_pin_color
extern

◆ output_pin_color

std::string output_pin_color
extern

◆ unused_cell_color

std::string unused_cell_color
extern