From d3d54144ffb964563d3409872a32a571761a243d Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 13 Sep 2008 20:22:48 -0700 Subject: [PATCH] Be more explicit with the type matching rules. Signals of a nexus must have types that exactly match, but the drivers of a signal nexus have slightly more subtle rules for the case where the signal is IVL_VT_LOGIC. Express those rules in the function check_signal_drive_type, and use it to check the type of constants driving a signal. --- tgt-stub/stub.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 21c27df08..c3e637b05 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -149,6 +149,26 @@ const char*data_type_string(ivl_variable_type_t vtype) return vt; } +/* + * The compiler will check the types of drivers to signals and will + * only connect outputs to signals that are compatible. This function + * shows the type compatibility that the compiler enforces at the + * ivl_target.h level. + */ +static int check_signal_drive_type(ivl_variable_type_t sig_type, + ivl_variable_type_t driver_type) +{ + if (sig_type == IVL_VT_LOGIC && driver_type == IVL_VT_BOOL) + return !0; + if (sig_type == IVL_VT_LOGIC && driver_type == IVL_VT_LOGIC) + return !0; + if (sig_type == IVL_VT_BOOL && driver_type == IVL_VT_BOOL) + return !0; + if (sig_type == driver_type) + return !0; + return 0; +} + /* * The compare-like LPM nodes have input widths that match the * ivl_lpm_width() value, and an output width of 1. This function @@ -1084,7 +1104,10 @@ static void signal_nexus_const(ivl_signal_t sig, stub_errors += 1; } - if (ivl_signal_data_type(sig) != ivl_const_type(con)) { + int drive_type_ok = check_signal_drive_type(ivl_signal_data_type(sig), + ivl_const_type(con)); + + if (! drive_type_ok) { fprintf(out, "ERROR: Signal data type does not match" " literal type.\n"); stub_errors += 1;