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

ALAP in depth_view #555

Open
lee30sonia opened this issue Jun 23, 2022 · 0 comments
Open

ALAP in depth_view #555

lee30sonia opened this issue Jun 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@lee30sonia
Copy link
Member

I implemented a draft (but not complete -- consideration of inverter cost is missing, and maybe some more details, plus documentation and tests etc. are also missing) during research but didn't need it in the end, so just to keep a back-up here in case someone decides that it's useful and makes a PR in the future.

As a public member function of depth_view:

  void ALAP()
  {
    _levels.reset( 0 );
    this->incr_trav_id();

    this->foreach_po( [&]( auto const& f ) {
      const auto n = this->get_node( f );
      if ( !this->is_constant( n ) && this->visited( n ) != this->trav_id() && !this->is_pi( n ) )
      {
        _levels[n] = _depth;
        compute_levels_ALAP( n );
      }
    } );
  }

As a private member function of depth_view:

  void compute_levels_ALAP( node const& n )
  {
    this->set_visited( n, this->trav_id() );

    this->foreach_fanin( n, [&]( auto const& fi ) {
      auto const ni = this->get_node( fi );
      if ( !this->is_constant( ni ) && !this->is_pi( ni ) )
      {
        assert( _levels[n] >= _cost_fn( *this, ni ) );
        auto fi_level = _levels[n] - _cost_fn( *this, ni );
        if ( this->visited( ni ) != this->trav_id() || _levels[ni] > fi_level )
        {
          _levels[ni] = fi_level;
          compute_levels_ALAP( ni );
        }
      }
    } );
  }
@lee30sonia lee30sonia added the enhancement New feature or request label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant