1 /* 2 * Copyright (c) Tony Bybell 1999-2011. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 */ 9 10 #include "globals.h" 11 12 /* 13 * tree.h 12/05/98ajb 14 */ 15 #ifndef WAVE_TREE_H 16 #define WAVE_TREE_H 17 18 #include <gtk/gtk.h> 19 #include <stdio.h> 20 #include <string.h> 21 #include <ctype.h> 22 #include "debug.h" 23 #include "symbol.h" 24 #include "vcd.h" 25 #include "tree_component.h" 26 27 #define FST_TREE_SEARCH_NEXT_LIMIT (40) 28 29 /* Kind of the tree. */ 30 enum tree_kind 31 { 32 /* Unknown. */ 33 TREE_UNKNOWN, 34 35 /* An internal signal. */ 36 TREE_SIGNAL, 37 38 /* An in/out/inout signal. */ 39 TREE_IN, 40 TREE_OUT, 41 TREE_INOUT, 42 43 /* An element of a vector. */ 44 TREE_VECTOREL, 45 /* An element of a record. */ 46 TREE_RECORDEL, 47 48 /* A Subinstance. */ 49 TREE_INSTANCE, 50 51 /* A package (somewhat VHDL specific ?). */ 52 TREE_PACKAGE, 53 54 /* A base (source file). Not yet implemented. */ 55 TREE_BASE, 56 57 /* Verilog/SV scope types */ 58 TREE_VCD_ST_MODULE, 59 TREE_VCD_ST_TASK, 60 TREE_VCD_ST_FUNCTION, 61 TREE_VCD_ST_BEGIN, 62 TREE_VCD_ST_FORK, 63 TREE_VCD_ST_GENERATE, 64 TREE_VCD_ST_STRUCT, 65 TREE_VCD_ST_UNION, 66 TREE_VCD_ST_CLASS, 67 TREE_VCD_ST_INTERFACE, 68 TREE_VCD_ST_PACKAGE, 69 TREE_VCD_ST_PROGRAM, 70 71 /* GHW VHDL scope types */ 72 TREE_VHDL_ST_DESIGN, 73 TREE_VHDL_ST_BLOCK, 74 TREE_VHDL_ST_GENIF, 75 TREE_VHDL_ST_GENFOR, 76 TREE_VHDL_ST_INSTANCE, 77 TREE_VHDL_ST_PACKAGE, 78 79 /* GHW VHDL signal types (still as part of scope in GHW) */ 80 TREE_VHDL_ST_SIGNAL, 81 TREE_VHDL_ST_PORTIN, 82 TREE_VHDL_ST_PORTOUT, 83 TREE_VHDL_ST_PORTINOUT, 84 TREE_VHDL_ST_BUFFER, 85 TREE_VHDL_ST_LINKAGE, 86 87 /* FSDB VHDL scope types: FSDB also reuses/defines GHW's TREE_VHDL_ST_BLOCK, TREE_VHDL_ST_GENFOR, TREE_VHDL_ST_GENIF */ 88 /* FST reuses TREE_VHDL_ST_PACKAGE */ 89 TREE_VHDL_ST_ARCHITECTURE, 90 TREE_VHDL_ST_FUNCTION, 91 TREE_VHDL_ST_PROCEDURE, 92 TREE_VHDL_ST_RECORD, 93 TREE_VHDL_ST_PROCESS, 94 TREE_VHDL_ST_GENERATE 95 }; 96 97 #define WAVE_T_WHICH_UNDEFINED_COMPNAME (-1) 98 #define WAVE_T_WHICH_COMPNAME_START (-2) 99 100 #ifdef WAVE_USE_STRUCT_PACKING 101 #pragma pack(push) 102 #pragma pack(1) 103 #endif 104 105 struct stem_struct_t 106 { 107 uint32_t stem_idx; /* in stem_path_string_table */ 108 uint32_t stem_line_number; 109 }; 110 111 struct tree 112 { 113 struct tree *next; 114 struct tree *child; 115 int t_which; /* 'i' for facs[i] table, value of < 0 means not a full signame */ 116 uint32_t t_stem; /* source stem (if >0) for Open Hierarchy Source Def, see stem_struct_t */ 117 uint32_t t_istem; /* source stem (if >0) for Open Hierarchy Source Inst, see stem_struct_t */ 118 119 unsigned kind : 7; /* Kind of the leaf: ghwlib reads this as val & 0x7f so only 7 bits needed */ 120 unsigned children_in_gui : 1; /* indicates that the child nodes are in the gtk2 tree, but gets borrowed during tree creation for fast judy sort */ 121 char name[]; /* C99 */ 122 }; 123 124 #ifdef WAVE_USE_STRUCT_PACKING 125 #pragma pack(pop) 126 #endif 127 128 /* names at the end of the main hierarchy 010104ajb */ 129 130 struct treechain 131 { 132 struct tree *tree; /* top of list of selected item in hierarchy */ 133 struct tree *label; /* actual selected item in hierarchy */ 134 struct treechain *next; 135 }; 136 137 138 struct autocoalesce_free_list 139 { 140 struct autocoalesce_free_list *next; /* list of coalesced names generated by treesearch gadget..only user of this struct */ 141 char *name; /* free up next time filtering is performed */ 142 }; 143 144 145 146 void init_tree(void); 147 void build_tree_from_name(const char *s, int which); 148 int treegraft(struct tree **t); 149 void treedebug(struct tree *t, char *s); 150 void maketree(GtkCTreeNode *subtree, struct tree *t); 151 #if WAVE_USE_GTK2 152 void maketree2(GtkCTreeNode *subtree, struct tree *t, int depth, GtkCTreeNode *graft); 153 #endif 154 155 char *leastsig_hiername(char *nam); 156 void allocate_and_decorate_module_tree_node(unsigned char ttype, const char *scopename, const char *compname, uint32_t scopename_len, uint32_t compname_len, uint32_t t_stem, uint32_t t_istem); 157 int decorated_module_cleanup(void); 158 159 void treesort(struct tree *t, struct tree *p); 160 void order_facs_from_treesort(struct tree *t, void *v); 161 162 void treenamefix(struct tree *t); 163 164 165 #ifdef WAVE_USE_STRUCT_PACKING 166 #define WAVE_TALLOC_POOL_SIZE (64 * 1024) 167 #define WAVE_TALLOC_ALTREQ_SIZE (4 * 1024) 168 struct tree *talloc_2(size_t siz); 169 #else 170 #define talloc_2(x) calloc_2(1,(x)) 171 #endif 172 173 174 void sst_exclusion_loader(void); 175 176 #endif 177 178