From 746a21b437b25e0a2f82b57177d2aafd1bce07db Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 5 Sep 2011 17:23:22 -0700 Subject: [PATCH] Update the $random routines to allow an int, long or bit as a seed. Modify the $random code to allow the seed to be either an int, long or bit that is 32 bits or longer. The 32 bit check is new and also applies to reg/logic variables. --- vpi/sys_random.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/vpi/sys_random.c b/vpi/sys_random.c index 67d10ad9a..2193b3140 100644 --- a/vpi/sys_random.c +++ b/vpi/sys_random.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2011 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 @@ -374,9 +374,22 @@ static unsigned is_seed_obj(vpiHandle obj, vpiHandle callh, const char *name) switch (vpi_get(vpiType, obj)) { case vpiTimeVar: case vpiIntegerVar: - case vpiReg: + case vpiIntVar: + case vpiLongIntVar: rtn = 1; break; + case vpiBitVar: + case vpiReg: + if (vpi_get(vpiSize, obj) < 32) { + vpi_printf("Error: %s:%d: ", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + vpi_printf("%s's seed variable is less than 32 bits " + " (%d).\n", name, + (int)vpi_get(vpiSize, obj)); + vpi_control(vpiFinish, 1); + } else rtn = 1; + break; default: vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh));