diff --git a/ivl.def b/ivl.def index 88af848ce..ddb57b0a1 100644 --- a/ivl.def +++ b/ivl.def @@ -7,6 +7,7 @@ ivl_design_const ivl_design_consts ivl_design_discipline ivl_design_disciplines +ivl_design_delay_sel ivl_design_flag ivl_design_process ivl_design_root diff --git a/ivl_target.h b/ivl_target.h index 2f04e55a5..90db9c025 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -1,7 +1,7 @@ #ifndef __ivl_target_H #define __ivl_target_H /* - * Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 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 @@ -477,6 +477,9 @@ extern int ivl_path_source_negedge(ivl_delaypath_t obj); * entire program. Use the design methods to iterate over the elements * of the design. * + * ivl_design_delay_sel + * Returns the tool delay selection: "MINIMUM", "TYPICAL" or "MAXIMUM"? + * * ivl_design_flag * This function returns the string value of a named flag. Flags * come from the "-fkey=value" options to the iverilog command and @@ -510,6 +513,7 @@ extern int ivl_path_source_negedge(ivl_delaypath_t obj); * signed power of 10) of a simulation tick. */ +extern const char* ivl_design_delay_sel(ivl_design_t des); extern const char* ivl_design_flag(ivl_design_t des, const char*key); extern int ivl_design_process(ivl_design_t des, ivl_process_f fun, void*cd); diff --git a/main.cc b/main.cc index c4d44fb0f..58ddea483 100644 --- a/main.cc +++ b/main.cc @@ -1032,6 +1032,20 @@ int main(int argc, char*argv[]) des->set_flags(flags); + switch(min_typ_max_flag) { + case MIN: + des->set_delay_sel(Design::MIN); + break; + case TYP: + des->set_delay_sel(Design::TYP); + break; + case MAX: + des->set_delay_sel(Design::MAX); + break; + default: + assert(0); + } + /* Done with all the pform data. Delete the modules. */ for (map::iterator idx = pform_modules.begin() ; idx != pform_modules.end() ; idx ++) { diff --git a/net_design.cc b/net_design.cc index 823469458..d54c71db8 100644 --- a/net_design.cc +++ b/net_design.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 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 @@ -60,6 +60,30 @@ int Design::get_precision() const return des_precision_; } +void Design::set_delay_sel(delay_sel_t sel) +{ + des_delay_sel_ = sel; +} + +const char* Design::get_delay_sel() const +{ + switch (des_delay_sel_) { + case Design::MIN: + return "MINIMUM"; + break; + case Design::TYP: + return "TYPICAL"; + break; + case Design::MAX: + return "MAXIMUM"; + break; + default: + assert(0); + return "TYPICAL"; + } +} + + uint64_t Design::scale_to_precision(uint64_t val, const NetScope*scope) const { diff --git a/netlist.h b/netlist.h index 2779fe1c7..ec42bf682 100644 --- a/netlist.h +++ b/netlist.h @@ -3876,6 +3876,10 @@ class Design { Design(); ~Design(); + /* We need to pass the tool delay selection for $sdf_annotate. */ + enum delay_sel_t { MIN, TYP, MAX }; + void set_delay_sel(delay_sel_t sel); + const char* get_delay_sel() const; /* The flags are a generic way of accepting command line parameters/flags and passing them to the processing steps @@ -3998,6 +4002,7 @@ class Design { map flags_; int des_precision_; + delay_sel_t des_delay_sel_; private: // not implemented Design(const Design&); diff --git a/t-dll-api.cc b/t-dll-api.cc index 32aaee04d..ee2ed612e 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 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 @@ -43,6 +43,10 @@ extern "C" ivl_nexus_t ivl_branch_terminal(ivl_branch_t net, int idx) assert( idx < 2); return net->pins[idx]; } +extern "C" const char*ivl_design_delay_sel(ivl_design_t des) +{ + return des->self->get_delay_sel(); +} extern "C" const char*ivl_design_flag(ivl_design_t des, const char*key) { diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index fba834998..1317d2591 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -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 * and/or modify it in source code form under the terms of the GNU @@ -111,13 +111,16 @@ int target_design(ivl_design_t des) draw_execute_header(des); + fprintf(vvp_out, ":ivl_delay_selection \"%s\";\n", + ivl_design_delay_sel(des)); + { int pre = ivl_design_time_precision(des); - char sign = '+'; - if (pre < 0) { + char sign = '+'; + if (pre < 0) { pre = -pre; sign = '-'; } - fprintf(vvp_out, ":vpi_time_precision %c %d;\n", sign, pre); + fprintf(vvp_out, ":vpi_time_precision %c %d;\n", sign, pre); } draw_module_declarations(des); diff --git a/vvp/lexor.lex b/vvp/lexor.lex index 67a8cef02..5edcac3d7 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -4,7 +4,7 @@ %{ /* - * 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 * and/or modify it in source code form under the terms of the GNU @@ -47,6 +47,7 @@ static char* strdupnew(char const *str) /* These are some special header/footer keywords. */ ^":ivl_version" { return K_ivl_version; } +^":ivl_delay_selection" { return K_ivl_delay_selection; } ^":vpi_module" { return K_vpi_module; } ^":vpi_time_precision" { return K_vpi_time_precision; } ^":file_names" { return K_file_names; } diff --git a/vvp/parse.y b/vvp/parse.y index 73eef8860..a0ed34f23 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -1,7 +1,7 @@ %{ /* - * 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 * and/or modify it in source code form under the terms of the GNU @@ -86,7 +86,8 @@ static struct __vpiModPath*modpath_dst = 0; %token K_UFUNC K_UFUNC_E K_UDP K_UDP_C K_UDP_S %token K_VAR K_VAR_S K_VAR_I K_VAR_R K_vpi_call K_vpi_func K_vpi_func_r %token K_disable K_fork -%token K_ivl_version K_vpi_module K_vpi_time_precision K_file_names +%token K_ivl_version K_ivl_delay_selection +%token K_vpi_module K_vpi_time_precision K_file_names %token T_INSTR %token T_LABEL @@ -125,6 +126,8 @@ header_line { verify_version($2, NULL); } | K_ivl_version T_STRING T_STRING ';' { verify_version($2, $3); } + | K_ivl_delay_selection T_STRING ';' + { /* Do something with the delay selection. */ } | K_vpi_module T_STRING ';' { compile_load_vpi_module($2); } | K_vpi_time_precision '+' T_NUMBER ';'