Add support for passing the delay selection to the VPI interface.

This patch adds support for passing the delay selection to the
VPI interface. It adds a new property to both the vpi_get and
vpi_get_str calls to return the current delay selection. It also
defines three constants for minimum, typical and maximum
delay selections.
This commit is contained in:
Cary R 2010-03-13 22:16:27 -08:00 committed by Stephen Williams
parent e241586bcf
commit 07bedc4e35
6 changed files with 51 additions and 7 deletions

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-2009 Stephen Williams (steve@icarus.com) * Copyright (c) 1999-2010 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
@ -364,7 +364,12 @@ typedef struct t_vpi_delay {
#define vpiConstantSelect 53 #define vpiConstantSelect 53
#define vpiSigned 65 #define vpiSigned 65
/* IVL private properties, also see vvp/vpi_priv.h for other properties */ /* IVL private properties, also see vvp/vpi_priv.h for other properties */
#define _vpiNexusId 0x1000000 #define _vpiNexusId 0x1000000
/* used in vvp/vpi_priv.h 0x1000001 */
#define _vpiDelaySelection 0x1000002
# define _vpiDelaySelMinimum 1
# define _vpiDelaySelTypical 2
# define _vpiDelaySelMaximum 3
/* DELAY MODES */ /* DELAY MODES */
#define vpiNoDelay 1 #define vpiNoDelay 1

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2010 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
@ -176,6 +176,21 @@ void verify_version(char*ivl_ver, char*commit)
free(vvp_ver); free(vvp_ver);
} }
int vpip_delay_selection = _vpiDelaySelTypical;
void set_delay_selection(const char* sel)
{
if (strcmp("TYPICAL", sel) == 0) {
vpip_delay_selection = _vpiDelaySelTypical;
} else if (strcmp("MINIMUM", sel) == 0) {
vpip_delay_selection = _vpiDelaySelMinimum;
} else if (strcmp("MAXIMUM", sel) == 0) {
vpip_delay_selection = _vpiDelaySelMaximum;
} else {
vpi_mcd_printf(1, "Error: Unknown delay selection \"%s\"!", sel);
exit(1);
}
}
unsigned module_cnt = 0; unsigned module_cnt = 0;
const char*module_tab[64]; const char*module_tab[64];
@ -282,7 +297,7 @@ int main(int argc, char*argv[])
if (version_flag) { if (version_flag) {
fprintf(stderr, "Icarus Verilog runtime version " VERSION " (" fprintf(stderr, "Icarus Verilog runtime version " VERSION " ("
VERSION_TAG ")\n\n"); VERSION_TAG ")\n\n");
fprintf(stderr, "Copyright 1998-2009 Stephen Williams\n\n"); fprintf(stderr, "Copyright 1998-2010 Stephen Williams\n\n");
fprintf(stderr, fprintf(stderr,
" This program is free software; you can redistribute it and/or modify\n" " This program is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n" " it under the terms of the GNU General Public License as published by\n"

View File

@ -127,7 +127,7 @@ header_line
| K_ivl_version T_STRING T_STRING ';' | K_ivl_version T_STRING T_STRING ';'
{ verify_version($2, $3); } { verify_version($2, $3); }
| K_ivl_delay_selection T_STRING ';' | K_ivl_delay_selection T_STRING ';'
{ /* Do something with the delay selection. */ } { set_delay_selection($2); }
| K_vpi_module T_STRING ';' | K_vpi_module T_STRING ';'
{ compile_load_vpi_module($2); } { compile_load_vpi_module($2); }
| K_vpi_time_precision '+' T_NUMBER ';' | K_vpi_time_precision '+' T_NUMBER ';'

View File

@ -1,7 +1,7 @@
#ifndef __parse_misc_H #ifndef __parse_misc_H
#define __parse_misc_H #define __parse_misc_H
/* /*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2010 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
@ -33,6 +33,11 @@ extern int compile_design(const char*path);
*/ */
extern void verify_version(char *ivl_ver, char* commit); extern void verify_version(char *ivl_ver, char* commit);
/*
* Set the default delay type for the $sdf_annotate task (min/typ/max).
*/
extern void set_delay_selection(const char* sel);
/* /*
* various functions shared by the lexor and the parser. * various functions shared by the lexor and the parser.
*/ */

View File

@ -264,6 +264,9 @@ static const char* vpi_type_values(PLI_INT32 code)
PLI_INT32 vpi_get(int property, vpiHandle ref) PLI_INT32 vpi_get(int property, vpiHandle ref)
{ {
/* We don't care what the ref is there is only one delay selection. */
if (property == _vpiDelaySelection) return vpip_delay_selection;
if (ref == 0) if (ref == 0)
return vpip_get_global(property); return vpip_get_global(property);
@ -303,6 +306,20 @@ PLI_INT32 vpi_get(int property, vpiHandle ref)
char* vpi_get_str(PLI_INT32 property, vpiHandle ref) char* vpi_get_str(PLI_INT32 property, vpiHandle ref)
{ {
/* We don't care what the ref is there is only one delay selection. */
if (property == _vpiDelaySelection) {
switch (vpip_delay_selection) {
case _vpiDelaySelMinimum:
return simple_set_rbuf_str("MINIMUM");
case _vpiDelaySelTypical:
return simple_set_rbuf_str("TYPICAL");
case _vpiDelaySelMaximum:
return simple_set_rbuf_str("MAXIMUM");
default:
assert(0);
}
}
if (ref == 0) { if (ref == 0) {
fprintf(stderr, "vpi error: vpi_get_str(%s, 0) called " fprintf(stderr, "vpi error: vpi_get_str(%s, 0) called "
"with null vpiHandle.\n", vpi_property_str(property)); "with null vpiHandle.\n", vpi_property_str(property));

View File

@ -1,7 +1,7 @@
#ifndef __vpi_priv_H #ifndef __vpi_priv_H
#define __vpi_priv_H #define __vpi_priv_H
/* /*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2010 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
@ -628,4 +628,6 @@ extern char *generic_get_str(int code, vpiHandle ref, const char *name, const ch
/* A routine to find the enclosing module. */ /* A routine to find the enclosing module. */
extern vpiHandle vpip_module(struct __vpiScope*scope); extern vpiHandle vpip_module(struct __vpiScope*scope);
extern int vpip_delay_selection;
#endif #endif