Code generator in Engee
Code generation via GUI
Code generation for subsystem
To generate code via the Engee GUI, right-click on the subsystem (block Subsystem):
In this way you can generate code from any selected subsystem in the model.
The generated code is located in a directory named modelname_Subsystem_code
in the same directory where the model is located (or in the current directory if the model has not yet been saved to disc). Here modelname
is the model name, Subsystem
is the subsystem name, and code
is the suffix added to the name of the directory with the generated code. For example, for a block with the name Subsystem in the model newmodel_1:
When generation is complete, a notification of successful code generation will appear in the model diagnostics window :
Code generation for the top level of the model
To generate the code for the entire model in the Engee GUI, click the button Generate code button located on the workspace toolbar.
In the drop-down menu next to the generate button, the target Engee platform must be selected (selected by default).
The generated code is in a directory named modelname_code
in the same directory as the model (or in the current directory if the model has not yet been saved to disc). Here modelname
is the model name, and code
is a suffix added to the name of the directory with the generated code. For example, for model newmodel_1 (subsystem not selected):
Code generation via command line or interactive script
To generate code in Engee, the command engee.generate_code is used in command line or script editor
.
Code generation for subsystem
To generate code for a subsystem, specify the full path to the subsystem using the subsystem_name
argument. The full path to the subsystem includes its name in the model.
*Function Signature:
engee.generate_code(
path/to/modelname.engee::String,
path/to/output_dir::String;
subsystem_name=subsystem_path::String,
subsystem_id = subsystem_id::String,
target::String
)
*Arguments:
-
path/to/modelname.engee::String
: Absolute or relative path to the model from which the code is generated. The argument can be a model object (an object of type model obtained by theengee.gcm
function). -
path/to/output_dir::String
: Absolute or relative path to the directory where the generated code will be saved. If theoutput_dir
directory does not exist - it will be created automatically. -
subsystem_name=path/to/subsystem::String
: Full path to the atomic subsystem from which the code is generated. -
subsystem_id= subsystem_id::String
: The unique identifier of the atomic subsystem from which the code is generated. -
target::String
: Specifies the language for code generation. Supported languages areSi
(by default) orVerilog
.
If no path to the generated subsystem is specified, the code is generated from the top level of the model.
*Example:
engee.generate_code("/user/newmodel_1.engee", "/user/newmodel_1/Subsystem") # генерация кода для подсистемы
engee.generate_code("/user/newmodel_1.engee", "/user/newmodel_1/Subsystem"; subsystem_id = "88275e0b-a049-4bb5-b8c7-057badd1b536") # генерация кода для атомарной подсистемы по ее id
Code generation for a model
To generate code from the entire model, specify the path to the model and the directory to save the generated code. If the model is already open in Engee, you can pass the model object obtained with the function engee.gcm).
Function signature:
engee.generate_code(
path/to/modelname.engee::String,
path/to/output_dir::String;
target::String
)
*Arguments:
-
path/to/modelname.engee::String
: Absolute or relative path to the model from which the code is generated. The argument can be a model object (an object of type model obtained by theengee.gcm
function). -
path/to/modelname.engee::String
: Absolute or relative path to the model from which the code is generated. The argument can be a model object (an object of type model obtained by theengee.gcm
function). -
path/to/output_dir::String
: Absolute or relative path to the directory where the generated code will be saved. If theoutput_dir
directory does not exist - it will be created automatically. -
target::String
: Specifies the language for code generation. Supported languages areCi
(by default) orVerilog
.
*Example:
engee.generate_code("/user/newmodel_1.engee", "/user/newmodel_1/codegen_output") # абсолютный путь к модели
engee.generate_code("newmodel_1.engee", "newmodel_1/codegen_output") # относительный путь к модели
m = engee.gcm() # получение текущей открытой модели
engee.generate_code(m, "/user/newmodel_1/codegen_output")