Add support for a generate scope to vvp and the vpi routines.

Instead of just translating a generate scope to a named begin/end scope
this patch creates a generate specific scope (vpiScopeGenerate) that is
of the vpiGenScope type. This may not match the standard 100%, but does
allow the FST dumper to denote generate scopes differently than the
other scope types. Most of the VPI code treats a vpiGenScope just like a
named block so only the FST dumper should have different behavior.
This commit is contained in:
Cary R 2013-07-17 10:55:46 -07:00
parent f636ffde48
commit 54cb85adfc
12 changed files with 68 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002-2009 Michael Ruff (mruff at chiaro.com) * Copyright (c) 2002-2013 Michael Ruff (mruff at chiaro.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -45,7 +45,7 @@ int acc_object_of_type(handle object, PLI_INT32 type)
case accScope: case accScope:
if (vtype == vpiModule || vtype == vpiNamedBegin || if (vtype == vpiModule || vtype == vpiNamedBegin ||
vtype == vpiNamedFork || vtype == vpiTask || vtype == vpiNamedFork || vtype == vpiTask ||
vtype == vpiFunction) rtn = 1; vtype == vpiFunction || vtype == vpiGenScope) rtn = 1;
break; break;
case accNet: rtn = vtype == vpiNet; break; case accNet: rtn = vtype == vpiNet; break;

View File

@ -1863,6 +1863,7 @@ static PLI_INT32 sys_printtimescale_compiletf(ICARUS_VPI_CONST PLI_BYTE8*name)
vpiHandle arg = vpi_scan(argv); vpiHandle arg = vpi_scan(argv);
switch (vpi_get(vpiType, arg)) { switch (vpi_get(vpiType, arg)) {
case vpiFunction: case vpiFunction:
case vpiGenScope:
case vpiIntegerVar: case vpiIntegerVar:
case vpiBitVar: case vpiBitVar:
case vpiByteVar: case vpiByteVar:

View File

@ -469,7 +469,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
struct t_cb_data cb; struct t_cb_data cb;
struct vcd_info* info; struct vcd_info* info;
PLI_INT32 type; enum fstVarType type = FST_VT_VCD_MAX;
enum fstScopeType stype = FST_ST_VCD_MAX;
enum fstVarDir dir;
const char *name; const char *name;
const char *fullname; const char *fullname;
char *escname; char *escname;
@ -514,11 +516,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
} }
break; break;
case vpiNamedBegin: type = FST_ST_VCD_BEGIN; break; case vpiNamedBegin: stype = FST_ST_VCD_BEGIN; break;
case vpiNamedFork: type = FST_ST_VCD_FORK; break; case vpiNamedFork: stype = FST_ST_VCD_FORK; break;
case vpiFunction: type = FST_ST_VCD_FUNCTION; break; case vpiFunction: stype = FST_ST_VCD_FUNCTION; break;
case vpiModule: type = FST_ST_VCD_MODULE; break; case vpiGenScope: stype = FST_ST_VCD_GENERATE; break;
case vpiTask: type = FST_ST_VCD_TASK; break; case vpiModule: stype = FST_ST_VCD_MODULE; break;
case vpiTask: stype = FST_ST_VCD_TASK; break;
default: default:
vpi_printf("FST warning: $dumpvars: Unsupported argument " vpi_printf("FST warning: $dumpvars: Unsupported argument "
@ -596,20 +599,24 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
* zero so we will also use a width of one for events. */ * zero so we will also use a width of one for events. */
if (item_type == vpiNamedEvent) size = 1; if (item_type == vpiNamedEvent) size = 1;
else size = vpi_get(vpiSize, item); else size = vpi_get(vpiSize, item);
/* The FST format supports a port direction so if the net
* is a port set the direction to one of the following:
* FST_VD_INPUT, FST_VD_OUTPUT or FST_VD_INOUT */
dir = FST_VD_IMPLICIT;
if (size > 1 || vpi_get(vpiLeftRange, item) != 0) { if (size > 1 || vpi_get(vpiLeftRange, item) != 0) {
char *buf = malloc(strlen(escname) + 65); char *buf = malloc(strlen(escname) + 65);
sprintf(buf, "%s [%i:%i]", escname, sprintf(buf, "%s [%i:%i]", escname,
(int)vpi_get(vpiLeftRange, item), (int)vpi_get(vpiLeftRange, item),
(int)vpi_get(vpiRightRange, item)); (int)vpi_get(vpiRightRange, item));
new_ident = fstWriterCreateVar(dump_file, type, new_ident = fstWriterCreateVar(dump_file, type,
FST_VD_IMPLICIT, size, buf, dir, size, buf,
(fstHandle)(long)ident); (fstHandle)(long)ident);
free(buf); free(buf);
} else { } else {
new_ident = fstWriterCreateVar(dump_file, type, new_ident = fstWriterCreateVar(dump_file, type,
FST_VD_IMPLICIT, size, escname, dir, size, escname,
(fstHandle)(long)ident); (fstHandle)(long)ident);
} }
free(escname); free(escname);
@ -643,9 +650,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break; break;
case vpiModule: case vpiModule:
case vpiNamedBegin: case vpiGenScope:
case vpiTask:
case vpiFunction: case vpiFunction:
case vpiTask:
case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
if (depth > 0) { if (depth > 0) {
@ -660,6 +668,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpiVariables, vpiVariables,
/* Scope */ /* Scope */
vpiFunction, vpiFunction,
vpiGenScope,
vpiModule, vpiModule,
vpiNamedBegin, vpiNamedBegin,
vpiNamedFork, vpiNamedFork,
@ -689,7 +698,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
free(defname); free(defname);
defname = NULL; defname = NULL;
} }
fstWriterSetScope(dump_file, type, name, defname); fstWriterSetScope(dump_file, stype, name, defname);
free(defname); free(defname);
for (i=0; types[i]>0; i++) { for (i=0; types[i]>0; i++) {
@ -734,10 +743,11 @@ static int draw_scope(vpiHandle item, vpiHandle callh)
switch (scope_type) { switch (scope_type) {
case vpiNamedBegin: type = FST_ST_VCD_BEGIN; break; case vpiNamedBegin: type = FST_ST_VCD_BEGIN; break;
case vpiTask: type = FST_ST_VCD_TASK; break;
case vpiFunction: type = FST_ST_VCD_FUNCTION; break; case vpiFunction: type = FST_ST_VCD_FUNCTION; break;
case vpiNamedFork: type = FST_ST_VCD_FORK; break; case vpiNamedFork: type = FST_ST_VCD_FORK; break;
case vpiGenScope: type = FST_ST_VCD_GENERATE; break;
case vpiModule: type = FST_ST_VCD_MODULE; break; case vpiModule: type = FST_ST_VCD_MODULE; break;
case vpiTask: type = FST_ST_VCD_TASK; break;
default: default:
type = FST_ST_VCD_MODULE; type = FST_ST_VCD_MODULE;
vpi_printf("FST Error: %s:%d: $dumpvars: Unsupported scope " vpi_printf("FST Error: %s:%d: $dumpvars: Unsupported scope "

View File

@ -640,9 +640,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break; break;
case vpiModule: case vpiModule:
case vpiNamedBegin: case vpiGenScope:
case vpiTask:
case vpiFunction: case vpiFunction:
case vpiTask:
case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
if (depth > 0) { if (depth > 0) {
@ -657,6 +658,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpiVariables, vpiVariables,
/* Scope */ /* Scope */
vpiFunction, vpiFunction,
vpiGenScope,
vpiModule, vpiModule,
vpiNamedBegin, vpiNamedBegin,
vpiNamedFork, vpiNamedFork,

View File

@ -695,9 +695,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break; break;
case vpiModule: case vpiModule:
case vpiNamedBegin: case vpiGenScope:
case vpiTask:
case vpiFunction: case vpiFunction:
case vpiTask:
case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
if (depth > 0) { if (depth > 0) {
@ -712,6 +713,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpiVariables, vpiVariables,
/* Scope */ /* Scope */
vpiFunction, vpiFunction,
vpiGenScope,
vpiModule, vpiModule,
vpiNamedBegin, vpiNamedBegin,
vpiNamedFork, vpiNamedFork,

View File

@ -545,6 +545,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break; break;
case vpiNamedBegin: type = "begin"; break; case vpiNamedBegin: type = "begin"; break;
case vpiGenScope: type = "begin"; break;
case vpiNamedFork: type = "fork"; break; case vpiNamedFork: type = "fork"; break;
case vpiFunction: type = "function"; break; case vpiFunction: type = "function"; break;
case vpiModule: type = "module"; break; case vpiModule: type = "module"; break;
@ -667,9 +668,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break; break;
case vpiModule: case vpiModule:
case vpiNamedBegin: case vpiGenScope:
case vpiTask:
case vpiFunction: case vpiFunction:
case vpiTask:
case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
if (depth > 0) { if (depth > 0) {
@ -683,6 +685,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpiVariables, vpiVariables,
/* Scope */ /* Scope */
vpiFunction, vpiFunction,
vpiGenScope,
vpiModule, vpiModule,
vpiNamedBegin, vpiNamedBegin,
vpiNamedFork, vpiNamedFork,
@ -733,6 +736,7 @@ static int draw_scope(vpiHandle item, vpiHandle callh)
switch (vpi_get(vpiType, scope)) { switch (vpi_get(vpiType, scope)) {
case vpiNamedBegin: type = "begin"; break; case vpiNamedBegin: type = "begin"; break;
case vpiGenScope: type = "begin"; break;
case vpiTask: type = "task"; break; case vpiTask: type = "task"; break;
case vpiFunction: type = "function"; break; case vpiFunction: type = "function"; break;
case vpiNamedFork: type = "fork"; break; case vpiNamedFork: type = "fork"; break;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003-2011 Stephen Williams (steve@icarus.com) * Copyright (c) 2003-2013 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -178,8 +178,9 @@ PLI_INT32 sys_dumpvars_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *name)
#endif #endif
/* The module types. */ /* The module types. */
case vpiModule: case vpiModule:
case vpiTask: case vpiGenScope:
case vpiFunction: case vpiFunction:
case vpiTask:
case vpiNamedBegin: case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
/* The variable types. */ /* The variable types. */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -38,6 +38,7 @@ static void dump_object(vpiHandle item)
/* These types are themselves scopes and have objects within. */ /* These types are themselves scopes and have objects within. */
case vpiModule: case vpiModule:
case vpiGenScope:
case vpiFunction: case vpiFunction:
case vpiTask: case vpiTask:
case vpiNamedBegin: case vpiNamedBegin:

View File

@ -1,7 +1,7 @@
#ifndef __vpi_user_H #ifndef __vpi_user_H
#define __vpi_user_H #define __vpi_user_H
/* /*
* Copyright (c) 1999-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -312,11 +312,12 @@ typedef struct t_vpi_delay {
/********************** object types added with 1364-2001 *********************/ /********************** object types added with 1364-2001 *********************/
# define vpiRegArray 116 #define vpiCallback 107
#define vpiRegArray 116
/********************** object types added with 1364-2005 *********************/ /********************** object types added with 1364-2005 *********************/
#define vpiCallback 1000 #define vpiGenScope 134
/* PROPERTIES */ /* PROPERTIES */
#define vpiUndefined (-1) #define vpiUndefined (-1)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003-2012 Stephen Williams (steve@icarus.com) * Copyright (c) 2003-2013 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -133,6 +133,7 @@ static void cmd_call(unsigned argc, char*argv[])
switch (table[tmp]->get_type_code()) { switch (table[tmp]->get_type_code()) {
case vpiModule: case vpiModule:
case vpiGenScope:
case vpiFunction: case vpiFunction:
case vpiTask: case vpiTask:
case vpiNamedBegin: case vpiNamedBegin:
@ -236,6 +237,11 @@ static void cmd_list(unsigned, char*[])
printf("module : %s\n", scope->name); printf("module : %s\n", scope->name);
break; break;
case vpiGenScope:
scope = dynamic_cast<__vpiScope*>(table[idx]);
printf("generate: %s\n", scope->name);
break;
case vpiTask: case vpiTask:
scope = dynamic_cast<__vpiScope*>(table[idx]); scope = dynamic_cast<__vpiScope*>(table[idx]);
printf("task : %s\n", scope->name); printf("task : %s\n", scope->name);

View File

@ -307,6 +307,8 @@ static const char* vpi_type_values(PLI_INT32 code)
return "vpiEnumTypespec"; return "vpiEnumTypespec";
case vpiFunction: case vpiFunction:
return "vpiFunction"; return "vpiFunction";
case vpiGenScope:
return "vpiGenScope";
case vpiIntVar: case vpiIntVar:
return "vpiIntVar"; return "vpiIntVar";
case vpiIntegerVar: case vpiIntegerVar:

View File

@ -61,6 +61,7 @@ static void delete_sub_scopes(struct __vpiScope *scope)
case vpiTask: case vpiTask:
contexts_delete(lscope); contexts_delete(lscope);
case vpiModule: case vpiModule:
case vpiGenScope:
case vpiNamedBegin: case vpiNamedBegin:
case vpiNamedFork: case vpiNamedFork:
delete_sub_scopes(lscope); delete_sub_scopes(lscope);
@ -187,6 +188,8 @@ static const char* scope_get_type(int code)
switch (code) { switch (code) {
case vpiModule: case vpiModule:
return "vpiModule"; return "vpiModule";
case vpiGenScope:
return "vpiGenScope";
case vpiFunction: case vpiFunction:
return "vpiFunction"; return "vpiFunction";
case vpiTask: case vpiTask:
@ -273,6 +276,7 @@ static int compare_types(int code, int type)
if ( code == vpiInternalScope && if ( code == vpiInternalScope &&
(type == vpiModule || (type == vpiModule ||
type == vpiGenScope ||
type == vpiFunction || type == vpiFunction ||
type == vpiTask || type == vpiTask ||
type == vpiNamedBegin || type == vpiNamedBegin ||
@ -368,6 +372,11 @@ struct vpiScopeBegin : public __vpiScope {
int get_type_code(void) const { return vpiNamedBegin; } int get_type_code(void) const { return vpiNamedBegin; }
}; };
struct vpiScopeGenerate : public __vpiScope {
inline vpiScopeGenerate() { }
int get_type_code(void) const { return vpiGenScope; }
};
struct vpiScopeFork : public __vpiScope { struct vpiScopeFork : public __vpiScope {
inline vpiScopeFork() { } inline vpiScopeFork() { }
int get_type_code(void) const { return vpiNamedFork; } int get_type_code(void) const { return vpiNamedFork; }
@ -435,7 +444,7 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
} else if (strcmp(base_type,"begin") == 0) { } else if (strcmp(base_type,"begin") == 0) {
scope = new vpiScopeBegin; scope = new vpiScopeBegin;
} else if (strcmp(base_type,"generate") == 0) { } else if (strcmp(base_type,"generate") == 0) {
scope = new vpiScopeBegin; scope = new vpiScopeGenerate;
} else if (strcmp(base_type,"package") == 0) { } else if (strcmp(base_type,"package") == 0) {
scope = new vpiScopePackage; scope = new vpiScopePackage;
} else if (strcmp(base_type,"class") == 0) { } else if (strcmp(base_type,"class") == 0) {