Sizer recognizes more LPM types.

This commit is contained in:
Stephen Williams 2014-05-25 19:38:12 -07:00
parent ef79f538d5
commit 579b59b8eb
4 changed files with 105 additions and 3 deletions

View File

@ -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:

View File

@ -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;

View File

@ -156,7 +156,22 @@ static void show_stats(struct sizer_statistics&stats)
for (map<unsigned,unsigned>::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<unsigned,unsigned>::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<unsigned,unsigned>::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<unsigned,unsigned>::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<unsigned,unsigned>::const_iterator cur = that.equality_count.begin()
; cur != that.equality_count.end() ; ++ cur)
equality_count[cur->first] += cur->second;
for (map<unsigned,unsigned>::const_iterator cur = that.magnitude_count.begin()
; cur != that.magnitude_count.end() ; ++ cur)
magnitude_count[cur->first] += cur->second;
for (map<unsigned,unsigned>::const_iterator cur = that.mux_count.begin()
; cur != that.mux_count.end() ; ++ cur)
mux_count[cur->first] += cur->second;
for (map<ivl_lpm_type_t,unsigned>::const_iterator cur = that.lpm_bytype.begin()
; cur != that.lpm_bytype.end() ; ++ cur)

View File

@ -31,6 +31,12 @@ struct sizer_statistics {
unsigned gate_count;
// Count adders of various dimension
std::map<unsigned,unsigned> adder_count;
// count equality comparators
std::map<unsigned,unsigned> equality_count;
// Count magnitude comparators
std::map<unsigned,unsigned> magnitude_count;
// Count mux's of various dimension
std::map<unsigned,unsigned> mux_count;
// Different kinds of nodes that we have not accounted for
std::map<ivl_lpm_type_t,unsigned> lpm_bytype;
std::map<ivl_logic_t,unsigned> log_bytype;