From a44ffe57463472fad6fde7e0f39f24e4d98b1929 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 2 Apr 2020 10:17:28 +0100 Subject: [PATCH] Fix GitHub issue #315 - support modpath delays on multiply-driven nets. --- tgt-vvp/draw_net_input.c | 22 +++++++++++++++++----- tgt-vvp/modpath.c | 8 +++++--- tgt-vvp/vvp_priv.h | 4 ++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index 86ec41657..111befd18 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2020 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 @@ -722,9 +722,9 @@ static void draw_net_input_x(ivl_nexus_t nex, char*nex_str = draw_net_input_drive(nex, drivers[0]); char modpath_label[64]; snprintf(modpath_label, sizeof modpath_label, - "V_%p/m", path_sig); + "V_%p_0/m", path_sig); nex_private = strdup(modpath_label); - draw_modpath(path_sig, nex_str); + draw_modpath(path_sig, nex_str, 0); } else { nex_private = draw_net_input_drive(nex, drivers[0]); @@ -745,8 +745,20 @@ static void draw_net_input_x(ivl_nexus_t nex, } driver_labels = malloc(ndrivers * sizeof(char*)); - for (idx = 0; idx < ndrivers; idx += 1) { - driver_labels[idx] = draw_net_input_drive(nex, drivers[idx]); + ivl_signal_t path_sig = find_modpath(nex); + if (path_sig) { + for (idx = 0; idx < ndrivers; idx += 1) { + char*nex_str = draw_net_input_drive(nex, drivers[idx]); + char modpath_label[64]; + snprintf(modpath_label, sizeof modpath_label, + "V_%p_%u/m", path_sig, idx); + driver_labels[idx] = strdup(modpath_label); + draw_modpath(path_sig, nex_str, idx); + } + } else { + for (idx = 0; idx < ndrivers; idx += 1) { + driver_labels[idx] = draw_net_input_drive(nex, drivers[idx]); + } } fprintf(vvp_out, "RS_%p .resolv %s", nex, resolv_type); for (idx = 0; idx < ndrivers; idx += 1) { diff --git a/tgt-vvp/modpath.c b/tgt-vvp/modpath.c index bdaf72e93..7d6ff1015 100644 --- a/tgt-vvp/modpath.c +++ b/tgt-vvp/modpath.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-2020 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 @@ -127,16 +127,18 @@ static void draw_modpath_record(const char*label, const char*driver, struct modpath_item { ivl_signal_t path_sig; char*drive_label; + unsigned drive_index; struct modpath_item*next; }; static struct modpath_item*modpath_list = 0; -void draw_modpath(ivl_signal_t path_sig, char*drive_label) +void draw_modpath(ivl_signal_t path_sig, char*drive_label, unsigned drive_index) { struct modpath_item*cur = calloc(1, sizeof(struct modpath_item)); cur->path_sig = path_sig; cur->drive_label = drive_label; + cur->drive_index = drive_index; cur->next = modpath_list; modpath_list = cur; } @@ -149,7 +151,7 @@ void cleanup_modpath(void) modpath_list = cur->next; - snprintf(modpath_label, sizeof modpath_label, "V_%p/m", cur->path_sig); + snprintf(modpath_label, sizeof modpath_label, "V_%p_%u/m", cur->path_sig, cur->drive_index); draw_modpath_record(modpath_label, cur->drive_label, cur->path_sig); free(cur->drive_label); free(cur); diff --git a/tgt-vvp/vvp_priv.h b/tgt-vvp/vvp_priv.h index c4e725bd9..d34d96b01 100644 --- a/tgt-vvp/vvp_priv.h +++ b/tgt-vvp/vvp_priv.h @@ -1,7 +1,7 @@ #ifndef IVL_vvp_priv_H #define IVL_vvp_priv_H /* - * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2020 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 @@ -120,7 +120,7 @@ extern char* process_octal_codes(const char*txt, unsigned wid); * Note: draw_modpath drive_label must be malloc'ed by the * caller. This function will free the string sometime in the future. */ -extern void draw_modpath(ivl_signal_t path_sig, char*drive_label); +extern void draw_modpath(ivl_signal_t path_sig, char*drive_label, unsigned drive_index); extern void cleanup_modpath(void); /*