Skip to content

Commit 9c100cd

Browse files
committed
Transforming to Doxy style
1 parent 21af89e commit 9c100cd

2 files changed

Lines changed: 45 additions & 100 deletions

File tree

assembler_tools/hec-assembler-tools/he_link.py

Lines changed: 30 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
#! /usr/bin/env python3
22
# encoding: utf-8
33
"""
4-
This module provides functionality for linking assembled kernels into a full HERACLES program for execution queues: MINST, CINST, and XINST.
5-
6-
Classes:
7-
LinkerRunConfig
8-
Maintains the configuration data for the run.
9-
10-
KernelFiles
11-
Structure for kernel files.
12-
13-
Functions:
14-
main(run_config: LinkerRunConfig, verbose_stream=None)
15-
Executes the linking process using the provided configuration.
16-
17-
parse_args() -> argparse.Namespace
18-
Parses command-line arguments for the linker script.
19-
20-
Usage:
21-
This script is intended to be run as a standalone program. It requires specific command-line arguments
22-
to specify input and output files and configuration options for the linking process.
4+
@file
5+
@brief This module provides functionality for linking assembled kernels into a full HERACLES program for execution queues: MINST, CINST, and XINST.
236
7+
This script is intended to be run as a standalone program. It requires specific command-line arguments
8+
to specify input and output files and configuration options for the linking process.
249
"""
2510
import argparse
2611
import io
@@ -48,11 +33,7 @@
4833

4934
class LinkerRunConfig(RunConfig):
5035
"""
51-
Maintains the configuration data for the run.
52-
53-
Methods:
54-
as_dict() -> dict
55-
Returns the configuration as a dictionary.
36+
@brief Maintains the configuration data for the run.
5637
"""
5738

5839
__initialized = False # specifies whether static members have been initialized
@@ -62,34 +43,27 @@ class LinkerRunConfig(RunConfig):
6243

6344
def __init__(self, **kwargs):
6445
"""
65-
Constructs a new LinkerRunConfig Object from input parameters.
46+
@brief Constructs a new LinkerRunConfig Object from input parameters.
6647
6748
See base class constructor for more parameters.
6849
69-
Args:
70-
input_prefixes (list[str]):
71-
List of input prefixes, including full path. For an input prefix, linker will
50+
@param kwargs Dictionary of configuration parameters:
51+
- input_prefixes: List of input prefixes, including full path. For an input prefix, linker will
7252
assume there are three files named `input_prefixes[i] + '.minst'`,
7353
`input_prefixes[i] + '.cinst'`, and `input_prefixes[i] + '.xinst'`.
7454
This list must not be empty.
75-
output_prefix (str):
76-
Prefix for the output file names.
55+
- output_prefix: Prefix for the output file names.
7756
Three files will be generated:
7857
`output_dir/output_prefix.minst`, `output_dir/output_prefix.cinst`, and
7958
`output_dir/output_prefix.xinst`.
8059
Output filenames cannot match input file names.
81-
input_mem_file (str):
82-
Input memory file associated with the result kernel.
83-
output_dir (str): current working directory
84-
OPTIONAL directory where to store all intermediate files and final output.
60+
- input_mem_file: Input memory file associated with the result kernel.
61+
- output_dir: OPTIONAL directory where to store all intermediate files and final output.
8562
This will be created if it doesn't exists.
8663
Defaults to current working directory.
8764
88-
Raises:
89-
TypeError:
90-
A mandatory configuration value was missing.
91-
ValueError:
92-
At least, one of the arguments passed is invalid.
65+
@throws TypeError A mandatory configuration value was missing.
66+
@throws ValueError At least, one of the arguments passed is invalid.
9367
"""
9468

9569
self.init_default_config()
@@ -113,7 +87,7 @@ def __init__(self, **kwargs):
11387
@classmethod
11488
def init_default_config(cls):
11589
"""
116-
Initializes static members of the class.
90+
@brief Initializes static members of the class.
11791
"""
11892
if not cls.__initialized:
11993
cls.__default_config["input_prefixes"] = None
@@ -129,10 +103,9 @@ def init_default_config(cls):
129103

130104
def __str__(self):
131105
"""
132-
Provides a string representation of the configuration.
106+
@brief Provides a string representation of the configuration.
133107
134-
Returns:
135-
str: The string for the configuration.
108+
@return The string for the configuration.
136109
"""
137110
self_dict = self.as_dict()
138111
with io.StringIO() as retval_f:
@@ -143,10 +116,9 @@ def __str__(self):
143116

144117
def as_dict(self) -> dict:
145118
"""
146-
Provides the configuration as a dictionary.
119+
@brief Provides the configuration as a dictionary.
147120
148-
Returns:
149-
dict: The configuration.
121+
@return The configuration.
150122
"""
151123
retval = super().as_dict()
152124
tmp_self_dict = vars(self)
@@ -155,17 +127,12 @@ def as_dict(self) -> dict:
155127

156128
class KernelFiles(NamedTuple):
157129
"""
158-
Structure for kernel files.
159-
160-
Attributes:
161-
minst (str):
162-
Index = 0. Name for file containing MInstructions for represented kernel.
163-
cinst (str):
164-
Index = 1. Name for file containing CInstructions for represented kernel.
165-
xinst (str):
166-
Index = 2. Name for file containing XInstructions for represented kernel.
167-
prefix (str):
168-
Index = 3
130+
@brief Structure for kernel files.
131+
132+
@var minst Index = 0. Name for file containing MInstructions for represented kernel.
133+
@var cinst Index = 1. Name for file containing CInstructions for represented kernel.
134+
@var xinst Index = 2. Name for file containing XInstructions for represented kernel.
135+
@var prefix Index = 3
169136
"""
170137
minst: str
171138
cinst: str
@@ -174,17 +141,14 @@ class KernelFiles(NamedTuple):
174141

175142
def main(run_config: LinkerRunConfig, verbose_stream = None):
176143
"""
177-
Executes the linking process using the provided configuration.
144+
@brief Executes the linking process using the provided configuration.
178145
179146
This function prepares input and output file names, initializes the memory model, discovers variables,
180147
and links each kernel, writing the output to specified files.
181148
182-
Args:
183-
run_config (LinkerRunConfig): The configuration object containing run parameters.
184-
verbose_stream: The stream to which verbose output is printed. Defaults to None.
185-
186-
Returns:
187-
None
149+
@param run_config The configuration object containing run parameters.
150+
@param verbose_stream The stream to which verbose output is printed. Defaults to None.
151+
@return None
188152
"""
189153
if verbose_stream:
190154
print("Linking...", file=verbose_stream)
@@ -313,13 +277,12 @@ def main(run_config: LinkerRunConfig, verbose_stream = None):
313277

314278
def parse_args():
315279
"""
316-
Parses command-line arguments for the linker script.
280+
@brief Parses command-line arguments for the linker script.
317281
318282
This function sets up the argument parser and defines the expected arguments for the script.
319283
It returns a Namespace object containing the parsed arguments.
320284
321-
Returns:
322-
argparse.Namespace: Parsed command-line arguments.
285+
@return Parsed command-line arguments.
323286
"""
324287
parser = argparse.ArgumentParser(
325288
description=("HERACLES Linker.\n"

assembler_tools/hec-assembler-tools/he_prep.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
#! /usr/bin/env python3
22

33
"""
4-
This module provides functionality for preprocessing P-ISA abstract kernels before further assembling for HERACLES.
5-
6-
Functions:
7-
__savePISAListing(out_stream, instr_listing: list)
8-
Stores instructions to a stream in P-ISA format.
9-
10-
main(output_file_name: str, input_file_name: str, b_verbose: bool)
11-
Preprocesses the P-ISA kernel and saves the output to a specified file.
12-
13-
parse_args() -> argparse.Namespace
14-
Parses command-line arguments for the preprocessing script.
15-
16-
Usage:
17-
This script is intended to be run as a standalone program. It requires specific command-line arguments
18-
to specify input and output files and verbosity options for the preprocessing process.
4+
@file
5+
@brief This module provides functionality for preprocessing P-ISA abstract kernels before further assembling for HERACLES.
196
7+
This script is intended to be run as a standalone program. It requires specific command-line arguments
8+
to specify input and output files and verbosity options for the preprocessing process.
209
"""
2110
import argparse
2211
import os
@@ -31,17 +20,14 @@
3120
def __savePISAListing(out_stream,
3221
instr_listing: list):
3322
"""
34-
Stores the instructions to a stream in P-ISA format.
23+
@brief Stores the instructions to a stream in P-ISA format.
3524
3625
This function iterates over a list of instructions and prints each instruction in P-ISA format
3726
to the specified output stream.
3827
39-
Args:
40-
out_stream: The output stream to which the instructions are printed.
41-
instr_listing (list): A list of instructions to be printed in P-ISA format.
42-
43-
Returns:
44-
None
28+
@param out_stream The output stream to which the instructions are printed.
29+
@param instr_listing A list of instructions to be printed in P-ISA format.
30+
@return None
4531
"""
4632
for inst in instr_listing:
4733
inst_line = inst.toPISAFormat()
@@ -52,18 +38,15 @@ def main(output_file_name: str,
5238
input_file_name: str,
5339
b_verbose: bool):
5440
"""
55-
Preprocesses the P-ISA kernel and saves the output to a specified file.
41+
@brief Preprocesses the P-ISA kernel and saves the output to a specified file.
5642
5743
This function reads an input kernel file, preprocesses it to transform instructions into ASM-ISA format,
5844
assigns register banks to variables, and saves the processed instructions to an output file.
5945
60-
Args:
61-
output_file_name (str): The name of the output file where processed instructions are saved.
62-
input_file_name (str): The name of the input file containing the P-ISA kernel.
63-
b_verbose (bool): Flag indicating whether verbose output is enabled.
64-
65-
Returns:
66-
None
46+
@param output_file_name The name of the output file where processed instructions are saved.
47+
@param input_file_name The name of the input file containing the P-ISA kernel.
48+
@param b_verbose Flag indicating whether verbose output is enabled.
49+
@return None
6750
"""
6851
# used for timings
6952
insts_end: int = 0
@@ -112,13 +95,12 @@ def main(output_file_name: str,
11295

11396
def parse_args():
11497
"""
115-
Parses command-line arguments for the preprocessing script.
98+
@brief Parses command-line arguments for the preprocessing script.
11699
117100
This function sets up the argument parser and defines the expected arguments for the script.
118101
It returns a Namespace object containing the parsed arguments.
119102
120-
Returns:
121-
argparse.Namespace: Parsed command-line arguments.
103+
@return Parsed command-line arguments.
122104
"""
123105
parser = argparse.ArgumentParser(
124106
description="HERACLES Assembling Pre-processor.\nThis program performs the preprocessing of P-ISA abstract kernels before further assembling.")

0 commit comments

Comments
 (0)