diff --git a/vpi/sdf_parse.y b/vpi/sdf_parse.y index 69d57300d..f4859add1 100644 --- a/vpi/sdf_parse.y +++ b/vpi/sdf_parse.y @@ -1,7 +1,7 @@ %{ /* - * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2009 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 @@ -38,6 +38,7 @@ char sdf_use_hchar = '.'; double real_val; char* string_val; + struct sdf_delay_s delay; struct port_with_edge_s port_with_edge; struct sdf_delval_list_s delval_list; }; @@ -58,8 +59,8 @@ char sdf_use_hchar = '.'; %type hierarchical_identifier %type port port_instance -%type rvalue rtriple signed_real_number -%type delval +%type rtriple signed_real_number +%type delval rvalue %type edge_identifier %type port_edge port_spec @@ -315,6 +316,7 @@ delval_list $$.count = $1.count; for (idx = 0 ; idx < $$.count ; idx += 1) $$.val[idx] = $1.val[idx]; +// Is this correct? if ($$.count < 12) { $$.val[$$.count] = $2; $$.count += 1; @@ -343,9 +345,14 @@ delval rvalue : '(' signed_real_number ')' - { $$ = $2; } + { $$.defined = 1; + $$.value = $2; } | '(' rtriple ')' - { $$ = $2; } + { $$.defined = 1; + $$.value = $2; } + | '(' ')' + { $$.defined = 0; + $$.value = 0.0; } ; hierarchical_identifier diff --git a/vpi/sdf_priv.h b/vpi/sdf_priv.h index a71d76958..e336c9360 100644 --- a/vpi/sdf_priv.h +++ b/vpi/sdf_priv.h @@ -1,7 +1,7 @@ #ifndef _sdf_priv_h #define _sdf_priv_h /* - * Copyright (c) 2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-2009 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 @@ -36,9 +36,14 @@ extern int sdf_flag_inform; * it is parsed. */ +struct sdf_delay_s { + int defined; + double value; +}; + struct sdf_delval_list_s { int count; - double val[12]; + struct sdf_delay_s val[12]; }; extern void sdf_select_instance(const char*celltype, const char*inst); diff --git a/vpi/sys_sdf.c b/vpi/sys_sdf.c index fe2210e28..e89e4943c 100644 --- a/vpi/sys_sdf.c +++ b/vpi/sys_sdf.c @@ -139,33 +139,22 @@ static const char*edge_str(int vpi_edge) void sdf_iopath_delays(int vpi_edge, const char*src, const char*dst, const struct sdf_delval_list_s*delval_list) { - s_vpi_delay delays; + vpiHandle iter, path; + int match_count = 0; + if (sdf_cur_cell == 0) return; - vpiHandle iter = vpi_iterate(vpiModPath, sdf_cur_cell); - - struct t_vpi_time delay_vals[12]; - int idx; - for (idx = 0 ; idx < delval_list->count ; idx += 1) { - delay_vals[idx].type = vpiScaledRealTime; - delay_vals[idx].real = delval_list->val[idx]; - } - - delays.da = delay_vals; - delays.no_of_delays = delval_list->count; - delays.time_type = vpiScaledRealTime; - delays.mtm_flag = 0; - delays.append_flag = 0; - delays.plusere_flag = 0; - + iter = vpi_iterate(vpiModPath, sdf_cur_cell); /* Search for the modpath that matches the IOPATH by looking for the modpath that uses the same ports as the ports that the parser has found. */ - vpiHandle path; - int match_count = 0; if (iter) while ( (path = vpi_scan(iter)) ) { + s_vpi_delay delays; + struct t_vpi_time delay_vals[12]; + int idx; + vpiHandle path_t_in = vpi_handle(vpiModPathIn,path); vpiHandle path_t_out = vpi_handle(vpiModPathOut,path); @@ -192,6 +181,22 @@ void sdf_iopath_delays(int vpi_edge, const char*src, const char*dst, continue; /* Ah, this must be a match! */ + delays.da = delay_vals; + delays.no_of_delays = delval_list->count; + delays.time_type = vpiScaledRealTime; + delays.mtm_flag = 0; + delays.append_flag = 0; + delays.plusere_flag = 0; + vpi_get_delays(path, &delays); + + for (idx = 0 ; idx < delval_list->count ; idx += 1) { + delay_vals[idx].type = vpiScaledRealTime; + if (delval_list->val[idx].defined) { + delay_vals[idx].real = delval_list->val[idx].value; + } + + } + vpi_put_delays(path, &delays); match_count += 1; } diff --git a/vvp/delay.cc b/vvp/delay.cc index 31b30367a..ab250c03d 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -768,23 +768,27 @@ static void modpath_src_get_delays ( vpiHandle ref, p_vpi_delay delays ) fun->get_delay12(tmp); switch (delays->no_of_delays) { + case 1: + case 2: + case 3: + case 6: case 12: - if (delays->time_type == vpiSimTime) { - for (idx = 0; idx < 12; idx += 1) { - vpip_time_to_timestruct(delays->da+idx, tmp[idx]); - } - } else { - /* int units = src->dest->scope->time_units; */ - for (idx = 0; idx < 12; idx += 1) { - delays->da[idx].real = vpip_time_to_scaled_real(tmp[idx], src->dest->scope); - } - } break; default: assert(0); break; } + + if (delays->time_type == vpiSimTime) { + for (idx = 0; idx < delays->no_of_delays; idx += 1) { + vpip_time_to_timestruct(delays->da+idx, tmp[idx]); + } + } else { + for (idx = 0; idx < delays->no_of_delays; idx += 1) { + delays->da[idx].real = vpip_time_to_scaled_real(tmp[idx], src->dest->scope); + } + } } static int pathterm_get(int code, vpiHandle ref)