mirror of
https://github.com/YosysHQ/yosys
synced 2025-12-14 07:36:24 +00:00
Explicitly store whether to use association lists
Instead of checking for the presence of helper names each time we need to determine whether to use association lists, explicitly store a boolean flag indicating whether association list helpers are being used.
This commit is contained in:
parent
ddcd93024f
commit
ade6379345
1 changed files with 6 additions and 4 deletions
|
|
@ -188,6 +188,7 @@ struct SmtrModule {
|
||||||
Functional::IR ir;
|
Functional::IR ir;
|
||||||
SmtrScope scope;
|
SmtrScope scope;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
bool use_assoc_list_helpers;
|
||||||
std::optional<std::string> input_helper_name;
|
std::optional<std::string> input_helper_name;
|
||||||
std::optional<std::string> output_helper_name;
|
std::optional<std::string> output_helper_name;
|
||||||
|
|
||||||
|
|
@ -196,7 +197,7 @@ struct SmtrModule {
|
||||||
SmtrStruct state_struct;
|
SmtrStruct state_struct;
|
||||||
|
|
||||||
SmtrModule(Module *module, bool assoc_list_helpers)
|
SmtrModule(Module *module, bool assoc_list_helpers)
|
||||||
: ir(Functional::IR::from_module(module)), scope(), name(scope.unique_name(module->name)),
|
: ir(Functional::IR::from_module(module)), scope(), name(scope.unique_name(module->name)), use_assoc_list_helpers(assoc_list_helpers),
|
||||||
input_struct(scope.unique_name(module->name.str() + "_Inputs"), scope),
|
input_struct(scope.unique_name(module->name.str() + "_Inputs"), scope),
|
||||||
output_struct(scope.unique_name(module->name.str() + "_Outputs"), scope),
|
output_struct(scope.unique_name(module->name.str() + "_Outputs"), scope),
|
||||||
state_struct(scope.unique_name(module->name.str() + "_State"), scope)
|
state_struct(scope.unique_name(module->name.str() + "_State"), scope)
|
||||||
|
|
@ -265,6 +266,9 @@ struct SmtrModule {
|
||||||
|
|
||||||
void write_assoc_list_helpers(SExprWriter &w)
|
void write_assoc_list_helpers(SExprWriter &w)
|
||||||
{
|
{
|
||||||
|
if (!output_helper_name || !input_helper_name)
|
||||||
|
log_error("if using keyword helpers, both input and output helper names are expected");
|
||||||
|
|
||||||
// Input struct keyword-based constructor.
|
// Input struct keyword-based constructor.
|
||||||
w.push();
|
w.push();
|
||||||
w.open(list("define"));
|
w.open(list("define"));
|
||||||
|
|
@ -308,9 +312,7 @@ struct SmtrModule {
|
||||||
output_struct.write_definition(w);
|
output_struct.write_definition(w);
|
||||||
state_struct.write_definition(w);
|
state_struct.write_definition(w);
|
||||||
|
|
||||||
if (input_helper_name || output_helper_name) {
|
if (use_assoc_list_helpers) {
|
||||||
if (!output_helper_name || !input_helper_name)
|
|
||||||
log_error("if keyword helpers are enabled, both input and output helper names are expected");
|
|
||||||
write_assoc_list_helpers(w);
|
write_assoc_list_helpers(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue