mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	
						commit
						4c72b0ecd8
					
				
					 11 changed files with 5547 additions and 5638 deletions
				
			
		|  | @ -206,6 +206,7 @@ static void reconstruct_clb_attimes(void *user_data, uint64_t pnt_time, fstHandl | |||
| void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t /* plen */) | ||||
| { | ||||
| 	if (pnt_time > end_time || !pnt_value) return; | ||||
| 	if (curr_cycle > last_cycle) return; | ||||
| 	// if we are past the timestamp
 | ||||
| 	bool is_clock = false; | ||||
| 	if (!all_samples) { | ||||
|  | @ -225,6 +226,7 @@ void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_faci | |||
| 	if (pnt_time > last_time) { | ||||
| 		if (all_samples) { | ||||
| 			callback(last_time); | ||||
| 			curr_cycle++; | ||||
| 			last_time = pnt_time; | ||||
| 		} else { | ||||
| 			if (is_clock) { | ||||
|  | @ -232,6 +234,7 @@ void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_faci | |||
| 				std::string prev = past_data[pnt_facidx]; | ||||
| 				if ((prev!="1" && val=="1") || (prev!="0" && val=="0")) { | ||||
| 					callback(last_time); | ||||
| 					curr_cycle++; | ||||
| 					last_time = pnt_time; | ||||
| 				} | ||||
| 			} | ||||
|  | @ -241,12 +244,14 @@ void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_faci | |||
| 	last_data[pnt_facidx] =  std::string((const char *)pnt_value); | ||||
| } | ||||
| 
 | ||||
| void FstData::reconstructAllAtTimes(std::vector<fstHandle> &signal, uint64_t start, uint64_t end, CallbackFunction cb) | ||||
| void FstData::reconstructAllAtTimes(std::vector<fstHandle> &signal, uint64_t start, uint64_t end, unsigned int end_cycle, CallbackFunction cb) | ||||
| { | ||||
| 	clk_signals = signal; | ||||
| 	callback = cb; | ||||
| 	start_time = start; | ||||
| 	end_time = end; | ||||
| 	curr_cycle = 0; | ||||
| 	last_cycle = end_cycle; | ||||
| 	last_data.clear(); | ||||
| 	last_time = start_time; | ||||
| 	past_data.clear(); | ||||
|  | @ -256,12 +261,16 @@ void FstData::reconstructAllAtTimes(std::vector<fstHandle> &signal, uint64_t sta | |||
| 	fstReaderSetUnlimitedTimeRange(ctx); | ||||
| 	fstReaderSetFacProcessMaskAll(ctx); | ||||
| 	fstReaderIterBlocks2(ctx, reconstruct_clb_attimes, reconstruct_clb_varlen_attimes, this, nullptr); | ||||
| 	if (last_time!=end_time) { | ||||
| 	if (last_time!=end_time && curr_cycle <= last_cycle) { | ||||
| 		past_data = last_data; | ||||
| 		callback(last_time); | ||||
| 		curr_cycle++; | ||||
| 	} | ||||
| 	if (curr_cycle <= last_cycle) { | ||||
| 		past_data = last_data; | ||||
| 		callback(end_time); | ||||
| 		curr_cycle++; | ||||
| 	} | ||||
| 	past_data = last_data; | ||||
| 	callback(end_time); | ||||
| } | ||||
| 
 | ||||
| std::string FstData::valueOf(fstHandle signal) | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ class FstData | |||
| 	std::vector<FstVar>& getVars() { return vars; }; | ||||
| 
 | ||||
| 	void reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t plen); | ||||
| 	void reconstructAllAtTimes(std::vector<fstHandle> &signal, uint64_t start_time, uint64_t end_time, CallbackFunction cb); | ||||
| 	void reconstructAllAtTimes(std::vector<fstHandle> &signal, uint64_t start_time, uint64_t end_time, unsigned int end_cycle, CallbackFunction cb); | ||||
| 
 | ||||
| 	std::string valueOf(fstHandle signal); | ||||
| 	fstHandle getHandle(std::string name); | ||||
|  | @ -73,6 +73,8 @@ private: | |||
| 	std::string timescale_str; | ||||
| 	uint64_t start_time; | ||||
| 	uint64_t end_time; | ||||
| 	unsigned int last_cycle; | ||||
| 	unsigned int curr_cycle; | ||||
| 	CallbackFunction callback; | ||||
| 	std::vector<fstHandle> clk_signals; | ||||
| 	bool all_samples; | ||||
|  |  | |||
|  | @ -1,14 +1,14 @@ | |||
| --- fstapi.cc
 | ||||
| +++ fstapi.cc
 | ||||
| @@ -4723,7 +4723,10 @@ if(gzread_pass_status)
 | ||||
|                                  hdr_incomplete = (xc->start_time == 0) && (xc->end_time == 0); | ||||
|                      hdr_incomplete = (xc->start_time == 0) && (xc->end_time == 0); | ||||
|   | ||||
|                                  fstFread(&dcheck, 8, 1, xc->f); | ||||
| -                                xc->double_endian_match = (dcheck == FST_DOUBLE_ENDTEST);
 | ||||
| +				/*
 | ||||
| +				 * Yosys patch: Fix double endian check for i386 targets built in modern gcc
 | ||||
| +				 */
 | ||||
| +                                xc->double_endian_match = (dcheck == (double)FST_DOUBLE_ENDTEST);
 | ||||
|                                  if(!xc->double_endian_match) | ||||
|                                          { | ||||
|                                          union   { | ||||
|                      fstFread(&dcheck, 8, 1, xc->f); | ||||
| -                    xc->double_endian_match = (dcheck == FST_DOUBLE_ENDTEST);
 | ||||
| +                   /*
 | ||||
| +                    * Yosys patch: Fix double endian check for i386 targets built in modern gcc
 | ||||
| +                    */
 | ||||
| +                    xc->double_endian_match = (dcheck == (double)FST_DOUBLE_ENDTEST);
 | ||||
|                      if (!xc->double_endian_match) { | ||||
|                          union | ||||
|                          { | ||||
|  |  | |||
|  | @ -23,9 +23,9 @@ | |||
| @@ -137,7 +137,7 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
 | ||||
|  #include <sys/sysctl.h> | ||||
|  #endif | ||||
|   | ||||
| -#if defined(FST_MACOSX) || defined(__MINGW32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
 | ||||
| +#if defined(FST_MACOSX) || defined(__MINGW32__) || defined(_MSC_VER) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
 | ||||
|  #if defined(FST_MACOSX) || defined(__MINGW32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ | ||||
| -    defined(__NetBSD__)
 | ||||
| +    defined(__NetBSD__) || defined(_MSC_VER)
 | ||||
|  #define FST_UNBUFFERED_IO | ||||
|  #endif | ||||
|   | ||||
|  |  | |||
|  | @ -7,10 +7,10 @@ | |||
| -#include <zlib.h>
 | ||||
|  #include <inttypes.h> | ||||
|  #if defined(_MSC_VER) | ||||
| +    #include "libs/zlib/zlib.h"
 | ||||
|      #include "fst_win_unistd.h" | ||||
| +#include "libs/zlib/zlib.h"
 | ||||
|  #include "fst_win_unistd.h" | ||||
|  #else | ||||
| +    #include <zlib.h>
 | ||||
|      #include <unistd.h> | ||||
| +#include <zlib.h>
 | ||||
|  #include <unistd.h> | ||||
|  #endif | ||||
|  #include <time.h> | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| --- fstapi.cc
 | ||||
| +++ fstapi.cc
 | ||||
| @@ -6072,6 +6072,7 @@ for(;;)
 | ||||
|                                                                  } | ||||
|                                          } | ||||
|   | ||||
|                                                          wx_len = snprintf(wx_buf, 32, "r%.16g", d); | ||||
| +                                                        if (wx_len > 32 || wx_len < 0) wx_len = 32;
 | ||||
|                                                          fstWritex(xc, wx_buf, wx_len); | ||||
|                                                          } | ||||
|                                                  } | ||||
|                                  wx_len = snprintf(wx_buf, 32, "r%.16g", d); | ||||
| +                                if (wx_len > 32 || wx_len < 0) wx_len = 32;
 | ||||
|                                  fstWritex(xc, wx_buf, wx_len); | ||||
|                                  } | ||||
|                          } | ||||
|  |  | |||
|  | @ -2,9 +2,10 @@ | |||
| 
 | ||||
| mv config.h config.h.bak | ||||
| rm -f *.txt *.cc *.h | ||||
| git clone --depth 1 https://github.com/gtkwave/gtkwave fst_upstream | ||||
| rm fst_upstream/lib/libfst/CMakeLists.txt | ||||
| mv fst_upstream/lib/libfst/*.{h,c,txt} . | ||||
| git clone --depth 1 https://github.com/gtkwave/libfst fst_upstream | ||||
| rm fst_upstream/src/meson.build | ||||
| mv fst_upstream/src/*.{h,c} . | ||||
| mv fst_upstream/doc/block_format.txt . | ||||
| rm -rf fst_upstream | ||||
| 
 | ||||
| for src in *.c; do | ||||
|  |  | |||
							
								
								
									
										10227
									
								
								libs/fst/fstapi.cc
									
										
									
									
									
								
							
							
						
						
									
										10227
									
								
								libs/fst/fstapi.cc
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -26,7 +26,8 @@ | |||
| #define FST_API_H | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| extern "C" | ||||
| { | ||||
| #endif | ||||
| 
 | ||||
| #include <stdio.h> | ||||
|  | @ -35,430 +36,510 @@ extern "C" { | |||
| #include <ctype.h> | ||||
| #include <inttypes.h> | ||||
| #if defined(_MSC_VER) | ||||
|     #include "libs/zlib/zlib.h" | ||||
|     #include "fst_win_unistd.h" | ||||
| #include "libs/zlib/zlib.h" | ||||
| #include "fst_win_unistd.h" | ||||
| #else | ||||
|     #include <zlib.h> | ||||
|     #include <unistd.h> | ||||
| #include <zlib.h> | ||||
| #include <unistd.h> | ||||
| #endif | ||||
| #include <time.h> | ||||
| 
 | ||||
| #define FST_RDLOAD "FSTLOAD | " | ||||
| 
 | ||||
| typedef uint32_t fstHandle; | ||||
| typedef uint32_t fstEnumHandle; | ||||
| 
 | ||||
| enum fstWriterPackType { | ||||
|     FST_WR_PT_ZLIB             = 0, | ||||
|     FST_WR_PT_FASTLZ           = 1, | ||||
|     FST_WR_PT_LZ4              = 2 | ||||
| enum fstWriterPackType | ||||
| { | ||||
|     FST_WR_PT_ZLIB = 0, | ||||
|     FST_WR_PT_FASTLZ = 1, | ||||
|     FST_WR_PT_LZ4 = 2 | ||||
| }; | ||||
| 
 | ||||
| enum fstFileType { | ||||
|     FST_FT_MIN                 = 0, | ||||
| enum fstFileType | ||||
| { | ||||
|     FST_FT_MIN = 0, | ||||
| 
 | ||||
|     FST_FT_VERILOG             = 0, | ||||
|     FST_FT_VHDL                = 1, | ||||
|     FST_FT_VERILOG_VHDL        = 2, | ||||
|     FST_FT_VERILOG = 0, | ||||
|     FST_FT_VHDL = 1, | ||||
|     FST_FT_VERILOG_VHDL = 2, | ||||
| 
 | ||||
|     FST_FT_MAX                 = 2 | ||||
|     FST_FT_MAX = 2 | ||||
| }; | ||||
| 
 | ||||
| enum fstBlockType { | ||||
|     FST_BL_HDR                 = 0, | ||||
|     FST_BL_VCDATA              = 1, | ||||
|     FST_BL_BLACKOUT            = 2, | ||||
|     FST_BL_GEOM                = 3, | ||||
|     FST_BL_HIER                = 4, | ||||
|     FST_BL_VCDATA_DYN_ALIAS    = 5, | ||||
|     FST_BL_HIER_LZ4            = 6, | ||||
|     FST_BL_HIER_LZ4DUO         = 7, | ||||
|     FST_BL_VCDATA_DYN_ALIAS2   = 8, | ||||
| enum fstBlockType | ||||
| { | ||||
|     FST_BL_HDR = 0, | ||||
|     FST_BL_VCDATA = 1, | ||||
|     FST_BL_BLACKOUT = 2, | ||||
|     FST_BL_GEOM = 3, | ||||
|     FST_BL_HIER = 4, | ||||
|     FST_BL_VCDATA_DYN_ALIAS = 5, | ||||
|     FST_BL_HIER_LZ4 = 6, | ||||
|     FST_BL_HIER_LZ4DUO = 7, | ||||
|     FST_BL_VCDATA_DYN_ALIAS2 = 8, | ||||
| 
 | ||||
|     FST_BL_ZWRAPPER            = 254,   /* indicates that whole trace is gz wrapped */ | ||||
|     FST_BL_SKIP                = 255    /* used while block is being written */ | ||||
|     FST_BL_ZWRAPPER = 254, /* indicates that whole trace is gz wrapped */ | ||||
|     FST_BL_SKIP = 255 /* used while block is being written */ | ||||
| }; | ||||
| 
 | ||||
| enum fstScopeType { | ||||
|     FST_ST_MIN                 = 0, | ||||
| enum fstScopeType | ||||
| { | ||||
|     FST_ST_MIN = 0, | ||||
| 
 | ||||
|     FST_ST_VCD_MODULE          = 0, | ||||
|     FST_ST_VCD_TASK            = 1, | ||||
|     FST_ST_VCD_FUNCTION        = 2, | ||||
|     FST_ST_VCD_BEGIN           = 3, | ||||
|     FST_ST_VCD_FORK            = 4, | ||||
|     FST_ST_VCD_GENERATE        = 5, | ||||
|     FST_ST_VCD_STRUCT          = 6, | ||||
|     FST_ST_VCD_UNION           = 7, | ||||
|     FST_ST_VCD_CLASS           = 8, | ||||
|     FST_ST_VCD_INTERFACE       = 9, | ||||
|     FST_ST_VCD_PACKAGE         = 10, | ||||
|     FST_ST_VCD_PROGRAM         = 11, | ||||
|     FST_ST_VCD_MODULE = 0, | ||||
|     FST_ST_VCD_TASK = 1, | ||||
|     FST_ST_VCD_FUNCTION = 2, | ||||
|     FST_ST_VCD_BEGIN = 3, | ||||
|     FST_ST_VCD_FORK = 4, | ||||
|     FST_ST_VCD_GENERATE = 5, | ||||
|     FST_ST_VCD_STRUCT = 6, | ||||
|     FST_ST_VCD_UNION = 7, | ||||
|     FST_ST_VCD_CLASS = 8, | ||||
|     FST_ST_VCD_INTERFACE = 9, | ||||
|     FST_ST_VCD_PACKAGE = 10, | ||||
|     FST_ST_VCD_PROGRAM = 11, | ||||
| 
 | ||||
|     FST_ST_VHDL_ARCHITECTURE   = 12, | ||||
|     FST_ST_VHDL_PROCEDURE      = 13, | ||||
|     FST_ST_VHDL_FUNCTION       = 14, | ||||
|     FST_ST_VHDL_RECORD         = 15, | ||||
|     FST_ST_VHDL_PROCESS        = 16, | ||||
|     FST_ST_VHDL_BLOCK          = 17, | ||||
|     FST_ST_VHDL_FOR_GENERATE   = 18, | ||||
|     FST_ST_VHDL_IF_GENERATE    = 19, | ||||
|     FST_ST_VHDL_GENERATE       = 20, | ||||
|     FST_ST_VHDL_PACKAGE        = 21, | ||||
|     FST_ST_VHDL_ARCHITECTURE = 12, | ||||
|     FST_ST_VHDL_PROCEDURE = 13, | ||||
|     FST_ST_VHDL_FUNCTION = 14, | ||||
|     FST_ST_VHDL_RECORD = 15, | ||||
|     FST_ST_VHDL_PROCESS = 16, | ||||
|     FST_ST_VHDL_BLOCK = 17, | ||||
|     FST_ST_VHDL_FOR_GENERATE = 18, | ||||
|     FST_ST_VHDL_IF_GENERATE = 19, | ||||
|     FST_ST_VHDL_GENERATE = 20, | ||||
|     FST_ST_VHDL_PACKAGE = 21, | ||||
| 
 | ||||
|     FST_ST_MAX                 = 21, | ||||
|     FST_ST_MAX = 21, | ||||
| 
 | ||||
|     FST_ST_GEN_ATTRBEGIN       = 252, | ||||
|     FST_ST_GEN_ATTREND         = 253, | ||||
|     FST_ST_GEN_ATTRBEGIN = 252, | ||||
|     FST_ST_GEN_ATTREND = 253, | ||||
| 
 | ||||
|     FST_ST_VCD_SCOPE           = 254, | ||||
|     FST_ST_VCD_UPSCOPE         = 255 | ||||
|     FST_ST_VCD_SCOPE = 254, | ||||
|     FST_ST_VCD_UPSCOPE = 255 | ||||
| }; | ||||
| 
 | ||||
| enum fstVarType { | ||||
|     FST_VT_MIN                 = 0,     /* start of vartypes */ | ||||
| enum fstVarType | ||||
| { | ||||
|     FST_VT_MIN = 0, /* start of vartypes */ | ||||
| 
 | ||||
|     FST_VT_VCD_EVENT           = 0, | ||||
|     FST_VT_VCD_INTEGER         = 1, | ||||
|     FST_VT_VCD_PARAMETER       = 2, | ||||
|     FST_VT_VCD_REAL            = 3, | ||||
|     FST_VT_VCD_REAL_PARAMETER  = 4, | ||||
|     FST_VT_VCD_REG             = 5, | ||||
|     FST_VT_VCD_SUPPLY0         = 6, | ||||
|     FST_VT_VCD_SUPPLY1         = 7, | ||||
|     FST_VT_VCD_TIME            = 8, | ||||
|     FST_VT_VCD_TRI             = 9, | ||||
|     FST_VT_VCD_TRIAND          = 10, | ||||
|     FST_VT_VCD_TRIOR           = 11, | ||||
|     FST_VT_VCD_TRIREG          = 12, | ||||
|     FST_VT_VCD_TRI0            = 13, | ||||
|     FST_VT_VCD_TRI1            = 14, | ||||
|     FST_VT_VCD_WAND            = 15, | ||||
|     FST_VT_VCD_WIRE            = 16, | ||||
|     FST_VT_VCD_WOR             = 17, | ||||
|     FST_VT_VCD_PORT            = 18, | ||||
|     FST_VT_VCD_SPARRAY         = 19,    /* used to define the rownum (index) port for a sparse array */ | ||||
|     FST_VT_VCD_REALTIME        = 20, | ||||
|     FST_VT_VCD_EVENT = 0, | ||||
|     FST_VT_VCD_INTEGER = 1, | ||||
|     FST_VT_VCD_PARAMETER = 2, | ||||
|     FST_VT_VCD_REAL = 3, | ||||
|     FST_VT_VCD_REAL_PARAMETER = 4, | ||||
|     FST_VT_VCD_REG = 5, | ||||
|     FST_VT_VCD_SUPPLY0 = 6, | ||||
|     FST_VT_VCD_SUPPLY1 = 7, | ||||
|     FST_VT_VCD_TIME = 8, | ||||
|     FST_VT_VCD_TRI = 9, | ||||
|     FST_VT_VCD_TRIAND = 10, | ||||
|     FST_VT_VCD_TRIOR = 11, | ||||
|     FST_VT_VCD_TRIREG = 12, | ||||
|     FST_VT_VCD_TRI0 = 13, | ||||
|     FST_VT_VCD_TRI1 = 14, | ||||
|     FST_VT_VCD_WAND = 15, | ||||
|     FST_VT_VCD_WIRE = 16, | ||||
|     FST_VT_VCD_WOR = 17, | ||||
|     FST_VT_VCD_PORT = 18, | ||||
|     FST_VT_VCD_SPARRAY = 19, /* used to define the rownum (index) port for a sparse array */ | ||||
|     FST_VT_VCD_REALTIME = 20, | ||||
| 
 | ||||
|     FST_VT_GEN_STRING          = 21,    /* generic string type   (max len is defined dynamically via fstWriterEmitVariableLengthValueChange) */ | ||||
|     FST_VT_GEN_STRING = 21, /* generic string type   (max len is defined dynamically via
 | ||||
|                                 fstWriterEmitVariableLengthValueChange) */ | ||||
| 
 | ||||
|     FST_VT_SV_BIT              = 22, | ||||
|     FST_VT_SV_LOGIC            = 23, | ||||
|     FST_VT_SV_INT              = 24,    /* declare as size = 32 */ | ||||
|     FST_VT_SV_SHORTINT         = 25,    /* declare as size = 16 */ | ||||
|     FST_VT_SV_LONGINT          = 26,    /* declare as size = 64 */ | ||||
|     FST_VT_SV_BYTE             = 27,    /* declare as size = 8  */ | ||||
|     FST_VT_SV_ENUM             = 28,    /* declare as appropriate type range */ | ||||
|     FST_VT_SV_SHORTREAL        = 29,    /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted as double, not a float) */ | ||||
|     FST_VT_SV_BIT = 22, | ||||
|     FST_VT_SV_LOGIC = 23, | ||||
|     FST_VT_SV_INT = 24, /* declare as size = 32 */ | ||||
|     FST_VT_SV_SHORTINT = 25, /* declare as size = 16 */ | ||||
|     FST_VT_SV_LONGINT = 26, /* declare as size = 64 */ | ||||
|     FST_VT_SV_BYTE = 27, /* declare as size = 8  */ | ||||
|     FST_VT_SV_ENUM = 28, /* declare as appropriate type range */ | ||||
|     FST_VT_SV_SHORTREAL = 29, /* declare and emit same as FST_VT_VCD_REAL (needs to be emitted
 | ||||
|                                     as double, not a float) */ | ||||
| 
 | ||||
|     FST_VT_MAX                 = 29     /* end of vartypes */ | ||||
|     FST_VT_MAX = 29 /* end of vartypes */ | ||||
| }; | ||||
| 
 | ||||
| enum fstVarDir { | ||||
|     FST_VD_MIN         = 0, | ||||
| enum fstVarDir | ||||
| { | ||||
|     FST_VD_MIN = 0, | ||||
| 
 | ||||
|     FST_VD_IMPLICIT    = 0, | ||||
|     FST_VD_INPUT       = 1, | ||||
|     FST_VD_OUTPUT      = 2, | ||||
|     FST_VD_INOUT       = 3, | ||||
|     FST_VD_BUFFER      = 4, | ||||
|     FST_VD_LINKAGE     = 5, | ||||
|     FST_VD_IMPLICIT = 0, | ||||
|     FST_VD_INPUT = 1, | ||||
|     FST_VD_OUTPUT = 2, | ||||
|     FST_VD_INOUT = 3, | ||||
|     FST_VD_BUFFER = 4, | ||||
|     FST_VD_LINKAGE = 5, | ||||
| 
 | ||||
|     FST_VD_MAX         = 5 | ||||
|     FST_VD_MAX = 5 | ||||
| }; | ||||
| 
 | ||||
| enum fstHierType { | ||||
|     FST_HT_MIN         = 0, | ||||
| enum fstHierType | ||||
| { | ||||
|     FST_HT_MIN = 0, | ||||
| 
 | ||||
|     FST_HT_SCOPE       = 0, | ||||
|     FST_HT_UPSCOPE     = 1, | ||||
|     FST_HT_VAR         = 2, | ||||
|     FST_HT_ATTRBEGIN   = 3, | ||||
|     FST_HT_ATTREND     = 4, | ||||
|     FST_HT_SCOPE = 0, | ||||
|     FST_HT_UPSCOPE = 1, | ||||
|     FST_HT_VAR = 2, | ||||
|     FST_HT_ATTRBEGIN = 3, | ||||
|     FST_HT_ATTREND = 4, | ||||
| 
 | ||||
|     /* FST_HT_TREEBEGIN and FST_HT_TREEEND are not yet used by FST but are currently used when fstHier bridges other formats */ | ||||
|     FST_HT_TREEBEGIN   = 5, | ||||
|     FST_HT_TREEEND     = 6, | ||||
|     /* FST_HT_TREEBEGIN and FST_HT_TREEEND are not yet used by FST but are currently used when
 | ||||
|         fstHier bridges other formats */ | ||||
|     FST_HT_TREEBEGIN = 5, | ||||
|     FST_HT_TREEEND = 6, | ||||
| 
 | ||||
|     FST_HT_MAX         = 6 | ||||
|     FST_HT_MAX = 6 | ||||
| }; | ||||
| 
 | ||||
| enum fstAttrType { | ||||
|     FST_AT_MIN         = 0, | ||||
| enum fstAttrType | ||||
| { | ||||
|     FST_AT_MIN = 0, | ||||
| 
 | ||||
|     FST_AT_MISC        = 0,     /* self-contained: does not need matching FST_HT_ATTREND */ | ||||
|     FST_AT_ARRAY       = 1, | ||||
|     FST_AT_ENUM        = 2, | ||||
|     FST_AT_PACK        = 3, | ||||
|     FST_AT_MISC = 0, /* self-contained: does not need matching FST_HT_ATTREND */ | ||||
|     FST_AT_ARRAY = 1, | ||||
|     FST_AT_ENUM = 2, | ||||
|     FST_AT_PACK = 3, | ||||
| 
 | ||||
|     FST_AT_MAX         = 3 | ||||
|     FST_AT_MAX = 3 | ||||
| }; | ||||
| 
 | ||||
| enum fstMiscType { | ||||
|     FST_MT_MIN         = 0, | ||||
| enum fstMiscType | ||||
| { | ||||
|     FST_MT_MIN = 0, | ||||
| 
 | ||||
|     FST_MT_COMMENT     = 0,     /* use fstWriterSetComment() to emit */ | ||||
|     FST_MT_ENVVAR      = 1,     /* use fstWriterSetEnvVar() to emit */ | ||||
|     FST_MT_SUPVAR      = 2,     /* use fstWriterCreateVar2() to emit */ | ||||
|     FST_MT_PATHNAME    = 3,     /* reserved for fstWriterSetSourceStem() string -> number management */ | ||||
|     FST_MT_SOURCESTEM  = 4,     /* use fstWriterSetSourceStem() to emit */ | ||||
|     FST_MT_SOURCEISTEM = 5,     /* use fstWriterSetSourceInstantiationStem() to emit */ | ||||
|     FST_MT_VALUELIST   = 6,	/* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */ | ||||
|     FST_MT_ENUMTABLE   = 7,	/* use fstWriterCreateEnumTable() and fstWriterEmitEnumTableRef() to emit */ | ||||
|     FST_MT_UNKNOWN     = 8, | ||||
|     FST_MT_COMMENT = 0, /* use fstWriterSetComment() to emit */ | ||||
|     FST_MT_ENVVAR = 1, /* use fstWriterSetEnvVar() to emit */ | ||||
|     FST_MT_SUPVAR = 2, /* use fstWriterCreateVar2() to emit */ | ||||
|     FST_MT_PATHNAME = 3, /* reserved for fstWriterSetSourceStem() string -> number management */ | ||||
|     FST_MT_SOURCESTEM = 4, /* use fstWriterSetSourceStem() to emit */ | ||||
|     FST_MT_SOURCEISTEM = 5, /* use fstWriterSetSourceInstantiationStem() to emit */ | ||||
|     FST_MT_VALUELIST = | ||||
|         6, /* use fstWriterSetValueList() to emit, followed by fstWriterCreateVar*() */ | ||||
|     FST_MT_ENUMTABLE = | ||||
|         7, /* use fstWriterCreateEnumTable() and fstWriterEmitEnumTableRef() to emit */ | ||||
|     FST_MT_UNKNOWN = 8, | ||||
| 
 | ||||
|     FST_MT_MAX         = 8 | ||||
|     FST_MT_MAX = 8 | ||||
| }; | ||||
| 
 | ||||
| enum fstArrayType { | ||||
|     FST_AR_MIN         = 0, | ||||
| enum fstArrayType | ||||
| { | ||||
|     FST_AR_MIN = 0, | ||||
| 
 | ||||
|     FST_AR_NONE        = 0, | ||||
|     FST_AR_UNPACKED    = 1, | ||||
|     FST_AR_PACKED      = 2, | ||||
|     FST_AR_SPARSE      = 3, | ||||
|     FST_AR_NONE = 0, | ||||
|     FST_AR_UNPACKED = 1, | ||||
|     FST_AR_PACKED = 2, | ||||
|     FST_AR_SPARSE = 3, | ||||
| 
 | ||||
|     FST_AR_MAX         = 3 | ||||
|     FST_AR_MAX = 3 | ||||
| }; | ||||
| 
 | ||||
| enum fstEnumValueType { | ||||
|     FST_EV_SV_INTEGER           = 0, | ||||
|     FST_EV_SV_BIT               = 1, | ||||
|     FST_EV_SV_LOGIC             = 2, | ||||
|     FST_EV_SV_INT               = 3, | ||||
|     FST_EV_SV_SHORTINT          = 4, | ||||
|     FST_EV_SV_LONGINT           = 5, | ||||
|     FST_EV_SV_BYTE              = 6, | ||||
|     FST_EV_SV_UNSIGNED_INTEGER  = 7, | ||||
|     FST_EV_SV_UNSIGNED_BIT      = 8, | ||||
|     FST_EV_SV_UNSIGNED_LOGIC    = 9, | ||||
|     FST_EV_SV_UNSIGNED_INT      = 10, | ||||
| enum fstEnumValueType | ||||
| { | ||||
|     FST_EV_SV_INTEGER = 0, | ||||
|     FST_EV_SV_BIT = 1, | ||||
|     FST_EV_SV_LOGIC = 2, | ||||
|     FST_EV_SV_INT = 3, | ||||
|     FST_EV_SV_SHORTINT = 4, | ||||
|     FST_EV_SV_LONGINT = 5, | ||||
|     FST_EV_SV_BYTE = 6, | ||||
|     FST_EV_SV_UNSIGNED_INTEGER = 7, | ||||
|     FST_EV_SV_UNSIGNED_BIT = 8, | ||||
|     FST_EV_SV_UNSIGNED_LOGIC = 9, | ||||
|     FST_EV_SV_UNSIGNED_INT = 10, | ||||
|     FST_EV_SV_UNSIGNED_SHORTINT = 11, | ||||
|     FST_EV_SV_UNSIGNED_LONGINT  = 12, | ||||
|     FST_EV_SV_UNSIGNED_BYTE     = 13, | ||||
|     FST_EV_SV_UNSIGNED_LONGINT = 12, | ||||
|     FST_EV_SV_UNSIGNED_BYTE = 13, | ||||
| 
 | ||||
|     FST_EV_REG			= 14, | ||||
|     FST_EV_TIME			= 15, | ||||
|     FST_EV_REG = 14, | ||||
|     FST_EV_TIME = 15, | ||||
| 
 | ||||
|     FST_EV_MAX                  = 15 | ||||
|     FST_EV_MAX = 15 | ||||
| }; | ||||
| 
 | ||||
| enum fstPackType { | ||||
|     FST_PT_NONE          = 0, | ||||
|     FST_PT_UNPACKED      = 1, | ||||
|     FST_PT_PACKED        = 2, | ||||
| enum fstPackType | ||||
| { | ||||
|     FST_PT_NONE = 0, | ||||
|     FST_PT_UNPACKED = 1, | ||||
|     FST_PT_PACKED = 2, | ||||
|     FST_PT_TAGGED_PACKED = 3, | ||||
| 
 | ||||
|     FST_PT_MAX           = 3 | ||||
|     FST_PT_MAX = 3 | ||||
| }; | ||||
| 
 | ||||
| enum fstSupplementalVarType { | ||||
|     FST_SVT_MIN                    = 0, | ||||
| enum fstSupplementalVarType | ||||
| { | ||||
|     FST_SVT_MIN = 0, | ||||
| 
 | ||||
|     FST_SVT_NONE                   = 0, | ||||
|     FST_SVT_NONE = 0, | ||||
| 
 | ||||
|     FST_SVT_VHDL_SIGNAL            = 1, | ||||
|     FST_SVT_VHDL_VARIABLE          = 2, | ||||
|     FST_SVT_VHDL_CONSTANT          = 3, | ||||
|     FST_SVT_VHDL_FILE              = 4, | ||||
|     FST_SVT_VHDL_MEMORY            = 5, | ||||
|     FST_SVT_VHDL_SIGNAL = 1, | ||||
|     FST_SVT_VHDL_VARIABLE = 2, | ||||
|     FST_SVT_VHDL_CONSTANT = 3, | ||||
|     FST_SVT_VHDL_FILE = 4, | ||||
|     FST_SVT_VHDL_MEMORY = 5, | ||||
| 
 | ||||
|     FST_SVT_MAX                    = 5 | ||||
|     FST_SVT_MAX = 5 | ||||
| }; | ||||
| 
 | ||||
| enum fstSupplementalDataType { | ||||
|     FST_SDT_MIN                    = 0, | ||||
| enum fstSupplementalDataType | ||||
| { | ||||
|     FST_SDT_MIN = 0, | ||||
| 
 | ||||
|     FST_SDT_NONE                   = 0, | ||||
|     FST_SDT_NONE = 0, | ||||
| 
 | ||||
|     FST_SDT_VHDL_BOOLEAN           = 1, | ||||
|     FST_SDT_VHDL_BIT               = 2, | ||||
|     FST_SDT_VHDL_BIT_VECTOR        = 3, | ||||
|     FST_SDT_VHDL_STD_ULOGIC        = 4, | ||||
|     FST_SDT_VHDL_BOOLEAN = 1, | ||||
|     FST_SDT_VHDL_BIT = 2, | ||||
|     FST_SDT_VHDL_BIT_VECTOR = 3, | ||||
|     FST_SDT_VHDL_STD_ULOGIC = 4, | ||||
|     FST_SDT_VHDL_STD_ULOGIC_VECTOR = 5, | ||||
|     FST_SDT_VHDL_STD_LOGIC         = 6, | ||||
|     FST_SDT_VHDL_STD_LOGIC_VECTOR  = 7, | ||||
|     FST_SDT_VHDL_UNSIGNED          = 8, | ||||
|     FST_SDT_VHDL_SIGNED            = 9, | ||||
|     FST_SDT_VHDL_INTEGER           = 10, | ||||
|     FST_SDT_VHDL_REAL              = 11, | ||||
|     FST_SDT_VHDL_NATURAL           = 12, | ||||
|     FST_SDT_VHDL_POSITIVE          = 13, | ||||
|     FST_SDT_VHDL_TIME              = 14, | ||||
|     FST_SDT_VHDL_CHARACTER         = 15, | ||||
|     FST_SDT_VHDL_STRING            = 16, | ||||
|     FST_SDT_VHDL_STD_LOGIC = 6, | ||||
|     FST_SDT_VHDL_STD_LOGIC_VECTOR = 7, | ||||
|     FST_SDT_VHDL_UNSIGNED = 8, | ||||
|     FST_SDT_VHDL_SIGNED = 9, | ||||
|     FST_SDT_VHDL_INTEGER = 10, | ||||
|     FST_SDT_VHDL_REAL = 11, | ||||
|     FST_SDT_VHDL_NATURAL = 12, | ||||
|     FST_SDT_VHDL_POSITIVE = 13, | ||||
|     FST_SDT_VHDL_TIME = 14, | ||||
|     FST_SDT_VHDL_CHARACTER = 15, | ||||
|     FST_SDT_VHDL_STRING = 16, | ||||
| 
 | ||||
|     FST_SDT_MAX                    = 16, | ||||
|     FST_SDT_MAX = 16, | ||||
| 
 | ||||
|     FST_SDT_SVT_SHIFT_COUNT        = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left after shifting FST_SDT_SVT_SHIFT_COUNT */ | ||||
|     FST_SDT_ABS_MAX                = ((1<<(FST_SDT_SVT_SHIFT_COUNT))-1) | ||||
|     FST_SDT_SVT_SHIFT_COUNT = 10, /* FST_SVT_* is ORed in by fstWriterCreateVar2() to the left
 | ||||
|                                         after shifting FST_SDT_SVT_SHIFT_COUNT */ | ||||
|     FST_SDT_ABS_MAX = ((1 << (FST_SDT_SVT_SHIFT_COUNT)) - 1) | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| struct fstHier | ||||
| { | ||||
| unsigned char htyp; | ||||
|     unsigned char htyp; | ||||
| 
 | ||||
| union { | ||||
|     union | ||||
|     { | ||||
|         /* if htyp == FST_HT_SCOPE */ | ||||
|         struct fstHierScope { | ||||
|                 unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */ | ||||
|                 const char *name; | ||||
|                 const char *component; | ||||
|                 uint32_t name_length;           /* strlen(u.scope.name) */ | ||||
|                 uint32_t component_length;      /* strlen(u.scope.component) */ | ||||
|                 } scope; | ||||
|         struct fstHierScope | ||||
|         { | ||||
|             unsigned char typ; /* FST_ST_MIN ... FST_ST_MAX */ | ||||
|             const char *name; | ||||
|             const char *component; | ||||
|             uint32_t name_length; /* strlen(u.scope.name) */ | ||||
|             uint32_t component_length; /* strlen(u.scope.component) */ | ||||
|         } scope; | ||||
| 
 | ||||
|         /* if htyp == FST_HT_VAR */ | ||||
|         struct fstHierVar { | ||||
|                 unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */ | ||||
|                 unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */ | ||||
|                 unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|                 unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|                 unsigned int  sxt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|                 const char *name; | ||||
|                 uint32_t length; | ||||
|                 fstHandle handle; | ||||
|                 uint32_t name_length; /* strlen(u.var.name) */ | ||||
|                 unsigned is_alias : 1; | ||||
|                 } var; | ||||
|         struct fstHierVar | ||||
|         { | ||||
|             unsigned char typ; /* FST_VT_MIN ... FST_VT_MAX */ | ||||
|             unsigned char direction; /* FST_VD_MIN ... FST_VD_MAX */ | ||||
|             unsigned char svt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|             unsigned char sdt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|             unsigned int sxt_workspace; /* zeroed out by FST reader, for client code use */ | ||||
|             const char *name; | ||||
|             uint32_t length; | ||||
|             fstHandle handle; | ||||
|             uint32_t name_length; /* strlen(u.var.name) */ | ||||
|             unsigned is_alias : 1; | ||||
|         } var; | ||||
| 
 | ||||
|         /* if htyp == FST_HT_ATTRBEGIN */ | ||||
|         struct fstHierAttr { | ||||
|                 unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */ | ||||
|                 unsigned char subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */ | ||||
|                 const char *name; | ||||
|                 uint64_t arg; /* number of array elements, struct members, or some other payload (possibly ignored) */ | ||||
|                 uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer (FST_AT_MISC + FST_MT_SOURCESTEM) */ | ||||
|                 uint32_t name_length; /* strlen(u.attr.name) */ | ||||
|                 } attr; | ||||
|         } u; | ||||
|         struct fstHierAttr | ||||
|         { | ||||
|             unsigned char typ; /* FST_AT_MIN ... FST_AT_MAX */ | ||||
|             unsigned char | ||||
|                 subtype; /* from fstMiscType, fstArrayType, fstEnumValueType, fstPackType */ | ||||
|             const char *name; | ||||
|             uint64_t arg; /* number of array elements, struct members, or some other payload
 | ||||
|                                 (possibly ignored) */ | ||||
|             uint64_t arg_from_name; /* for when name is overloaded as a variable-length integer
 | ||||
|                                         (FST_AT_MISC + FST_MT_SOURCESTEM) */ | ||||
|             uint32_t name_length; /* strlen(u.attr.name) */ | ||||
|         } attr; | ||||
|     } u; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| struct fstETab | ||||
| { | ||||
| char *name; | ||||
| uint32_t elem_count; | ||||
| char **literal_arr; | ||||
| char **val_arr; | ||||
|     char *name; | ||||
|     uint32_t elem_count; | ||||
|     char **literal_arr; | ||||
|     char **val_arr; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
|  * writer functions | ||||
|  */ | ||||
| void            fstWriterClose(void *ctx); | ||||
| void *          fstWriterCreate(const char *nam, int use_compressed_hier); | ||||
| fstEnumHandle   fstWriterCreateEnumTable(void *ctx, const char *name, uint32_t elem_count, unsigned int min_valbits, const char **literal_arr, const char **val_arr); | ||||
|                 /* used for Verilog/SV */ | ||||
| fstHandle       fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd, | ||||
|                         uint32_t len, const char *nam, fstHandle aliasHandle); | ||||
|                 /* future expansion for VHDL and other languages.  The variable type, data type, etc map onto
 | ||||
|                    the current Verilog/SV one.  The "type" string is optional for a more verbose or custom description */ | ||||
| fstHandle       fstWriterCreateVar2(void *ctx, enum fstVarType vt, enum fstVarDir vd, | ||||
|                         uint32_t len, const char *nam, fstHandle aliasHandle, | ||||
|                         const char *type, enum fstSupplementalVarType svt, enum fstSupplementalDataType sdt); | ||||
| void            fstWriterEmitDumpActive(void *ctx, int enable); | ||||
| void 		fstWriterEmitEnumTableRef(void *ctx, fstEnumHandle handle); | ||||
| void            fstWriterEmitValueChange(void *ctx, fstHandle handle, const void *val); | ||||
| void            fstWriterEmitValueChange32(void *ctx, fstHandle handle, | ||||
|                         uint32_t bits, uint32_t val); | ||||
| void            fstWriterEmitValueChange64(void *ctx, fstHandle handle, | ||||
|                         uint32_t bits, uint64_t val); | ||||
| void            fstWriterEmitValueChangeVec32(void *ctx, fstHandle handle, | ||||
|                         uint32_t bits, const uint32_t *val); | ||||
| void            fstWriterEmitValueChangeVec64(void *ctx, fstHandle handle, | ||||
|                         uint32_t bits, const uint64_t *val); | ||||
| void            fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len); | ||||
| void            fstWriterEmitTimeChange(void *ctx, uint64_t tim); | ||||
| void            fstWriterFlushContext(void *ctx); | ||||
| int             fstWriterGetDumpSizeLimitReached(void *ctx); | ||||
| int             fstWriterGetFseekFailed(void *ctx); | ||||
| void            fstWriterSetAttrBegin(void *ctx, enum fstAttrType attrtype, int subtype, | ||||
|                         const char *attrname, uint64_t arg); | ||||
| void            fstWriterSetAttrEnd(void *ctx); | ||||
| void            fstWriterSetComment(void *ctx, const char *comm); | ||||
| void            fstWriterSetDate(void *ctx, const char *dat); | ||||
| void            fstWriterSetDumpSizeLimit(void *ctx, uint64_t numbytes); | ||||
| void            fstWriterSetEnvVar(void *ctx, const char *envvar); | ||||
| void            fstWriterSetFileType(void *ctx, enum fstFileType filetype); | ||||
| void            fstWriterSetPackType(void *ctx, enum fstWriterPackType typ); | ||||
| void            fstWriterSetParallelMode(void *ctx, int enable); | ||||
| void            fstWriterSetRepackOnClose(void *ctx, int enable);       /* type = 0 (none), 1 (libz) */ | ||||
| void            fstWriterSetScope(void *ctx, enum fstScopeType scopetype, | ||||
|                         const char *scopename, const char *scopecomp); | ||||
| void            fstWriterSetSourceInstantiationStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath); | ||||
| void            fstWriterSetSourceStem(void *ctx, const char *path, unsigned int line, unsigned int use_realpath); | ||||
| void            fstWriterSetTimescale(void *ctx, int ts); | ||||
| void            fstWriterSetTimescaleFromString(void *ctx, const char *s); | ||||
| void            fstWriterSetTimezero(void *ctx, int64_t tim); | ||||
| void            fstWriterSetUpscope(void *ctx); | ||||
| void		fstWriterSetValueList(void *ctx, const char *vl); | ||||
| void            fstWriterSetVersion(void *ctx, const char *vers); | ||||
| 
 | ||||
| typedef struct fstWriterContext fstWriterContext; | ||||
| 
 | ||||
| void fstWriterClose(fstWriterContext *ctx); | ||||
| fstWriterContext *fstWriterCreate(const char *nam, int use_compressed_hier); | ||||
| fstEnumHandle fstWriterCreateEnumTable(fstWriterContext *ctx, | ||||
|                                         const char *name, | ||||
|                                         uint32_t elem_count, | ||||
|                                         unsigned int min_valbits, | ||||
|                                         const char **literal_arr, | ||||
|                                         const char **val_arr); | ||||
| /* used for Verilog/SV */ | ||||
| fstHandle fstWriterCreateVar(fstWriterContext *ctx, | ||||
|                                 enum fstVarType vt, | ||||
|                                 enum fstVarDir vd, | ||||
|                                 uint32_t len, | ||||
|                                 const char *nam, | ||||
|                                 fstHandle aliasHandle); | ||||
| /* future expansion for VHDL and other languages.  The variable type, data type, etc map onto
 | ||||
|     the current Verilog/SV one.  The "type" string is optional for a more verbose or custom | ||||
|     description */ | ||||
| fstHandle fstWriterCreateVar2(fstWriterContext *ctx, | ||||
|                                 enum fstVarType vt, | ||||
|                                 enum fstVarDir vd, | ||||
|                                 uint32_t len, | ||||
|                                 const char *nam, | ||||
|                                 fstHandle aliasHandle, | ||||
|                                 const char *type, | ||||
|                                 enum fstSupplementalVarType svt, | ||||
|                                 enum fstSupplementalDataType sdt); | ||||
| void fstWriterEmitDumpActive(fstWriterContext *ctx, int enable); | ||||
| void fstWriterEmitEnumTableRef(fstWriterContext *ctx, fstEnumHandle handle); | ||||
| void fstWriterEmitValueChange(fstWriterContext *ctx, fstHandle handle, const void *val); | ||||
| void fstWriterEmitValueChange32(fstWriterContext *ctx, | ||||
|                                 fstHandle handle, | ||||
|                                 uint32_t bits, | ||||
|                                 uint32_t val); | ||||
| void fstWriterEmitValueChange64(fstWriterContext *ctx, | ||||
|                                 fstHandle handle, | ||||
|                                 uint32_t bits, | ||||
|                                 uint64_t val); | ||||
| void fstWriterEmitValueChangeVec32(fstWriterContext *ctx, | ||||
|                                     fstHandle handle, | ||||
|                                     uint32_t bits, | ||||
|                                     const uint32_t *val); | ||||
| void fstWriterEmitValueChangeVec64(fstWriterContext *ctx, | ||||
|                                     fstHandle handle, | ||||
|                                     uint32_t bits, | ||||
|                                     const uint64_t *val); | ||||
| void fstWriterEmitVariableLengthValueChange(fstWriterContext *ctx, | ||||
|                                             fstHandle handle, | ||||
|                                             const void *val, | ||||
|                                             uint32_t len); | ||||
| void fstWriterEmitTimeChange(fstWriterContext *ctx, uint64_t tim); | ||||
| void fstWriterFlushContext(fstWriterContext *ctx); | ||||
| int fstWriterGetDumpSizeLimitReached(fstWriterContext *ctx); | ||||
| int fstWriterGetFseekFailed(fstWriterContext *ctx); | ||||
| int fstWriterGetFlushContextPending(fstWriterContext *ctx); | ||||
| void fstWriterSetAttrBegin(fstWriterContext *ctx, | ||||
|                             enum fstAttrType attrtype, | ||||
|                             int subtype, | ||||
|                             const char *attrname, | ||||
|                             uint64_t arg); | ||||
| void fstWriterSetAttrEnd(fstWriterContext *ctx); | ||||
| void fstWriterSetComment(fstWriterContext *ctx, const char *comm); | ||||
| void fstWriterSetDate(fstWriterContext *ctx, const char *dat); | ||||
| void fstWriterSetDumpSizeLimit(fstWriterContext *ctx, uint64_t numbytes); | ||||
| void fstWriterSetEnvVar(fstWriterContext *ctx, const char *envvar); | ||||
| void fstWriterSetFileType(fstWriterContext *ctx, enum fstFileType filetype); | ||||
| void fstWriterSetPackType(fstWriterContext *ctx, enum fstWriterPackType typ); | ||||
| void fstWriterSetParallelMode(fstWriterContext *ctx, int enable); | ||||
| void fstWriterSetRepackOnClose(fstWriterContext *ctx, | ||||
|                                 int enable); /* type = 0 (none), 1 (libz) */ | ||||
| void fstWriterSetScope(fstWriterContext *ctx, | ||||
|                         enum fstScopeType scopetype, | ||||
|                         const char *scopename, | ||||
|                         const char *scopecomp); | ||||
| void fstWriterSetSourceInstantiationStem(fstWriterContext *ctx, | ||||
|                                             const char *path, | ||||
|                                             unsigned int line, | ||||
|                                             unsigned int use_realpath); | ||||
| void fstWriterSetSourceStem(fstWriterContext *ctx, | ||||
|                             const char *path, | ||||
|                             unsigned int line, | ||||
|                             unsigned int use_realpath); | ||||
| void fstWriterSetTimescale(fstWriterContext *ctx, int ts); | ||||
| void fstWriterSetTimescaleFromString(fstWriterContext *ctx, const char *s); | ||||
| void fstWriterSetTimezero(fstWriterContext *ctx, int64_t tim); | ||||
| void fstWriterSetUpscope(fstWriterContext *ctx); | ||||
| void fstWriterSetValueList(fstWriterContext *ctx, const char *vl); | ||||
| void fstWriterSetVersion(fstWriterContext *ctx, const char *vers); | ||||
| 
 | ||||
| /*
 | ||||
|  * reader functions | ||||
|  */ | ||||
| void            fstReaderClose(void *ctx); | ||||
| void            fstReaderClrFacProcessMask(void *ctx, fstHandle facidx); | ||||
| void            fstReaderClrFacProcessMaskAll(void *ctx); | ||||
| uint64_t        fstReaderGetAliasCount(void *ctx); | ||||
| const char *    fstReaderGetCurrentFlatScope(void *ctx); | ||||
| void *          fstReaderGetCurrentScopeUserInfo(void *ctx); | ||||
| int             fstReaderGetCurrentScopeLen(void *ctx); | ||||
| const char *    fstReaderGetDateString(void *ctx); | ||||
| int             fstReaderGetDoubleEndianMatchState(void *ctx); | ||||
| uint64_t        fstReaderGetDumpActivityChangeTime(void *ctx, uint32_t idx); | ||||
| unsigned char   fstReaderGetDumpActivityChangeValue(void *ctx, uint32_t idx); | ||||
| uint64_t        fstReaderGetEndTime(void *ctx); | ||||
| int             fstReaderGetFacProcessMask(void *ctx, fstHandle facidx); | ||||
| int             fstReaderGetFileType(void *ctx); | ||||
| int             fstReaderGetFseekFailed(void *ctx); | ||||
| fstHandle       fstReaderGetMaxHandle(void *ctx); | ||||
| uint64_t        fstReaderGetMemoryUsedByWriter(void *ctx); | ||||
| uint32_t        fstReaderGetNumberDumpActivityChanges(void *ctx); | ||||
| uint64_t        fstReaderGetScopeCount(void *ctx); | ||||
| uint64_t        fstReaderGetStartTime(void *ctx); | ||||
| signed char     fstReaderGetTimescale(void *ctx); | ||||
| int64_t         fstReaderGetTimezero(void *ctx); | ||||
| uint64_t        fstReaderGetValueChangeSectionCount(void *ctx); | ||||
| char *          fstReaderGetValueFromHandleAtTime(void *ctx, uint64_t tim, fstHandle facidx, char *buf); | ||||
| uint64_t        fstReaderGetVarCount(void *ctx); | ||||
| const char *    fstReaderGetVersionString(void *ctx); | ||||
| struct fstHier *fstReaderIterateHier(void *ctx); | ||||
| int             fstReaderIterateHierRewind(void *ctx); | ||||
| int             fstReaderIterBlocks(void *ctx, | ||||
|                         void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value), | ||||
|                         void *user_callback_data_pointer, FILE *vcdhandle); | ||||
| int             fstReaderIterBlocks2(void *ctx, | ||||
|                         void (*value_change_callback)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value), | ||||
|                         void (*value_change_callback_varlen)(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value, uint32_t len), | ||||
|                         void *user_callback_data_pointer, FILE *vcdhandle); | ||||
| void            fstReaderIterBlocksSetNativeDoublesOnCallback(void *ctx, int enable); | ||||
| void *          fstReaderOpen(const char *nam); | ||||
| void *          fstReaderOpenForUtilitiesOnly(void); | ||||
| const char *    fstReaderPopScope(void *ctx); | ||||
| int             fstReaderProcessHier(void *ctx, FILE *vcdhandle); | ||||
| const char *    fstReaderPushScope(void *ctx, const char *nam, void *user_info); | ||||
| void            fstReaderResetScope(void *ctx); | ||||
| void            fstReaderSetFacProcessMask(void *ctx, fstHandle facidx); | ||||
| void            fstReaderSetFacProcessMaskAll(void *ctx); | ||||
| void            fstReaderSetLimitTimeRange(void *ctx, uint64_t start_time, uint64_t end_time); | ||||
| void            fstReaderSetUnlimitedTimeRange(void *ctx); | ||||
| void            fstReaderSetVcdExtensions(void *ctx, int enable); | ||||
| 
 | ||||
| typedef struct fstReaderContext fstReaderContext; | ||||
| 
 | ||||
| void fstReaderClose(fstReaderContext *ctx); | ||||
| void fstReaderClrFacProcessMask(fstReaderContext *ctx, fstHandle facidx); | ||||
| void fstReaderClrFacProcessMaskAll(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetAliasCount(fstReaderContext *ctx); | ||||
| const char *fstReaderGetCurrentFlatScope(fstReaderContext *ctx); | ||||
| void *fstReaderGetCurrentScopeUserInfo(fstReaderContext *ctx); | ||||
| int fstReaderGetCurrentScopeLen(fstReaderContext *ctx); | ||||
| const char *fstReaderGetDateString(fstReaderContext *ctx); | ||||
| int fstReaderGetDoubleEndianMatchState(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetDumpActivityChangeTime(fstReaderContext *ctx, uint32_t idx); | ||||
| unsigned char fstReaderGetDumpActivityChangeValue(fstReaderContext *ctx, uint32_t idx); | ||||
| uint64_t fstReaderGetEndTime(fstReaderContext *ctx); | ||||
| int fstReaderGetFacProcessMask(fstReaderContext *ctx, fstHandle facidx); | ||||
| int fstReaderGetFileType(fstReaderContext *ctx); | ||||
| int fstReaderGetFseekFailed(fstReaderContext *ctx); | ||||
| fstHandle fstReaderGetMaxHandle(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetMemoryUsedByWriter(fstReaderContext *ctx); | ||||
| uint32_t fstReaderGetNumberDumpActivityChanges(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetScopeCount(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetStartTime(fstReaderContext *ctx); | ||||
| signed char fstReaderGetTimescale(fstReaderContext *ctx); | ||||
| int64_t fstReaderGetTimezero(fstReaderContext *ctx); | ||||
| uint64_t fstReaderGetValueChangeSectionCount(fstReaderContext *ctx); | ||||
| char *fstReaderGetValueFromHandleAtTime(fstReaderContext *ctx, | ||||
|                                         uint64_t tim, | ||||
|                                         fstHandle facidx, | ||||
|                                         char *buf); | ||||
| uint64_t fstReaderGetVarCount(fstReaderContext *ctx); | ||||
| const char *fstReaderGetVersionString(fstReaderContext *ctx); | ||||
| struct fstHier *fstReaderIterateHier(fstReaderContext *ctx); | ||||
| int fstReaderIterateHierRewind(fstReaderContext *ctx); | ||||
| int fstReaderIterBlocks(fstReaderContext *ctx, | ||||
|                         void (*value_change_callback)(void *user_callback_data_pointer, | ||||
|                                                       uint64_t time, | ||||
|                                                       fstHandle facidx, | ||||
|                                                       const unsigned char *value), | ||||
|                         void *user_callback_data_pointer, | ||||
|                         FILE *vcdhandle); | ||||
| int fstReaderIterBlocks2(fstReaderContext *ctx, | ||||
|                          void (*value_change_callback)(void *user_callback_data_pointer, | ||||
|                                                        uint64_t time, | ||||
|                                                        fstHandle facidx, | ||||
|                                                        const unsigned char *value), | ||||
|                          void (*value_change_callback_varlen)(void *user_callback_data_pointer, | ||||
|                                                               uint64_t time, | ||||
|                                                               fstHandle facidx, | ||||
|                                                               const unsigned char *value, | ||||
|                                                               uint32_t len), | ||||
|                          void *user_callback_data_pointer, | ||||
|                          FILE *vcdhandle); | ||||
| void fstReaderIterBlocksSetNativeDoublesOnCallback(fstReaderContext *ctx, int enable); | ||||
| fstReaderContext *fstReaderOpen(const char *nam); | ||||
| fstReaderContext *fstReaderOpenForUtilitiesOnly(void); | ||||
| const char *fstReaderPopScope(fstReaderContext *ctx); | ||||
| int fstReaderProcessHier(fstReaderContext *ctx, FILE *vcdhandle); | ||||
| const char *fstReaderPushScope(fstReaderContext *ctx, const char *nam, void *user_info); | ||||
| void fstReaderResetScope(fstReaderContext *ctx); | ||||
| void fstReaderSetFacProcessMask(fstReaderContext *ctx, fstHandle facidx); | ||||
| void fstReaderSetFacProcessMaskAll(fstReaderContext *ctx); | ||||
| void fstReaderSetLimitTimeRange(fstReaderContext *ctx, uint64_t start_time, uint64_t end_time); | ||||
| void fstReaderSetUnlimitedTimeRange(fstReaderContext *ctx); | ||||
| void fstReaderSetVcdExtensions(fstReaderContext *ctx, int enable); | ||||
| 
 | ||||
| /*
 | ||||
|  * utility functions | ||||
|  */ | ||||
| int             fstUtilityBinToEscConvertedLen(const unsigned char *s, int len); /* used for mallocs for fstUtilityBinToEsc() */ | ||||
| int             fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len); | ||||
| int             fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len); | ||||
| int fstUtilityBinToEscConvertedLen(const unsigned char *s, int len); /* used for mallocs for fstUtilityBinToEsc() */ | ||||
| int fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len); | ||||
| int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len); | ||||
| struct fstETab *fstUtilityExtractEnumTableFromString(const char *s); | ||||
| void 		fstUtilityFreeEnumTable(struct fstETab *etab); /* must use to free fstETab properly */ | ||||
| 
 | ||||
| void fstUtilityFreeEnumTable(struct fstETab *etab); /* must use to free fstETab properly */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
|  |  | |||
|  | @ -1546,36 +1546,27 @@ struct SimWorker : SimShared | |||
| 			log(" for %d clock cycle(s)",numcycles); | ||||
| 		log("\n"); | ||||
| 		bool all_samples = fst_clock.empty(); | ||||
| 		unsigned int end_cycle = cycles_set ? numcycles*2 : INT_MAX; | ||||
| 
 | ||||
| 		try { | ||||
| 			fst->reconstructAllAtTimes(fst_clock, startCount, stopCount, [&](uint64_t time) { | ||||
| 				if (verbose) | ||||
| 					log("Co-simulating %s %d [%lu%s].\n", (all_samples ? "sample" : "cycle"), cycle, (unsigned long)time, fst->getTimescaleString()); | ||||
| 				bool did_something = top->setInputs(); | ||||
| 		fst->reconstructAllAtTimes(fst_clock, startCount, stopCount, end_cycle, [&](uint64_t time) { | ||||
| 			if (verbose) | ||||
| 				log("Co-simulating %s %d [%lu%s].\n", (all_samples ? "sample" : "cycle"), cycle, (unsigned long)time, fst->getTimescaleString()); | ||||
| 			bool did_something = top->setInputs(); | ||||
| 
 | ||||
| 				if (initial) { | ||||
| 					if (!fst_noinit) did_something |= top->setInitState(); | ||||
| 					initialize_stable_past(); | ||||
| 					initial = false; | ||||
| 				} | ||||
| 				if (did_something) | ||||
| 					update(true); | ||||
| 				register_output_step(time); | ||||
| 			if (initial) { | ||||
| 				if (!fst_noinit) did_something |= top->setInitState(); | ||||
| 				initialize_stable_past(); | ||||
| 				initial = false; | ||||
| 			} | ||||
| 			if (did_something) | ||||
| 				update(true); | ||||
| 			register_output_step(time); | ||||
| 
 | ||||
| 				bool status = top->checkSignals(); | ||||
| 				if (status) | ||||
| 					log_error("Signal difference\n"); | ||||
| 				cycle++; | ||||
| 
 | ||||
| 				// Limit to number of cycles if provided
 | ||||
| 				if (cycles_set && cycle > numcycles *2) | ||||
| 					throw fst_end_of_data_exception(); | ||||
| 				if (time==stopCount) | ||||
| 					throw fst_end_of_data_exception(); | ||||
| 			}); | ||||
| 		} catch(fst_end_of_data_exception) { | ||||
| 			// end of data detected
 | ||||
| 		} | ||||
| 			bool status = top->checkSignals(); | ||||
| 			if (status) | ||||
| 				log_error("Signal difference\n"); | ||||
| 			cycle++; | ||||
| 		}); | ||||
| 
 | ||||
| 		write_output_files(); | ||||
| 		delete fst; | ||||
|  | @ -2248,40 +2239,31 @@ struct SimWorker : SimShared | |||
| 		log("Writing data to `%s`\n", (tb_filename+".txt").c_str()); | ||||
| 		std::ofstream data_file(tb_filename+".txt"); | ||||
| 		std::stringstream initstate; | ||||
| 		try { | ||||
| 			fst->reconstructAllAtTimes(fst_clock, startCount, stopCount, [&](uint64_t time) { | ||||
| 				for(auto &item : clocks) | ||||
| 					data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 				for(auto &item : inputs) | ||||
| 					data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 				for(auto &item : outputs) | ||||
| 					data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 				data_file << stringf("%s\n",Const(time-prev_time).as_string().c_str()); | ||||
| 		unsigned int end_cycle = cycles_set ? numcycles*2 : INT_MAX; | ||||
| 		fst->reconstructAllAtTimes(fst_clock, startCount, stopCount, end_cycle, [&](uint64_t time) { | ||||
| 			for(auto &item : clocks) | ||||
| 				data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 			for(auto &item : inputs) | ||||
| 				data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 			for(auto &item : outputs) | ||||
| 				data_file << stringf("%s",fst->valueOf(item.second).c_str()); | ||||
| 			data_file << stringf("%s\n",Const(time-prev_time).as_string().c_str()); | ||||
| 
 | ||||
| 				if (time==startCount) { | ||||
| 					// initial state
 | ||||
| 					for(auto var : fst->getVars()) { | ||||
| 						if (var.is_reg && !Const::from_string(fst->valueOf(var.id).c_str()).is_fully_undef()) { | ||||
| 							if (var.scope == scope) { | ||||
| 								initstate << stringf("\t\tuut.%s = %d'b%s;\n", var.name.c_str(), var.width, fst->valueOf(var.id).c_str()); | ||||
| 							} else if (var.scope.find(scope+".")==0) { | ||||
| 								initstate << stringf("\t\tuut.%s.%s = %d'b%s;\n",var.scope.substr(scope.size()+1).c_str(), var.name.c_str(), var.width, fst->valueOf(var.id).c_str()); | ||||
| 							} | ||||
| 			if (time==startCount) { | ||||
| 				// initial state
 | ||||
| 				for(auto var : fst->getVars()) { | ||||
| 					if (var.is_reg && !Const::from_string(fst->valueOf(var.id).c_str()).is_fully_undef()) { | ||||
| 						if (var.scope == scope) { | ||||
| 							initstate << stringf("\t\tuut.%s = %d'b%s;\n", var.name.c_str(), var.width, fst->valueOf(var.id).c_str()); | ||||
| 						} else if (var.scope.find(scope+".")==0) { | ||||
| 							initstate << stringf("\t\tuut.%s.%s = %d'b%s;\n",var.scope.substr(scope.size()+1).c_str(), var.name.c_str(), var.width, fst->valueOf(var.id).c_str()); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				cycle++; | ||||
| 				prev_time = time; | ||||
| 
 | ||||
| 				// Limit to number of cycles if provided
 | ||||
| 				if (cycles_set && cycle > numcycles *2) | ||||
| 					throw fst_end_of_data_exception(); | ||||
| 				if (time==stopCount) | ||||
| 					throw fst_end_of_data_exception(); | ||||
| 			}); | ||||
| 		} catch(fst_end_of_data_exception) { | ||||
| 			// end of data detected
 | ||||
| 		} | ||||
| 			} | ||||
| 			cycle++; | ||||
| 			prev_time = time; | ||||
| 		}); | ||||
| 
 | ||||
| 		f << stringf("\treg [0:%d] data [0:%d];\n", data_len-1, cycle-1); | ||||
| 		f << "\tinitial begin;\n"; | ||||
|  | @ -2400,7 +2382,7 @@ struct VCDWriter : public OutputWriter | |||
| struct FSTWriter : public OutputWriter | ||||
| { | ||||
| 	FSTWriter(SimWorker *worker, std::string filename) : OutputWriter(worker) { | ||||
| 		fstfile = (struct fstContext *)fstWriterCreate(filename.c_str(),1); | ||||
| 		fstfile = fstWriterCreate(filename.c_str(),1); | ||||
| 	} | ||||
| 
 | ||||
| 	virtual ~FSTWriter() | ||||
|  | @ -2456,7 +2438,7 @@ struct FSTWriter : public OutputWriter | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	struct fstContext *fstfile = nullptr; | ||||
| 	struct fstWriterContext *fstfile = nullptr; | ||||
| 	std::map<int,fstHandle> mapping; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										51
									
								
								tests/sim/sim_cycles.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								tests/sim/sim_cycles.ys
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| read_verilog dff.v | ||||
| prep | ||||
| 
 | ||||
| # create fst with 20 clock cycles (41 samples, 202ns) | ||||
| sim -clock clk -fst sim_cycles.fst -n 20 | ||||
| 
 | ||||
| logger -expect-no-warnings | ||||
| 
 | ||||
| # final step is 41 | ||||
| logger -expect log "Co-simulating cycle 41" 2 | ||||
| logger -warn "Co-simulating cycle 42" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 21 -sim-cmp | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 202 -sim-cmp | ||||
| logger -check-expected | ||||
| 
 | ||||
| # over limit stops at final step | ||||
| logger -expect log "Co-simulating cycle 41" 2 | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 30 -sim-cmp | ||||
| # -stop warns for over limit | ||||
| logger -nowarn "Stop time is after simulation file end time" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 300 -sim-cmp | ||||
| logger -check-expected | ||||
| 
 | ||||
| # don't auto step last | ||||
| logger -expect log "Co-simulating cycle 40" 2 | ||||
| logger -warn "Co-simulating cycle 41" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 20 -sim-cmp | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 200 -sim-cmp | ||||
| logger -check-expected | ||||
| 
 | ||||
| # -n 10 == -stop 100 | ||||
| # should simulate up to 20 and not more | ||||
| logger -expect log "Co-simulating cycle 20" 2 | ||||
| logger -warn "Co-simulating cycle 21" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 10 -sim-cmp | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 100 -sim-cmp | ||||
| logger -check-expected | ||||
| 
 | ||||
| # -n 1 == -stop 10 | ||||
| logger -expect log "Co-simulating cycle 2" 2 | ||||
| logger -warn "Co-simulating cycle 3" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 1 -sim-cmp | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 10 -sim-cmp | ||||
| logger -check-expected | ||||
| 
 | ||||
| # -n 0 == -stop 0 | ||||
| logger -expect log "Co-simulating cycle 0" 2 | ||||
| logger -warn "Co-simulating cycle 1" | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -n 0 -sim-cmp | ||||
| sim -clock clk -r sim_cycles.fst -scope dff -stop 0 -sim-cmp | ||||
| logger -check-expected | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue