diff --git a/ivl_target.h b/ivl_target.h index 038a504cb..c766f4fcd 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -495,7 +495,7 @@ extern int ivl_path_source_negedge(ivl_delaypath_t obj); * * ivl_design_flag * This function returns the string value of a named flag. Flags - * come from the "-fkey=value" options to the iverilog command and + * come from the "-pkey=value" options to the iverilog command and * are stored in a map for this function. Given the key, this * function returns the value. * diff --git a/tgt-vlog95/vlog95.c b/tgt-vlog95/vlog95.c index 26bb36e63..1e6b3f7c1 100644 --- a/tgt-vlog95/vlog95.c +++ b/tgt-vlog95/vlog95.c @@ -25,6 +25,7 @@ # include "version_tag.h" # include "config.h" # include "vlog95_priv.h" +# include # include static const char*version_string = @@ -56,8 +57,43 @@ int target_design(ivl_design_t des) ivl_scope_t *roots; unsigned nroots, idx; const char*path = ivl_design_flag(des, "-o"); + /* Set the indent spacing with the -pspacing flag passed to iverilog + * (e.g. -pspacing=4). */ + const char*spacing = ivl_design_flag(des, "spacing"); assert(path); + /* Check for and use a provided indent spacing. */ + if (strcmp(spacing, "") != 0) { + char *eptr; + long sp_incr = strtol(spacing, &eptr, 0); + /* Nothing usable in the spacing string. */ + if (spacing == eptr) { + fprintf(stderr, "vlog95 error: Unable to extract spacing " + "increment from string: %s\n", spacing); + return 1; + } + /* Extra stuff at the end. */ + if (*eptr != 0) { + fprintf(stderr, "vlog95 error: Extra characters '%s' " + "included at end of spacing string: %s\n", + eptr, spacing); + return 1; + } + /* The increment must be positive. */ + if (sp_incr < 1) { + fprintf(stderr, "vlog95 error: Spacing increment (%ld) must " + "be greater than zero.\n", sp_incr); + return 1; + } + /* An increment of more than sixteen is too much. */ + if (sp_incr > 16) { + fprintf(stderr, "vlog95 error: Spacing increment (%ld) must " + "be sixteen or less.\n", sp_incr); + return 1; + } + indent_incr = sp_incr; + } + design = des; #ifdef HAVE_FOPEN64