2018-07-05 03:52:15 +02:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Estimate instruction count to run the logic
|
|
|
|
|
// we would generate for any given AST subtree.
|
|
|
|
|
//
|
2019-11-08 04:33:59 +01:00
|
|
|
// Code available from: https://verilator.org
|
2018-07-05 03:52:15 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2020-03-21 16:24:24 +01:00
|
|
|
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you
|
|
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2018-07-05 03:52:15 +02:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2018-07-05 03:52:15 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
2019-10-05 02:17:11 +02:00
|
|
|
|
2019-12-30 04:04:03 +01:00
|
|
|
#ifndef _V3INSTRCOUNT_H_
|
|
|
|
|
#define _V3INSTRCOUNT_H_ 1
|
|
|
|
|
|
2018-07-05 03:52:15 +02:00
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
|
|
|
|
|
|
|
|
|
class AstNode;
|
|
|
|
|
|
2020-11-19 03:32:16 +01:00
|
|
|
class V3InstrCount final {
|
2018-07-05 03:52:15 +02:00
|
|
|
public:
|
|
|
|
|
// Return the estimate count of instructions we'd incur while running
|
|
|
|
|
// code in and under nodep.
|
|
|
|
|
//
|
|
|
|
|
// This is a rough estimate; we don't know what path we'll take through
|
|
|
|
|
// conditionals in nodep, so we assume we take the longest path.
|
|
|
|
|
//
|
|
|
|
|
// If nodep is an AstActive, returns 0.
|
|
|
|
|
// If nodep contains nested AstActives, raises an error.
|
|
|
|
|
//
|
|
|
|
|
// If assertNoDups is true, marks user5 on each AstNode scanned. Then
|
|
|
|
|
// if we see the same node twice (across more than one call to count,
|
|
|
|
|
// potentially) raises an error.
|
2018-07-14 23:31:36 +02:00
|
|
|
// Optional osp is stream to dump critical path to.
|
2020-08-15 16:12:55 +02:00
|
|
|
static uint32_t count(AstNode* nodep, bool assertNoDups, std::ostream* osp = nullptr);
|
2018-07-05 03:52:15 +02:00
|
|
|
};
|
2019-12-30 04:04:03 +01:00
|
|
|
|
|
|
|
|
#endif // guard
|