#include <sc_wif_trace.h>
Public 型 | |
enum | wif_enum { WIF_BIT = 0, WIF_MVL = 1, WIF_REAL = 2, WIF_LAST } |
Public メソッド | |
void | sc_set_wif_time_unit (int exponent10_seconds) |
wif_trace_file (const char *name) | |
~wif_trace_file () | |
std::string | obtain_new_index () |
Public 変数 | |
std::vector< wif_trace * > | traces |
Protected メソッド | |
void | trace (const bool &object, const std::string &name) |
void | trace (const sc_dt::sc_bit &object, const std::string &name) |
void | trace (const sc_dt::sc_logic &object, const std::string &name) |
void | trace (const unsigned char &object, const std::string &name, int width) |
void | trace (const unsigned short &object, const std::string &name, int width) |
void | trace (const unsigned int &object, const std::string &name, int width) |
void | trace (const unsigned long &object, const std::string &name, int width) |
void | trace (const char &object, const std::string &name, int width) |
void | trace (const short &object, const std::string &name, int width) |
void | trace (const int &object, const std::string &name, int width) |
void | trace (const long &object, const std::string &name, int width) |
void | trace (const sc_dt::int64 &object, const std::string &name, int width) |
void | trace (const sc_dt::uint64 &object, const std::string &name, int width) |
void | trace (const float &object, const std::string &name) |
void | trace (const double &object, const std::string &name) |
void | trace (const sc_dt::sc_unsigned &object, const std::string &name) |
void | trace (const sc_dt::sc_signed &object, const std::string &name) |
void | trace (const sc_dt::sc_uint_base &object, const std::string &name) |
void | trace (const sc_dt::sc_int_base &object, const std::string &name) |
void | trace (const sc_dt::sc_fxval &object, const std::string &name) |
void | trace (const sc_dt::sc_fxval_fast &object, const std::string &name) |
void | trace (const sc_dt::sc_fxnum &object, const std::string &name) |
void | trace (const sc_dt::sc_fxnum_fast &object, const std::string &name) |
template<class T> | |
void | traceT (const T &object, const std::string &name, wif_enum type) |
virtual void | trace (const sc_dt::sc_bv_base &object, const std::string &name) |
virtual void | trace (const sc_dt::sc_lv_base &object, const std::string &name) |
void | trace (const unsigned &object, const std::string &name, const char **enum_literals) |
void | write_comment (const std::string &comment) |
void | delta_cycles (bool flag) |
void | cycle (bool delta_cycle) |
Private メソッド | |
void | initialize () |
void | create_wif_name (std::string *ptr_to_str) |
Private 変数 | |
FILE * | fp |
bool | trace_delta_cycles |
unsigned | wif_name_index |
unsigned | previous_time_units_low |
unsigned | previous_time_units_high |
double | previous_time |
sc_wif_trace.h の 69 行で定義されています。
sc_core::wif_trace_file::wif_trace_file | ( | const char * | name | ) |
sc_wif_trace.cpp の 1564 行で定義されています。
01565 { 01566 std::string file_name = name ; 01567 file_name += ".awif"; 01568 fp = fopen(file_name.c_str(), "w"); 01569 if (!fp) { 01570 std::string msg = 01571 std::string("Cannot write trace file '") + file_name + 01572 "'"; 01573 ::std::cerr << "FATAL: " << msg << "\n"; 01574 exit(1); 01575 } 01576 trace_delta_cycles = false; // make it the default 01577 initialized = false; 01578 wif_name_index = 0; 01579 01580 // default time step is the time resolution 01581 timescale_unit = sc_get_time_resolution().to_seconds(); 01582 01583 timescale_set_by_user = false; 01584 }
sc_core::wif_trace_file::~wif_trace_file | ( | ) |
sc_wif_trace.cpp の 1928 行で定義されています。
01929 { 01930 int i; 01931 for (i = 0; i < (int)traces.size(); i++) { 01932 wif_trace* t = traces[i]; 01933 delete t; 01934 } 01935 fclose(fp); 01936 }
void sc_core::wif_trace_file::sc_set_wif_time_unit | ( | int | exponent10_seconds | ) | [inline] |
void sc_core::wif_trace_file::trace | ( | const bool & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_bit & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_logic & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const unsigned char & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const unsigned short & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const unsigned int & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const unsigned long & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const char & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const short & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const int & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const long & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::int64 & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::uint64 & | object, | |
const std::string & | name, | |||
int | width | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const float & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const double & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_unsigned & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_signed & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_uint_base & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_int_base & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_fxval & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_fxval_fast & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_fxnum & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_fxnum_fast & | object, | |
const std::string & | name | |||
) | [protected] |
void sc_core::wif_trace_file::traceT | ( | const T & | object, | |
const std::string & | name, | |||
wif_enum | type | |||
) | [inline, protected] |
sc_wif_trace.h の 169 行で定義されています。
00170 { 00171 if(initialized) 00172 put_error_message("No traces can be added once simulation has" 00173 " started.\nTo add traces, create a new wif trace file.", false); 00174 else 00175 traces.push_back(new wif_T_trace<T>(object, name, 00176 obtain_new_index(),type)); 00177 }
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_bv_base & | object, | |
const std::string & | name | |||
) | [protected, virtual] |
void sc_core::wif_trace_file::trace | ( | const sc_dt::sc_lv_base & | object, | |
const std::string & | name | |||
) | [protected, virtual] |
void sc_core::wif_trace_file::trace | ( | const unsigned & | object, | |
const std::string & | name, | |||
const char ** | enum_literals | |||
) | [protected] |
sc_wif_trace.cpp の 1801 行で定義されています。
01804 { 01805 if( initialized ) { 01806 put_error_message( 01807 "No traces can be added once simulation has started.\n" 01808 "To add traces, create a new wif trace file.", false ); 01809 } 01810 std::string temp_wif_name; 01811 create_wif_name( &temp_wif_name ); 01812 traces.push_back( new wif_enum_trace( object_, 01813 name_, 01814 temp_wif_name, 01815 enum_literals_ ) ); 01816 }
void sc_core::wif_trace_file::write_comment | ( | const std::string & | comment | ) | [protected, virtual] |
sc_core::sc_trace_fileを実装しています。
sc_wif_trace.cpp の 1834 行で定義されています。
01835 { 01836 //no newline in comments allowed 01837 std::fprintf(fp, "comment \"%s\" ;\n", comment.c_str()); 01838 }
void sc_core::wif_trace_file::delta_cycles | ( | bool | flag | ) | [protected, virtual] |
sc_core::sc_trace_fileを再定義しています。
sc_wif_trace.cpp の 1842 行で定義されています。
01843 { 01844 trace_delta_cycles = flag; 01845 }
void sc_core::wif_trace_file::cycle | ( | bool | delta_cycle | ) | [protected, virtual] |
sc_core::sc_trace_fileを実装しています。
sc_wif_trace.cpp の 1848 行で定義されています。
01849 { 01850 unsigned now_units_high, now_units_low; 01851 01852 // Trace delta cycles only when enabled 01853 if (!trace_delta_cycles && this_is_a_delta_cycle) return; 01854 01855 // Check for initialization 01856 if (!initialized) { 01857 initialize(); 01858 initialized = true; 01859 return; 01860 }; 01861 01862 // double now_units = sc_simulation_time() / timescale_unit; 01863 double now_units = sc_time_stamp().to_seconds() / timescale_unit; 01864 01865 double_to_special_int64(now_units, &now_units_high, &now_units_low ); 01866 01867 // Now do the real stuff 01868 unsigned delta_units_high, delta_units_low; 01869 double diff_time; 01870 diff_time = now_units - previous_time; 01871 double_to_special_int64(diff_time, &delta_units_high, &delta_units_low); 01872 if (this_is_a_delta_cycle && (diff_time == 0.0)) 01873 delta_units_low++; // Increment time for delta cycle simulation 01874 // Note that in the last statement above, we are assuming no more 01875 // than 2^32 delta cycles - seems realistic 01876 01877 bool time_printed = false; 01878 wif_trace* const* const l_traces = &traces[0]; 01879 for (int i = 0; i < (int)traces.size(); i++) { 01880 wif_trace* t = l_traces[i]; 01881 if(t->changed()){ 01882 if(time_printed == false){ 01883 if(delta_units_high){ 01884 std::fprintf(fp, "delta_time %u%09u ;\n", delta_units_high, 01885 delta_units_low); 01886 } 01887 else{ 01888 std::fprintf(fp, "delta_time %u ;\n", delta_units_low); 01889 } 01890 time_printed = true; 01891 } 01892 01893 // Write the variable 01894 t->write(fp); 01895 } 01896 } 01897 01898 if(time_printed) { 01899 std::fprintf(fp, "\n"); // Put another newline 01900 // We update previous_time_units only when we print time because 01901 // this field stores the previous time that was printed, not the 01902 // previous time this function was called 01903 previous_time_units_high = now_units_high; 01904 previous_time_units_low = now_units_low; 01905 previous_time = now_units; 01906 } 01907 }
void sc_core::wif_trace_file::initialize | ( | ) | [private] |
sc_wif_trace.cpp の 1587 行で定義されています。
01588 { 01589 char buf[2000]; 01590 01591 // init 01592 std::fprintf(fp, "init ;\n\n"); 01593 01594 //timescale: 01595 if (timescale_unit == 1e-15) std::sprintf(buf,"0"); 01596 else if(timescale_unit == 1e-14) std::sprintf(buf,"1"); 01597 else if(timescale_unit == 1e-13) std::sprintf(buf,"2"); 01598 else if(timescale_unit == 1e-12) std::sprintf(buf,"3"); 01599 else if(timescale_unit == 1e-11) std::sprintf(buf,"4"); 01600 else if(timescale_unit == 1e-10) std::sprintf(buf,"5"); 01601 else if(timescale_unit == 1e-9) std::sprintf(buf,"6"); 01602 else if(timescale_unit == 1e-8) std::sprintf(buf,"7"); 01603 else if(timescale_unit == 1e-7) std::sprintf(buf,"8"); 01604 else if(timescale_unit == 1e-6) std::sprintf(buf,"9"); 01605 else if(timescale_unit == 1e-5) std::sprintf(buf,"10"); 01606 else if(timescale_unit == 1e-4) std::sprintf(buf,"11"); 01607 else if(timescale_unit == 1e-3) std::sprintf(buf,"12"); 01608 else if(timescale_unit == 1e-2) std::sprintf(buf,"13"); 01609 else if(timescale_unit == 1e-1) std::sprintf(buf,"14"); 01610 else if(timescale_unit == 1e0) std::sprintf(buf,"15"); 01611 else if(timescale_unit == 1e1) std::sprintf(buf,"16"); 01612 else if(timescale_unit == 1e2) std::sprintf(buf,"17"); 01613 std::fprintf(fp,"header %s \"%s\" ;\n\n", buf, sc_version()); 01614 01615 //date: 01616 time_t long_time; 01617 time(&long_time); 01618 struct tm* p_tm; 01619 p_tm = localtime(&long_time); 01620 strftime(buf, 199, "%b %d, %Y %H:%M:%S", p_tm); 01621 std::fprintf(fp, "comment \"ASCII WIF file produced on date: %s\" ;\n", buf); 01622 01623 //version: 01624 std::fprintf(fp, "comment \"Created by %s\" ;\n", sc_version()); 01625 //conversion info 01626 std::fprintf(fp, "comment \"Convert this file to binary WIF format using a2wif\" ;\n\n"); 01627 01628 01629 running_regression = ( getenv( "SYSTEMC_REGRESSION" ) != NULL ); 01630 // Don't print message if running regression 01631 if( ! timescale_set_by_user && ! running_regression ) { 01632 ::std::cout << "WARNING: Default time step is used for WIF tracing." << ::std::endl; 01633 } 01634 01635 // Define the two types we need to represent bool and sc_logic 01636 std::fprintf(fp, "type scalar \"BIT\" enum '0', '1' ;\n"); 01637 std::fprintf(fp, "type scalar \"MVL\" enum '0', '1', 'X', 'Z', '?' ;\n"); 01638 std::fprintf(fp, "\n"); 01639 01640 //variable definitions: 01641 int i; 01642 for (i = 0; i < (int)traces.size(); i++) { 01643 wif_trace* t = traces[i]; 01644 t->set_width(); //needed for all vectors 01645 t->print_variable_declaration_line(fp); 01646 } 01647 01648 double inittime = sc_time_stamp().to_seconds(); 01649 previous_time = inittime/timescale_unit; 01650 01651 // Dump all values at initial time 01652 std::sprintf(buf, 01653 "All initial values are dumped below at time " 01654 "%g sec = %g timescale units.", 01655 inittime, 01656 inittime/timescale_unit 01657 ); 01658 write_comment(buf); 01659 01660 double_to_special_int64(inittime/timescale_unit, 01661 &previous_time_units_high, 01662 &previous_time_units_low ); 01663 01664 for (i = 0; i < (int)traces.size(); i++) { 01665 wif_trace* t = traces[i]; 01666 t->write(fp); 01667 } 01668 }
void sc_core::wif_trace_file::create_wif_name | ( | std::string * | ptr_to_str | ) | [private] |
sc_wif_trace.cpp の 1911 行で定義されています。
01912 { 01913 char buf[50]; 01914 std::sprintf(buf,"O%d", wif_name_index); 01915 *ptr_to_str = buf; 01916 wif_name_index++; 01917 }
std::string sc_core::wif_trace_file::obtain_new_index | ( | ) |
sc_wif_trace.cpp の 1920 行で定義されています。
01921 { 01922 char buf[32]; 01923 std::sprintf( buf, "O%d", wif_name_index ++ ); 01924 return std::string( buf ); 01925 }
FILE* sc_core::wif_trace_file::fp [private] |
sc_wif_trace.h の 210 行で定義されています。
bool sc_core::wif_trace_file::trace_delta_cycles [private] |
sc_wif_trace.h の 212 行で定義されています。
unsigned sc_core::wif_trace_file::wif_name_index [private] |
sc_wif_trace.h の 214 行で定義されています。
unsigned sc_core::wif_trace_file::previous_time_units_low [private] |
sc_wif_trace.h の 216 行で定義されています。
unsigned sc_core::wif_trace_file::previous_time_units_high [private] |
sc_wif_trace.h の 216 行で定義されています。
double sc_core::wif_trace_file::previous_time [private] |
sc_wif_trace.h の 217 行で定義されています。
std::vector<wif_trace*> sc_core::wif_trace_file::traces |
sc_wif_trace.h の 225 行で定義されています。