iverilog/tgt-sizer/scan_lpms.cc

60 lines
1.8 KiB
C++
Raw Normal View History

2014-02-08 19:16:11 +01:00
/*
* Copyright (c) 2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "sizer_priv.h"
2014-02-09 03:53:42 +01:00
static void scan_lpms_ff(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats)
2014-02-08 19:16:11 +01:00
{
ivl_nexus_t out = ivl_lpm_q(lpm);
unsigned wid = get_nexus_width(out);
stats.flop_count += wid;
}
void scan_lpms(ivl_scope_t scope, struct sizer_statistics&stats)
{
for (unsigned idx = 0 ; idx < ivl_scope_lpms(scope) ; idx += 1) {
ivl_lpm_t lpm = ivl_scope_lpm(scope,idx);
switch (ivl_lpm_type(lpm)) {
2014-02-09 03:53:42 +01:00
// Part select nodes don't actually take up
// hardware. These represent things like bundle
// manipulations, which are done in routing.
case IVL_LPM_PART_VP:
case IVL_LPM_PART_PV:
case IVL_LPM_CONCAT:
case IVL_LPM_CONCATZ:
case IVL_LPM_REPEAT:
break;
case IVL_LPM_ADD:
stats.adder_count += 1;
break;
// D-Type flip-flops.
2014-02-08 19:16:11 +01:00
case IVL_LPM_FF:
scan_lpms_ff(scope, lpm, stats);
break;
2014-02-09 03:53:42 +01:00
2014-02-08 19:16:11 +01:00
default:
stats.lpm_unknown += 1;
break;
}
}
}