Skip to content

Commit

Permalink
Support dump exclusion (#1092)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkryukov authored Sep 7, 2019
1 parent 16c098b commit db840c5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ If you still use Python 2, be sure you have `future` package installed: `pip ins
* `-l` — enables per-module output, for instance:
* `-l fetch,decode` — prints only fetch and decode stages
* `-l cpu` — prints all stages
* `-l cpu,!mem` — print all except mem stage
* `-d` — enables output of functional simulator

### Performance mode options
Expand Down
12 changes: 11 additions & 1 deletion simulator/infra/ports/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ void Module::force_enable_logging()
c->force_enable_logging();
}

void Module::force_disable_logging()
{
sout.disable();
for (const auto& c : children)
c->force_disable_logging();
}

void Module::enable_logging_impl( const std::unordered_set<std::string>& names)
{
if ( names.count( name) != 0)
force_enable_logging();
else for ( const auto& c : children)
else if ( names.count( '!' + name) != 0)
force_disable_logging();;

for ( const auto& c : children)
c->enable_logging_impl( names);
}

Expand Down
1 change: 1 addition & 0 deletions simulator/infra/ports/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Module : public Log
private:
virtual std::shared_ptr<PortMap> get_portmap() const { return parent->get_portmap(); }
void force_enable_logging();
void force_disable_logging();

void add_child( Module* module) { children.push_back( module); }

Expand Down
3 changes: 2 additions & 1 deletion simulator/infra/ports/ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ class Port : public Log
{
public:
const std::string& get_key() const noexcept { return k; }
std::shared_ptr<PortMap> get_port_map() const noexcept { return pm; }

protected:
Port( std::shared_ptr<PortMap> port_map, std::string key);
std::shared_ptr<PortMap> get_port_map() const noexcept { return pm; }

Cycle get_last_cycle() const noexcept { return last_cycle; }
void update_last_cycle( Cycle cycle) noexcept
{
Expand Down
11 changes: 11 additions & 0 deletions simulator/infra/ports/t/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,14 @@ TEST_CASE("Module: dump subtrees")
CHECK( h.e->check_if_dumps());
CHECK_FALSE( h.f->check_if_dumps());
}

TEST_CASE("Module: exclusion")
{
SomeHiearchy h( "test-root,!D,!C,F");
CHECK( h.a->check_if_dumps());
CHECK( h.b->check_if_dumps());
CHECK_FALSE( h.c->check_if_dumps());
CHECK_FALSE( h.d->check_if_dumps());
CHECK_FALSE( h.e->check_if_dumps());
CHECK( h.f->check_if_dumps());
}

0 comments on commit db840c5

Please sign in to comment.