From 4af28c75267cbd2110e9340a0ac235ef2af3bce2 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 1 Sep 2007 14:38:57 -0700 Subject: [PATCH 1/3] Signed divide of 32bit values Signed divide of 32bit values can overflow if done in a 32bit long due to the truncation of sign bits. So use the large value algorithm if the values are >= 31 bits (63 bits on 64bit machines). Signed-off-by: Stephen Williams --- verinum.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verinum.cc b/verinum.cc index 7e50f5a1d..d651aaf1d 100644 --- a/verinum.cc +++ b/verinum.cc @@ -947,7 +947,7 @@ verinum operator / (const verinum&left, const verinum&right) result is signed or not. */ if (result.has_sign()) { - if (use_len <= 8*sizeof(long)) { + if (use_len <= (8*sizeof(long) - 1)) { long l = left.as_long(); long r = right.as_long(); long v = l / r; From 59af5d08b7a517a93a0dc9a0c8f535d5dd2d7134 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 1 Sep 2007 15:00:53 -0700 Subject: [PATCH 2/3] More portable encoding of vectors Slight modification to the description of a vector vareable in the declarations section for the convenience of 3rd party VCD viewers. --- vpi/sys_vcd.c | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 6270bb782..70217ef2d 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -549,7 +549,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) */ if (vpi_get(vpiSize, item) > 1 || vpi_get(vpiLeftRange, item) != 0) { - fprintf(dump_file, "[%i:%i]", vpi_get(vpiLeftRange, item), + fprintf(dump_file, " [%i:%i]", vpi_get(vpiLeftRange, item), vpi_get(vpiRightRange, item)); } fprintf(dump_file, " $end\n"); @@ -833,48 +833,3 @@ void sys_vcd_register() vpi_register_systf(&tf_data); } -/* - * $Log: sys_vcd.c,v $ - * Revision 1.58 2007/03/14 04:05:51 steve - * VPI tasks take PLI_BYTE* by the standard. - * - * Revision 1.57 2006/10/30 22:45:38 steve - * Updates for Cygwin portability (pr1585922) - * - * Revision 1.56 2004/10/04 01:10:58 steve - * Clean up spurious trailing white space. - * - * Revision 1.55 2004/02/15 20:46:01 steve - * Add the $dumpflush function - * - * Revision 1.54 2004/02/15 03:17:15 steve - * dumpfile selects file at compiletf time. - * - * Revision 1.53 2004/01/21 01:22:53 steve - * Give the vip directory its own configure and vpi_config.h - * - * Revision 1.52 2003/12/19 01:27:10 steve - * Fix various unsigned compare warnings. - * - * Revision 1.51 2003/10/29 03:28:27 steve - * Add the PLU_UINT64_FMT string for formatting output. - * - * Revision 1.50 2003/10/29 03:23:12 steve - * Portably handle time format of VCD prints. - * - * Revision 1.49 2003/10/08 23:14:29 steve - * TIME_FMT does not include the % character. - * - * Revision 1.48 2003/10/02 21:30:06 steve - * Use configured TIME_FMT in vcd dump printf. - * - * Revision 1.47 2003/09/30 01:33:39 steve - * dumpers must be aware of 64bit time. - * - * Revision 1.46 2003/08/22 23:14:27 steve - * Preserve variable ranges all the way to the vpi. - * - * Revision 1.45 2003/08/06 18:24:55 steve - * Fix error truncating bitvec in output. - */ - From 963b26283afc94e50be61122ea044ec7f0d7728f Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 1 Sep 2007 15:06:53 -0700 Subject: [PATCH 3/3] Generate scopes are more like begin-end scopes Apparently making generate scopes look like module instances confuses some 3rd party tools that see this information in the VCD dump. --- vvp/vpi_scope.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index b9203118d..4eaf21060 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2007 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 @@ -328,9 +328,7 @@ compile_scope_decl(char*label, char*type, char*name, char*tname, char*parent) else if (strcmp(type,"begin") == 0) scope->base.vpi_type = &vpip_scope_begin_rt; else if (strcmp(type,"generate") == 0) - // Generate blocks are not really modules, but this is a - // hack that will work for now. - scope->base.vpi_type = &vpip_scope_module_rt; + scope->base.vpi_type = &vpip_scope_begin_rt; else { scope->base.vpi_type = &vpip_scope_module_rt; assert(0);