From 28bc333cba5c6272c990f8363d3c6f65b5bf8388 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 13 Feb 2013 19:12:54 -0800 Subject: [PATCH] vlog95: block generating a concat-Z LPM device in the compiler. Since the vlog95 code generator needs the strength information we do not want to hide it behind a concat-Z optimization. For now we abort the optimization, but in the future we could add parts of this back in (e.g. all the drivers have matching strength then replace with a normal concat and a buf-Z if the strength are not both strong. The original buf-Z should be removed to reduce the number of LPM devices). --- compiler.h | 6 +++++- main.cc | 6 +++++- netmisc.cc | 13 ++++++++++++- tgt-vlog95/logic_lpm.c | 8 +++++++- tgt-vlog95/vlog95-s.conf | 1 + tgt-vlog95/vlog95.conf | 1 + 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/compiler.h b/compiler.h index fd26fe4bf6..5cfd6dbedd 100644 --- a/compiler.h +++ b/compiler.h @@ -1,7 +1,7 @@ #ifndef __compiler_H #define __compiler_H /* - * Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2013 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 @@ -107,6 +107,10 @@ extern bool debug_optimizer; /* Possibly temporary flag to control virtualization of pin arrays */ extern bool disable_virtual_pins; +/* The vlog95 code generator does not want the compiler to generate concat-Z + * LPM objects so this flag is used to block them from being generated. */ +extern bool disable_concatz_generation; + /* Limit to size of devirtualized arrays */ extern unsigned long array_size_limit; diff --git a/main.cc b/main.cc index 5c2bb207d5..be73a3bd6e 100644 --- a/main.cc +++ b/main.cc @@ -1,5 +1,5 @@ const char COPYRIGHT[] = - "Copyright (c) 1998-2012 Stephen Williams (steve@icarus.com)"; + "Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com)"; /* * This source code is free software; you can redistribute it @@ -175,6 +175,7 @@ bool debug_optimizer = false; bool disable_virtual_pins = false; unsigned long array_size_limit = 16777216; // Minimum required by IEEE-1364? unsigned recursive_mod_limit = 10; +bool disable_concatz_generation = false; /* * Verbose messages enabled. @@ -967,6 +968,9 @@ int main(int argc, char*argv[]) flag_tmp = flags["RECURSIVE_MOD_LIMIT"]; if (flag_tmp) recursive_mod_limit = strtoul(flag_tmp,NULL,0); + flag_tmp = flags["DISABLE_CONCATZ_GENERATION"]; + if (flag_tmp) disable_concatz_generation = strcmp(flag_tmp,"true")==0; + /* Parse the input. Make the pform. */ pform_set_timescale(def_ts_units, def_ts_prec, 0, 0); int rc = pform_parse(argv[optind]); diff --git a/netmisc.cc b/netmisc.cc index 98e90ed47f..783c9a5068 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2013 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 @@ -1127,6 +1127,17 @@ void collapse_partselect_pv_to_concat(Design*des, NetNet*sig) ivl_assert(*sig, idx == ps_map.size()); + /* The vlog95 and possibly other code generators do not want + * to have a group of part selects turned into a transparent + * concatenation. */ + if (disable_concatz_generation) { +// HERE: If the part selects have matching strengths then we can use +// a normal concat with a buf-Z after if the strengths are not +// both strong. We would ideally delete any buf-Z driving the +// concat, but that is not required for the vlog95 generator. + return; + } + // Ah HAH! The NetPartSelect::PV objects exactly cover the // target signal. We can replace all of them with a single // concatenation. diff --git a/tgt-vlog95/logic_lpm.c b/tgt-vlog95/logic_lpm.c index 34d8cb78ff..40be840b31 100644 --- a/tgt-vlog95/logic_lpm.c +++ b/tgt-vlog95/logic_lpm.c @@ -888,8 +888,14 @@ static void emit_lpm_as_ca(ivl_scope_t scope, ivl_lpm_t lpm) emit_nexus_as_ca(scope, ivl_lpm_data(lpm, 1), 0); fprintf(vlog_out, ")"); break; - case IVL_LPM_CONCAT: + /* A concat-Z should never be generated, but report it as an + * error if one is generated. */ case IVL_LPM_CONCATZ: + fprintf(stderr, "%s:%u: vlog95 error: Transparent concatenations " + "should not be generated.\n", + ivl_lpm_file(lpm), ivl_lpm_lineno(lpm)); + vlog_errors += 1; + case IVL_LPM_CONCAT: emit_lpm_concat(scope, lpm); break; case IVL_LPM_DIVIDE: diff --git a/tgt-vlog95/vlog95-s.conf b/tgt-vlog95/vlog95-s.conf index 19573a9446..04e49e471b 100644 --- a/tgt-vlog95/vlog95-s.conf +++ b/tgt-vlog95/vlog95-s.conf @@ -2,3 +2,4 @@ functor:synth2 functor:synth functor:syn-rules flag:DLL=vlog95.tgt +flag:DISABLE_CONCATZ_GENERATION=true diff --git a/tgt-vlog95/vlog95.conf b/tgt-vlog95/vlog95.conf index ee96d5cb38..362c35c6ce 100644 --- a/tgt-vlog95/vlog95.conf +++ b/tgt-vlog95/vlog95.conf @@ -1 +1,2 @@ flag:DLL=vlog95.tgt +flag:DISABLE_CONCATZ_GENERATION=true