Skip to content

Commit 78d4c27

Browse files
committed
improved code documentation and formatting
1 parent 40be52d commit 78d4c27

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
lines changed

utils/vqm2blif/src/base/hard_block_recog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The purpose of this file is to support netlists that
33
* contain new types of hard blocks. Specifically, user defined
4-
* hard blocks are indetified within the netlist and then instantiated
4+
* hard blocks are identified within the netlist and then instantiated
55
* so that they are later written to the generated .blif file.
66
*
77
* For example, consider a user design that contains a new hard block

utils/vqm2blif/src/base/hard_block_recog.h

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef HARD_BLOCK_RECOG_H
2+
#define HARD_BLOCK_RECOG_H
3+
14
/* VQM new primitive hard block recognition header file
25
*
36
* The purpose of this file is to identify and instantiate
@@ -10,18 +13,16 @@
1013
*
1114
* This file also contains all the declarations of functions that can be
1215
* used to interact with and manipulate the main data structures. Additionally,
13-
* some utility functions are added to help identify whether a hard block was * included within the design. For more information,
14-
* refer to 'hard_block_recog.cpp'.
16+
* some utility functions are added to help identify whether a hard block was
17+
* included within the design.
18+
* For more information, refer to 'hard_block_recog.cpp'.
1519
*
1620
*/
1721

1822

1923
// need to use vtr::malloc for memory allocation (only in the files here)
20-
// no need to run VTR assert, after memory allocation, this is checked in the function already
21-
24+
// no need to rcheck for failed malloc (NULL pointer), this is already checked in vtr::malloc
2225

23-
#ifndef HARD_BLOCK_RECOG_H
24-
#define HARD_BLOCK_RECOG_H
2526

2627
// user VTR libraries
2728
#include "vqm_dll.h"
@@ -63,18 +64,27 @@
6364
// each level of hierarchy (module within module) is seperated by the delimiter character defined below. The last level of hierarchy is the output net of the block
6465
#define VQM_NODE_NAME_DELIMITER "|"
6566

67+
// a port that is a bus is a vectored port. So a single port name with multiple indices.
68+
// We use the size of the port to determine whether the port is a bus or not.
69+
// A port size of 1 represents a port that is not a bus, whereas a port size greater than 1 represents a bus.
70+
// So a non-bus port size is represented below
6671
#define PORT_NOT_BUS 1
6772

73+
// We use regex to extract the port name and index from the vqm netlist.
74+
// For example, given the string payload[1]~QIC_DANGLING_PORT_I, we would extract 'payload' and '1'.
75+
// For the case where a port is not a bus, we would just extract the port name.
76+
// Now the extracted information is stored in an array of strings, and the indices of where the port name and index are stored is found below.
6877
#define PORT_NAME 1
6978
#define PORT_INDEX 2
7079

80+
// used to identify the case where a hard block instance is not found within the netlist
7181
#define HARD_BLOCK_INSTANCE_DOES_NOT_EXIST -1
7282

7383
// define how flip flops and LUT will be identified within a given node type (within t_node struct)
7484
#define LUT_TYPE "stratixiv_lcell_comb"
7585
#define DFF_TYPE "dffeas"
7686

77-
// define the number of ports a LUT that represents a hard block instance output port would have
87+
// define the number of output ports a LUT that represents a hard block instance output port would have
7888
#define LUT_OUTPUT_PORT_SIZE 1
7989

8090
// names of the output port for a LUT and DFF
@@ -88,11 +98,12 @@
8898

8999

90100
/*
91-
* The purpose of this data structure is to
92-
* store the port information (in an array) for an arbritary user defined
93-
* hard block design. Then a mapping is provided which can
101+
* The port information (in an array) for an arbritary user defined
102+
* hard block in the design is stored in s_hard_block_port_info. Then a
103+
* mapping is provided which can
94104
* help identify the specific location within the port array
95-
* that a given port name begins at.
105+
* that a given port name begins at. This data structure is created
106+
* for each type of hard block.
96107
*/
97108
typedef struct s_hard_block_port_info
98109
{
@@ -115,12 +126,13 @@ typedef struct s_hard_block_port_info
115126
* This node will then be stored within a node array and enclosed
116127
* within a 't_module' variable (refer to 'vqm_dll.h').
117128
*
118-
*
119-
* The purpose of the data structure below is to keep a reference to a
120-
* single hard block node (one instance of a hard block within the design). * This way, the node can be accessed quickly whenever changes need to be
129+
* A reference to a single hard block node (one instance of a hard block
130+
* within the design) is stored inside s_hard_block, so it essentially
131+
* represents a hard block instance.
132+
* This way, the node can be accessed quickly whenever changes need to be
121133
* applied. Additional information about the hard block is also stored as well.
122134
*
123-
* THe node itself is stored internally within the a node array. And
135+
* The node itself is stored internally within the a node array. And
124136
* located inside a module.
125137
*/
126138
typedef struct s_hard_block
@@ -141,13 +153,11 @@ typedef struct s_hard_block
141153
* the names and port info of every type of user defined hard blocks. It
142154
* also stores all hard blocks that were instantiated within
143155
* the user design and an accompanying data strcuture to quickly identify
144-
* a specific hard block instance. All functiions will primarily interact
156+
* a specific hard block instance. All functions will primarily interact
145157
* with this data structure.
146158
*/
147159
typedef struct s_hard_block_recog
148160
{
149-
// names of all the user defined hard blocks
150-
//std::vector<std::string>* hard_block_type_names; // hb_type_names (probably do not need)
151161

152162
// store the port information of each and every type of
153163
// user defined hard blocks. All ports connected to each
@@ -158,7 +168,8 @@ typedef struct s_hard_block_recog
158168
// user design
159169
std::vector<t_hard_block> hard_block_instances;
160170

161-
/* given a specific hard block instance name, we need to quickly
171+
/*
172+
Given a specific hard block instance name, we need to quickly
162173
identify the corresponding hard block structure instance.
163174
We do this by using the map data structure below,
164175
where a hard block instance name is associated with an index
@@ -169,17 +180,27 @@ typedef struct s_hard_block_recog
169180
/*
170181
The luts and dffeas used to model ports are all stored as nodes and
171182
we will need to remove them from the netlist after adding all the
172-
hard blocks to the netlist.The ports that are modelled by the luts and dffeas aren't needed once all the hard blocks within the design are added to the netlist.The luts and dffeas are simply repeating the port information, so we can remove them.
183+
hard blocks to the netlist.The ports that are modelled by the luts and dffeas
184+
aren't needed once all the hard blocks within the design are added to the netlist.
185+
The luts and dffeas are simply repeating the port information, so we can remove them.
173186
174-
The nodelist is simply an array. Now deleting lut/dffeas nodes while still creating additional hard block nodes could cause some problems, so we will delete all these nodes at the end. Therefore we need to keep a
175-
reference for all the luts and dffeas nodes that represent hard block ports here, so we can them remove later on.*/
187+
The nodelist is simply an array. Now deleting lut/dffeas nodes while still creating additional
188+
hard block nodes could cause some problems, so we will delete all these nodes at the end.
189+
Therefore we need to keep a reference for all the luts and dffeas nodes that
190+
represent hard block ports here, so we can them remove later on.
191+
*/
176192
std::vector<t_node*> luts_dffeas_nodes_to_remove; // look into using array index instead
177193

178194
}t_hard_block_recog;
179195

180196
/*
181-
* When we go through the .vqm file, the ports of any user defined hard block * will be represented as a LUT (stratix_lcell), or flip flop (dffeas) (for * more info refer to 'hard_block_recog.cpp'). The generated names found in * the .vqm file for the two previous blocks contain a lot of information * about the hard block. The structure below is used to store the information,
182-
* which includes the hard block name, hard block type, the specfic hard * block port and if the port is a bus, then the specific index.
197+
* When we go through the .vqm file, the ports of any user defined hard block
198+
* will be represented as a LUT (stratix_lcell), or flip flop (dffeas)
199+
* (for more info refer to 'hard_block_recog.cpp'). The generated names found
200+
* in the .vqm file for the two previous blocks contain a lot of information
201+
* about the hard block. The structure below is used to store the information,
202+
* which includes the hard block name, hard block type, the specfic hard
203+
* block port and if the port is a bus, then the specific index.
183204
*/
184205
typedef struct s_parsed_hard_block_port_info
185206
{
@@ -195,7 +216,7 @@ typedef struct s_parsed_hard_block_port_info
195216
std::string hard_block_port_name = "";
196217

197218
// index of the port defined in the current block (LUT or dffeas)
198-
// initialized to an index equivalent to what a port thas is not a bus would have
219+
// initialized to an index equivalent to what a port that is not a bus would have
199220
int hard_block_port_index = DEFAULT_PORT_INDEX;
200221

201222
}t_parsed_hard_block_port_info;
@@ -228,4 +249,4 @@ typedef struct s_parsed_hard_block_port_info
228249
*/
229250
void add_hard_blocks_to_netlist(t_module*, t_arch*, std::vector<std::string>*, std::string, std::string);
230251

231-
#endif
252+
#endif

0 commit comments

Comments
 (0)