Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor full_selection #4768

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
428dbdc
Refactor full_selection
KrystalDelusion Nov 18, 2024
1d18334
tests/select: Add tests for selections with boxes
KrystalDelusion Nov 18, 2024
66ed710
Unify Design::selected_modules variants
KrystalDelusion Nov 19, 2024
334cede
Can clean boxed modules
KrystalDelusion Nov 19, 2024
a3b6b60
rtlil: Add selection helpers
KrystalDelusion Nov 19, 2024
c4f0ad9
Use selection helpers
KrystalDelusion Nov 19, 2024
15b921c
rtlil: Design::top_module() can be const
KrystalDelusion Nov 19, 2024
5d9d77a
Fixing selections
KrystalDelusion Nov 19, 2024
c120abe
Fix describe_selection_for_assert
KrystalDelusion Nov 19, 2024
ac5058a
Fix select_op_random ignoring boxes
KrystalDelusion Nov 19, 2024
ae94953
abc9: Use push_empty_selection()
KrystalDelusion Nov 19, 2024
c0a04b8
tests: Fixes for boxes
KrystalDelusion Nov 25, 2024
8e64222
Add Selection::complete_selection
KrystalDelusion Nov 25, 2024
c9fcad0
Selecting a blackbox sets selects_boxes
KrystalDelusion Nov 25, 2024
270c55e
select.cc: Re-add '=' to empty selection warning
KrystalDelusion Nov 26, 2024
11ee9ca
abc9.cc: Call select =*
KrystalDelusion Nov 26, 2024
4ab59a9
select.cc: Fix %i when rhs is empty
KrystalDelusion Nov 26, 2024
edbb3cb
abc9: Use techmap -autoproc
KrystalDelusion Nov 27, 2024
1cb5e3d
Design::selection_stack should never be empty
KrystalDelusion Nov 27, 2024
ed5ca08
abc_new: Use push_empty_selection()
KrystalDelusion Nov 27, 2024
7cbccc2
firrtl: Drop full_selection check
KrystalDelusion Dec 1, 2024
4c0f68b
Drop deprecation on Design::selected_modules()
KrystalDelusion Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions backends/firrtl/firrtl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,6 @@ struct FirrtlBackend : public Backend {
}
extra_args(f, filename, args, argidx);

if (!design->full_selection())
log_cmd_error("This command only operates on fully selected designs!\n");

log_header(design, "Executing FIRRTL backend.\n");
log_push();

Expand All @@ -1230,7 +1227,7 @@ struct FirrtlBackend : public Backend {
autoid_counter = 0;

// Get the top module, or a reasonable facsimile - we need something for the circuit name.
Module *top = design->top_module();
Module *top = nullptr;
Module *last = nullptr;
// Generate module and wire names.
for (auto module : design->modules()) {
Expand Down
4 changes: 2 additions & 2 deletions backends/rtlil/rtlil_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ void RTLIL_BACKEND::dump_conn(std::ostream &f, std::string indent, const RTLIL::

void RTLIL_BACKEND::dump_module(std::ostream &f, std::string indent, RTLIL::Module *module, RTLIL::Design *design, bool only_selected, bool flag_m, bool flag_n)
{
bool print_header = flag_m || design->selected_whole_module(module->name);
bool print_body = !flag_n || !design->selected_whole_module(module->name);
bool print_header = flag_m || module->is_selected_whole();
bool print_body = !flag_n || !module->is_selected_whole();

if (print_header)
{
Expand Down
4 changes: 2 additions & 2 deletions docs/source/code_examples/extensions/my_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ struct Test2Pass : public Pass {
Test2Pass() : Pass("test2", "demonstrating sigmap on test module") { }
void execute(std::vector<std::string>, RTLIL::Design *design) override
{
if (design->selection_stack.back().empty())
if (design->selection().empty())
log_cmd_error("This command can't operator on an empty selection!\n");

RTLIL::Module *module = design->modules_.at("\\test");
RTLIL::Module *module = design->module("\\test");

RTLIL::SigSpec a(module->wire("\\a")), x(module->wire("\\x")), y(module->wire("\\y"));
log("%d %d %d\n", a == x, x == y, y == a); // will print "0 0 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Use ``log_cmd_error()`` to report a recoverable error:

.. code:: C++

if (design->selection_stack.back().empty())
if (design->selection().empty())
log_cmd_error("This command can't operator on an empty selection!\n");

Use ``log_assert()`` and ``log_abort()`` instead of ``assert()`` and ``abort()``.
Expand Down
2 changes: 1 addition & 1 deletion kernel/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void run(const char *command)
log_last_error = "";
} catch (...) {
while (GetSize(yosys_get_design()->selection_stack) > selSize)
yosys_get_design()->selection_stack.pop_back();
yosys_get_design()->pop_selection();
throw;
}
}
Expand Down
24 changes: 12 additions & 12 deletions kernel/register.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,56 +318,56 @@ void Pass::call(RTLIL::Design *design, std::vector<std::string> args)
pass_register[args[0]]->execute(args, design);
pass_register[args[0]]->post_execute(state);
while (design->selection_stack.size() > orig_sel_stack_pos)
design->selection_stack.pop_back();
design->pop_selection();
}

void Pass::call_on_selection(RTLIL::Design *design, const RTLIL::Selection &selection, std::string command)
{
std::string backup_selected_active_module = design->selected_active_module;
design->selected_active_module.clear();
design->selection_stack.push_back(selection);
design->push_selection(selection);

Pass::call(design, command);

design->selection_stack.pop_back();
design->pop_selection();
design->selected_active_module = backup_selected_active_module;
}

void Pass::call_on_selection(RTLIL::Design *design, const RTLIL::Selection &selection, std::vector<std::string> args)
{
std::string backup_selected_active_module = design->selected_active_module;
design->selected_active_module.clear();
design->selection_stack.push_back(selection);
design->push_selection(selection);

Pass::call(design, args);

design->selection_stack.pop_back();
design->pop_selection();
design->selected_active_module = backup_selected_active_module;
}

void Pass::call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::string command)
{
std::string backup_selected_active_module = design->selected_active_module;
design->selected_active_module = module->name.str();
design->selection_stack.push_back(RTLIL::Selection(false));
design->selection_stack.back().select(module);
design->push_empty_selection();
design->select(module);

Pass::call(design, command);

design->selection_stack.pop_back();
design->pop_selection();
design->selected_active_module = backup_selected_active_module;
}

void Pass::call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::vector<std::string> args)
{
std::string backup_selected_active_module = design->selected_active_module;
design->selected_active_module = module->name.str();
design->selection_stack.push_back(RTLIL::Selection(false));
design->selection_stack.back().select(module);
design->push_empty_selection();
design->select(module);

Pass::call(design, args);

design->selection_stack.pop_back();
design->pop_selection();
design->selected_active_module = backup_selected_active_module;
}

Expand Down Expand Up @@ -745,7 +745,7 @@ void Backend::backend_call(RTLIL::Design *design, std::ostream *f, std::string f
}

while (design->selection_stack.size() > orig_sel_stack_pos)
design->selection_stack.pop_back();
design->pop_selection();
}

struct SimHelper {
Expand Down
Loading
Loading