VA-File and VA-Code
VA Code structure. As Includes traverse like a tree, it is implemented as a dictionary Oo.
- class DMT.core.va_file.VACode(code: str = '', code_compressed: tuple[str, int] = ('', -1), ignore_checksum: bool = False)[source]
Bases:
object
Base file for VA-Codes
- Parameters:
- class DMT.core.va_file.VAFileMap(name: str | Path, files: dict[str, VACode] | None = None, code: str | VACode = '', code_compressed: tuple[str, int] = ('', -1), ignore_checksum: bool = False)[source]
Bases:
object
Mapping for VA-Code. The mapping data type is chosen to correctly use possible file structures of multi-file VA-Codes
- Parameters:
- name
Union
[str
,Path
] Absolute or relative path to file or just name of the root file.
- files
dict
,optional
Dictionary with {file_name: VACode}. One of the keys must be the same as the name, by default None
- code
Union
[str
,VACode
],optional
Code of the root file, by default “”
- code_compressed(
str
,int
),optional
Compressed code as loaded from a json modelcard file.
- ignore_checksum: bool, optional
If True, the checksum is ignored, defaults to False.
- name
- export_dict(compressed_code: bool = False) dict [source]
Export self and children into a dictionary for serialization
- get_tree_hash() str [source]
Create a hash for all the codes from this node and all its children. Should be unique for each model…
- Returns:
str
MD5 Hash for the code of this file and all its children
- classmethod import_dict(data_import: dict, ignore_checksum: bool = False) VAFileMap [source]
Imports a full VAFileMap from a (serialized) dictionary
- read_structure(path_to_own_folder: str | Path)[source]
Checks the file for imports and adds them into the dict. This is done using verilogae.
- Parameters:
- path_to_own_folder
Union
[str
,Path
] Path, in which the main file of the model is located.
- path_to_own_folder
- Raises:
NotImplementedError
Currently only relative imports are supported. If a file includes an absolute path, the error is raised.
- property root_vfs: str[source]
Returns the root path inside the vfs
- Returns:
str
Path to the root file
- property vfs: dict[str, str][source]
Virtual file system of this VAFileMap
The vfs is saved in a dictionary with {<path>: <file content>}
- write_files(path_to_target: str | Path, filter: Callable[[str], str] | None = None)[source]
Writes the all Verilog-A files from this mapping into the given target path. The file structure is written as read from the “original”
- Parameters:
- path_to_target
Union
[str
,Path
] Path to target directory
- filter
callable()
,optional
Called with each code file as an argument. Can be used to filter out “non-compiling” additional code parts. For example to remove VAE language extensions (spectre):
lambda code: re.sub(r"\(\*.+\*\)", "", code)
- path_to_target