Skip to content

Commit

Permalink
vlog95: block generating a concat-Z LPM device in the compiler.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
caryr committed Feb 14, 2013
1 parent 8b4dc05 commit 28bc333
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
6 changes: 5 additions & 1 deletion compiler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __compiler_H
#define __compiler_H
/*
* Copyright (c) 1999-2011 Stephen Williams ([email protected])
* Copyright (c) 1999-2013 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const char COPYRIGHT[] =
"Copyright (c) 1998-2012 Stephen Williams ([email protected])";
"Copyright (c) 1998-2013 Stephen Williams ([email protected])";

/*
* This source code is free software; you can redistribute it
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]);
Expand Down
13 changes: 12 additions & 1 deletion netmisc.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2012 Stephen Williams ([email protected])
* Copyright (c) 2001-2013 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion tgt-vlog95/logic_lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tgt-vlog95/vlog95-s.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ functor:synth2
functor:synth
functor:syn-rules
flag:DLL=vlog95.tgt
flag:DISABLE_CONCATZ_GENERATION=true
1 change: 1 addition & 0 deletions tgt-vlog95/vlog95.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flag:DLL=vlog95.tgt
flag:DISABLE_CONCATZ_GENERATION=true

0 comments on commit 28bc333

Please sign in to comment.