From 579b59b8eb2985409bd24bcc2e1748190ef49da4 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 25 May 2014 19:38:12 -0700 Subject: [PATCH] Sizer recognizes more LPM types. --- tgt-sizer/scan_logs.cc | 5 ++++ tgt-sizer/scan_lpms.cc | 67 ++++++++++++++++++++++++++++++++++++++++-- tgt-sizer/sizer.cc | 30 ++++++++++++++++++- tgt-sizer/sizer_priv.h | 6 ++++ 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/tgt-sizer/scan_logs.cc b/tgt-sizer/scan_logs.cc index 82a4df0d9..0269543ad 100644 --- a/tgt-sizer/scan_logs.cc +++ b/tgt-sizer/scan_logs.cc @@ -32,6 +32,11 @@ void scan_logs(ivl_scope_t scope, struct sizer_statistics&stats) for (unsigned idx = 0 ; idx < ivl_scope_logs(scope) ; idx += 1) { ivl_net_logic_t log = ivl_scope_log(scope, idx); switch (ivl_logic_type(log)) { + // These logic gate types don't really exist in a + // mapped design. + case IVL_LO_BUFZ: + break; + case IVL_LO_AND: case IVL_LO_OR: case IVL_LO_XOR: diff --git a/tgt-sizer/scan_lpms.cc b/tgt-sizer/scan_lpms.cc index 6298d1275..a5c6b5aae 100644 --- a/tgt-sizer/scan_lpms.cc +++ b/tgt-sizer/scan_lpms.cc @@ -37,7 +37,7 @@ static void scan_lpms_ff(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&sta * Count adders as 2m gates. * Also keep a count of adders by width, just out of curiosity. */ -static void scans_lpms_add(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) +static void scan_lpms_add(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) { unsigned wid = ivl_lpm_width(lpm); @@ -46,8 +46,35 @@ static void scans_lpms_add(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&s stats.gate_count += 2*wid; } +/* + * Count equality comparator as 2m gates. + * Also keep a count of comparators by width, just out of curiosity. + */ +static void scan_lpms_equality(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) +{ + unsigned wid = ivl_lpm_width(lpm); + + stats.equality_count[wid] += 1; + + stats.gate_count += 2*wid; +} + +/* + * Count magnitude comparators as 2m gates. + * Also keep a count of comparators by width, just out of curiosity. + */ +static void scan_lpms_magnitude(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) +{ + unsigned wid = ivl_lpm_width(lpm); + + stats.magnitude_count[wid] += 1; + + stats.gate_count += 2*wid; +} + /* * Count mux devices as 2m gates. + * Also count the mux slices of various select sizes. */ static void scan_lpms_mux(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) { @@ -57,10 +84,25 @@ static void scan_lpms_mux(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&st return; } + // The "width" of a mux is the number of 1-bit slices. unsigned wid = ivl_lpm_width(lpm); + + // Count the slices of the various width of muxes. + stats.mux_count[2] += wid; + stats.gate_count += 2*wid; } +/* + * Count reduction gates (wide input gates) as 1m gates. + */ +static void scan_lpms_reduction(ivl_scope_t, ivl_lpm_t lpm, struct sizer_statistics&stats) +{ + unsigned wid = ivl_lpm_width(lpm); + + stats.gate_count += wid; +} + void scan_lpms(ivl_scope_t scope, struct sizer_statistics&stats) { for (unsigned idx = 0 ; idx < ivl_scope_lpms(scope) ; idx += 1) { @@ -77,7 +119,19 @@ void scan_lpms(ivl_scope_t scope, struct sizer_statistics&stats) break; case IVL_LPM_ADD: - scans_lpms_add(scope, lpm, stats); + scan_lpms_add(scope, lpm, stats); + break; + + case IVL_LPM_CMP_EQ: + case IVL_LPM_CMP_NE: + case IVL_LPM_CMP_EEQ: + case IVL_LPM_CMP_NEE: + scan_lpms_equality(scope, lpm, stats); + break; + + case IVL_LPM_CMP_GE: + case IVL_LPM_CMP_GT: + scan_lpms_magnitude(scope, lpm, stats); break; // D-Type flip-flops. @@ -89,6 +143,15 @@ void scan_lpms(ivl_scope_t scope, struct sizer_statistics&stats) scan_lpms_mux(scope, lpm, stats); break; + case IVL_LPM_RE_AND: + case IVL_LPM_RE_NAND: + case IVL_LPM_RE_OR: + case IVL_LPM_RE_NOR: + case IVL_LPM_RE_XOR: + case IVL_LPM_RE_XNOR: + scan_lpms_reduction(scope, lpm, stats); + break; + default: stats.lpm_bytype[ivl_lpm_type(lpm)] += 1; break; diff --git a/tgt-sizer/sizer.cc b/tgt-sizer/sizer.cc index 2c985dd3a..a729e6f2b 100644 --- a/tgt-sizer/sizer.cc +++ b/tgt-sizer/sizer.cc @@ -156,7 +156,22 @@ static void show_stats(struct sizer_statistics&stats) for (map::const_iterator cur = stats.adder_count.begin() ; cur != stats.adder_count.end() ; ++ cur) { - fprintf(sizer_out, " ADDER[%u]: %u\n", cur->first, cur->second); + fprintf(sizer_out, " ADDER[%u]: %u units\n", cur->first, cur->second); + } + + for (map::const_iterator cur = stats.equality_count.begin() + ; cur != stats.equality_count.end() ; ++ cur) { + fprintf(sizer_out, " EQUALITY[%u]: %u units\n", cur->first, cur->second); + } + + for (map::const_iterator cur = stats.magnitude_count.begin() + ; cur != stats.magnitude_count.end() ; ++ cur) { + fprintf(sizer_out, " MAGNITUDE[%u]: %u units\n", cur->first, cur->second); + } + + for (map::const_iterator cur = stats.mux_count.begin() + ; cur != stats.mux_count.end() ; ++ cur) { + fprintf(sizer_out, " MUX[%u]: %u slices\n", cur->first, cur->second); } // These are diagnostic outputs for when more detail is needed. @@ -195,6 +210,19 @@ struct sizer_statistics& sizer_statistics::operator += (const sizer_statistics&t ; cur != that.adder_count.end() ; ++ cur) adder_count[cur->first] += cur->second; + for (map::const_iterator cur = that.equality_count.begin() + ; cur != that.equality_count.end() ; ++ cur) + equality_count[cur->first] += cur->second; + + for (map::const_iterator cur = that.magnitude_count.begin() + ; cur != that.magnitude_count.end() ; ++ cur) + magnitude_count[cur->first] += cur->second; + + + for (map::const_iterator cur = that.mux_count.begin() + ; cur != that.mux_count.end() ; ++ cur) + mux_count[cur->first] += cur->second; + for (map::const_iterator cur = that.lpm_bytype.begin() ; cur != that.lpm_bytype.end() ; ++ cur) diff --git a/tgt-sizer/sizer_priv.h b/tgt-sizer/sizer_priv.h index 3732e3174..85ca43cb9 100644 --- a/tgt-sizer/sizer_priv.h +++ b/tgt-sizer/sizer_priv.h @@ -31,6 +31,12 @@ struct sizer_statistics { unsigned gate_count; // Count adders of various dimension std::map adder_count; + // count equality comparators + std::map equality_count; + // Count magnitude comparators + std::map magnitude_count; + // Count mux's of various dimension + std::map mux_count; // Different kinds of nodes that we have not accounted for std::map lpm_bytype; std::map log_bytype;