hdlparse package¶
Submodules¶
hdlparse.minilexer module¶
hdlparse.verilog_parser module¶
-
class
hdlparse.verilog_parser.
VerilogExtractor
¶ Bases:
object
Utility class that caches parsed objects
-
extract_objects
(fname, type_filter=None)¶ Extract objects from a source file
Parameters: - fname (str) – Name of file to read from
- type_filter (class, optional) – Object class to filter results
Returns: List of objects extracted from the file.
-
extract_objects_from_source
(text, type_filter=None)¶ Extract object declarations from a text buffer
Parameters: - text (str) – Source code to parse
- type_filter (class, optional) – Object class to filter results
Returns: List of parsed objects.
-
is_array
(data_type)¶ Check if a type is an array type
Parameters: data_type (str) – Data type Returns: True when a data type is an array.
-
-
class
hdlparse.verilog_parser.
VerilogModule
(name, ports, generics=None, sections=None, desc=None)¶ Bases:
hdlparse.verilog_parser.VerilogObject
Module definition
-
class
hdlparse.verilog_parser.
VerilogObject
(name, desc=None)¶ Bases:
object
Base class for parsed Verilog objects
-
class
hdlparse.verilog_parser.
VerilogParameter
(name, mode=None, data_type=None, default_value=None, desc=None)¶ Bases:
object
Parameter and port to a module
-
hdlparse.verilog_parser.
is_verilog
(fname)¶ Identify file as Verilog by its extension
Parameters: fname (str) – File name to check Returns: True when file has a Verilog extension.
-
hdlparse.verilog_parser.
parse_verilog
(text)¶ Parse a text buffer of Verilog code
Parameters: text (str) – Source code to parse Returns: List of parsed objects.
-
hdlparse.verilog_parser.
parse_verilog_file
(fname)¶ Parse a named Verilog file
Parameters: fname (str) – File to parse. Returns: List of parsed objects.
hdlparse.vhdl_parser module¶
-
class
hdlparse.vhdl_parser.
VhdlComponent
(name, package, ports, generics=None, sections=None, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Component declaration
Parameters: - name (str) – Name of the component
- package (str) – Package containing the component
- ports (list of VhdlParameter) – Port parameters to the component
- generics (list of VhdlParameter) – Generic parameters to the component
- sections (list of str) – Metacomment sections
- desc (str, optional) – Description from object metacomments
-
dump
()¶
-
class
hdlparse.vhdl_parser.
VhdlConstant
(name, package, base_type, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Constant definition
Parameters: - name (str) – Name of the constant
- package (str) – Package containing the constant
- base_type (str) – Type fo the constant
- desc (str, optional) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlExtractor
(array_types=set([]))¶ Bases:
object
Utility class that caches parsed objects and tracks array type definitions
Parameters: array_types (set) – Initial array types -
extract_objects
(fname, type_filter=None)¶ Extract objects from a source file
Parameters: - fname (str) – File to parse
- type_filter (class, optional) – Object class to filter results
Returns: List of parsed objects.
-
extract_objects_from_source
(text, type_filter=None)¶ Extract object declarations from a text buffer
Parameters: - text (str) – Source code to parse
- type_filter (class, optional) – Object class to filter results
Returns: List of parsed objects.
-
is_array
(data_type)¶ Check if a type is a known array type
Parameters: data_type (str) – Name of type to check Returns: True if data_type
is a known array type.
-
load_array_types
(fname)¶ Load file of previously extracted data types
Parameters: fname (str) – Name of file to load array database from
-
register_array_types_from_sources
(source_files)¶ Add array type definitions from a file list to internal registry
Parameters: source_files (list of str) – Files to parse for array definitions
-
save_array_types
(fname)¶ Save array type registry to a file
Parameters: fname (str) – Name of file to save array database to
-
-
class
hdlparse.vhdl_parser.
VhdlFunction
(name, package, parameters, return_type=None, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Function declaration
Parameters: - name (str) – Name of the function
- package (str) – Package containing the function
- parameters (list of VhdlParameter) – Parameters to the function
- return_type (str, optional) – Type of the return value
- desc (str, optional) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlObject
(name, desc=None)¶ Bases:
object
Base class for parsed VHDL objects
Parameters: - name (str) – Name of the object
- desc (str) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlPackage
(name, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Package declaration
Parameters: - name (str) – Name of the package
- desc (str) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlParameter
(name, mode=None, data_type=None, default_value=None, desc=None)¶ Bases:
object
Parameter to subprograms, ports, and generics
Parameters: - name (str) – Name of the object
- mode (str) – Direction mode for the parameter
- data_type (str) – Type name for the parameter
- default_value (str) – Default value of the parameter
- desc (str) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlProcedure
(name, package, parameters, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Procedure declaration
Parameters: - name (str) – Name of the procedure
- package (str) – Package containing the procedure
- parameters (list of VhdlParameter) – Parameters to the procedure
- desc (str, optional) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlSubtype
(name, package, base_type, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Subtype definition
Parameters: - name (str) – Name of the subtype
- package (str) – Package containing the subtype
- base_type (str) – Base type name derived from
- desc (str, optional) – Description from object metacomments
-
class
hdlparse.vhdl_parser.
VhdlType
(name, package, type_of, desc=None)¶ Bases:
hdlparse.vhdl_parser.VhdlObject
Type definition
Parameters: - name (str) – Name of the type
- package (str) – Package containing the type
- type_of (str) – Object type of this type definition
- desc (str, optional) – Description from object metacomments
-
hdlparse.vhdl_parser.
is_vhdl
(fname)¶ Identify file as VHDL by its extension
Parameters: fname (str) – File name to check Returns: True when file has a VHDL extension.
-
hdlparse.vhdl_parser.
parse_vhdl
(text)¶ Parse a text buffer of VHDL code
Parameters: text (str) – Source code to parse Returns: Parsed objects.
-
hdlparse.vhdl_parser.
parse_vhdl_file
(fname)¶ Parse a named VHDL file
Parameters: fname (str) – Name of file to parse Returns: Parsed objects.
-
hdlparse.vhdl_parser.
subprogram_prototype
(vo)¶ Generate a canonical prototype string
Parameters: vo (VhdlFunction, VhdlProcedure) – Subprogram object Returns: Prototype string.
-
hdlparse.vhdl_parser.
subprogram_signature
(vo, fullname=None)¶ Generate a signature string
Parameters: vo (VhdlFunction, VhdlProcedure) – Subprogram object Returns: Signature string.