00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "string_cache.h"
00025 #include "odin_util.h"
00026 #include "read_xml_arch_file.h"
00027
00028 #ifndef TRUE
00029 #define TRUE 1
00030 #endif
00031 #ifndef FALSE
00032 #define FALSE 0
00033 #endif
00034
00035 #ifndef TYPES_H
00036 #define TYPES_H
00037
00038 typedef struct config_t_t config_t;
00039 typedef struct global_args_t_t global_args_t;
00040
00041 typedef struct global_args_read_blif_t_t global_args_read_blif_t;
00042
00043 typedef struct ast_node_t_t ast_node_t;
00044 typedef struct info_ast_visit_t_t info_ast_visit_t;
00045
00046 typedef struct sim_state_t_t sim_state_t;
00047 typedef struct nnode_t_t nnode_t;
00048 typedef struct npin_t_t npin_t;
00049 typedef struct nnet_t_t nnet_t;
00050 typedef struct signal_list_t_t signal_list_t;
00051 typedef struct char_list_t_t char_list_t;
00052 typedef struct netlist_t_t netlist_t;
00053 typedef struct netlist_stats_t_t netlist_stats_t;
00054
00055
00056 #define PARSE_ERROR -3
00057
00058 #define NETLIST_ERROR -4
00059
00060 #define BLIF_ERROR -5
00061
00062 #define NETLIST_FILE_ERROR -6
00063
00064 #define ACTIVATION_ERROR -7
00065
00066 #define SIMULATION_ERROR -8
00067
00068
00069 #define PARTIAL_MAP_TRAVERSE_VALUE 10
00070 #define OUTPUT_TRAVERSE_VALUE 12
00071 #define COUNT_NODES 14
00072 #define COMBO_LOOP 15
00073 #define COMBO_LOOP_ERROR 16
00074 #define GRAPH_CRUNCH 17
00075 #define STATS 18
00076 #define SEQUENTIAL_LEVELIZE 19
00077
00078
00079 #define RESET -1
00080 #define LEVELIZE 12
00081 #define ACTIVATION 13
00082
00083
00084 #define oassert(x) {if(!(x)){__asm("int3");}} // causes an interrupt in GDB
00085
00086
00087
00088 struct config_t_t
00089 {
00090 char **list_of_file_names;
00091 int num_list_of_file_names;
00092
00093 char *output_type;
00094
00095 char *debug_output_path;
00096 short output_ast_graphs;
00097 short output_netlist_graphs;
00098 short print_parse_tokens;
00099 short output_preproc_source;
00100 int min_hard_multiplier;
00101 int fixed_hard_multiplier;
00102 int fracture_hard_multiplier;
00103 short split_memory_width;
00104 short split_memory_depth;
00105 char *arch_file;
00106 };
00107
00108 typedef enum {
00109 NO_SIMULATION = 0,
00110 TEST_EXISTING_VECTORS,
00111 GENERATE_VECTORS,
00112 }simulation_type;
00113
00114
00115 struct global_args_t_t
00116 {
00117 char *config_file;
00118 char *verilog_file;
00119 char *output_file;
00120 char *arch_file;
00121 char *activation_blif_file;
00122 char *activation_netlist_file;
00123 char *high_level_block;
00124 char *sim_vectors_file;
00125 int num_test_vectors;
00126 simulation_type sim_type;
00127 };
00128
00129
00130 struct global_args_read_blif_t_t
00131 {
00132 char *config_file;
00133 char *blif_file;
00134 char *arch_file;
00135 char *sim_vectors_file;
00136 int num_test_vectors;
00137 simulation_type sim_type;
00138 };
00139
00140 #endif // TYPES_H
00141
00142
00143
00144 #ifndef AST_TYPES_H
00145 #define AST_TYPES_H
00146
00147 typedef enum
00148 {
00149 DEC,
00150 HEX,
00151 OCT,
00152 BIN,
00153 LONG_LONG,
00154 } bases;
00155
00156 typedef enum
00157 {
00158 NO_OP,
00159 MULTI_PORT_MUX,
00160 FF_NODE,
00161 BUF_NODE,
00162 INPUT_NODE,
00163 OUTPUT_NODE,
00164 GND_NODE,
00165 VCC_NODE,
00166 CLOCK_NODE,
00167 ADD,
00168 MINUS,
00169 BITWISE_NOT,
00170 BITWISE_AND,
00171 BITWISE_OR,
00172 BITWISE_NAND,
00173 BITWISE_NOR,
00174 BITWISE_XNOR,
00175 BITWISE_XOR,
00176 LOGICAL_NOT,
00177 LOGICAL_OR,
00178 LOGICAL_AND,
00179 LOGICAL_NAND,
00180 LOGICAL_NOR,
00181 LOGICAL_XNOR,
00182 LOGICAL_XOR,
00183 MULTIPLY,
00184 DIVIDE,
00185 MODULO,
00186 LT,
00187 GT,
00188 LOGICAL_EQUAL,
00189 NOT_EQUAL,
00190 LTE,
00191 GTE,
00192 SR,
00193 SL,
00194 CASE_EQUAL,
00195 CASE_NOT_EQUAL,
00196 ADDER_FUNC,
00197 CARRY_FUNC,
00198 MUX_2,
00199 BLIF_FUNCTION,
00200 NETLIST_FUNCTION,
00201 MEMORY,
00202 PAD_NODE,
00203 HARD_IP,
00204 GENERIC
00205 } operation_list;
00206
00207 typedef enum
00208 {
00209 NO_ID,
00210
00211 FILE_ITEMS,
00212 MODULE,
00213
00214 INPUT,
00215 OUTPUT,
00216 INOUT,
00217 WIRE,
00218 REG,
00219 PARAMETER,
00220 PORT,
00221
00222 MODULE_ITEMS,
00223 VAR_DECLARE,
00224 VAR_DECLARE_LIST,
00225 ASSIGN,
00226
00227 GATE,
00228 GATE_INSTANCE,
00229
00230 MODULE_CONNECT_LIST,
00231 MODULE_CONNECT,
00232 MODULE_NAMED_INSTANCE,
00233 MODULE_INSTANCE,
00234
00235 BLOCK,
00236 NON_BLOCKING_STATEMENT,
00237 BLOCKING_STATEMENT,
00238 CASE,
00239 CASE_LIST,
00240 CASE_ITEM,
00241 CASE_DEFAULT,
00242 ALWAYS,
00243 IF,
00244 IF_Q,
00245
00246 DELAY_CONTROL,
00247 POSEDGE,
00248 NEGEDGE,
00249
00250 BINARY_OPERATION,
00251 UNARY_OPERATION,
00252
00253 ARRAY_REF,
00254 RANGE_REF,
00255 CONCATENATE,
00256
00257 IDENTIFIERS,
00258 NUMBERS,
00259
00260 HARD_BLOCK,
00261 HARD_BLOCK_NAMED_INSTANCE,
00262 HARD_BLOCK_CONNECT_LIST,
00263 HARD_BLOCK_CONNECT,
00264
00265 RAM
00266 } ids;
00267
00268 struct ast_node_t_t
00269 {
00270 int unique_count;
00271 int far_tag;
00272 int high_number;
00273 ids type;
00274 union
00275 {
00276 char *identifier;
00277 struct
00278 {
00279 short base;
00280 int size;
00281 int binary_size;
00282 char *binary_string;
00283 char *number;
00284 long long value;
00285 } number;
00286 struct
00287 {
00288 operation_list op;
00289 } operation;
00290 struct
00291 {
00292 short is_parameter;
00293 short is_port;
00294 short is_input;
00295 short is_output;
00296 short is_inout;
00297 short is_wire;
00298 short is_reg;
00299 } variable;
00300 struct
00301 {
00302 short is_instantiated;
00303 ast_node_t **module_instantiations_instance;
00304 int size_module_instantiations;
00305 int index;
00306 } module;
00307 struct
00308 {
00309 int num_bit_strings;
00310 char **bit_strings;
00311 } concat;
00312 } types;
00313
00314 ast_node_t **children;
00315 int num_children;
00316
00317 int line_number;
00318 int file_number;
00319
00320 short shared_node;
00321 void *hb_port;
00322 void *net_node;
00323
00324 void *additional_data;
00325 };
00326
00327 struct info_ast_visit_t_t
00328 {
00329 ast_node_t *me;
00330 ast_node_t *from;
00331 int from_child_position;
00332
00333 short is_constant;
00334 long long value;
00335
00336 short is_constant_folded;
00337 };
00338 #endif // AST_TYPES_H
00339
00340
00341 #ifndef NETLIST_UTILS_H
00342 #define NETLIST_UTILS_H
00343
00344 struct sim_state_t_t
00345 {
00346 int cycle;
00347 int value;
00348 int prev_value;
00349 };
00350
00351
00352
00353 struct nnode_t_t
00354 {
00355 long unique_id;
00356 char *name;
00357 operation_list type;
00358 ast_node_t *related_ast_node;
00359
00360 short traverse_visited;
00361
00362 npin_t **input_pins;
00363 int num_input_pins;
00364 int *input_port_sizes;
00365 int num_input_port_sizes;
00366
00367 npin_t **output_pins;
00368 int num_output_pins;
00369 int *output_port_sizes;
00370 int num_output_port_sizes;
00371
00372 short unique_node_data_id;
00373 void *node_data;
00374
00375 int forward_level;
00376 int backward_level;
00377 int sequential_level;
00378 short sequential_terminator;
00379
00380 netlist_t* internal_netlist;
00381
00382 int *memory_data;
00383
00384 void (*simulate_block_cycle)(int, int, int*, int, int*);
00385
00386 short *associated_function;
00387
00388 char** bit_map;
00389 int bit_map_line_count;
00390 };
00391
00392 struct npin_t_t
00393 {
00394 long unique_id;
00395 ids type;
00396 char *name;
00397
00398 nnet_t *net;
00399 int pin_net_idx;
00400
00401 nnode_t *node;
00402 int pin_node_idx;
00403 char *mapping;
00404
00405 sim_state_t *sim_state;
00406 };
00407
00408 struct nnet_t_t
00409 {
00410 long unique_id;
00411 char *name;
00412 short combined;
00413
00414 npin_t *driver_pin;
00415
00416 npin_t **fanout_pins;
00417 int num_fanout_pins;
00418
00419 short unique_net_data_id;
00420 void *net_data;
00421 };
00422
00423 struct signal_list_t_t
00424 {
00425 npin_t **signal_list;
00426 int signal_list_size;
00427
00428 short is_memory;
00429 };
00430
00431 struct char_list_t_t
00432 {
00433 char **strings;
00434 int num_strings;
00435 };
00436
00437 struct netlist_t_t
00438 {
00439 nnode_t *gnd_node;
00440 nnode_t *vcc_node;
00441 nnode_t *pad_node;
00442 nnet_t *zero_net;
00443 nnet_t *one_net;
00444 nnet_t *pad_net;
00445 nnode_t** top_input_nodes;
00446 int num_top_input_nodes;
00447 nnode_t** top_output_nodes;
00448 int num_top_output_nodes;
00449 nnode_t** ff_nodes;
00450 int num_ff_nodes;
00451 nnode_t** internal_nodes;
00452 int num_internal_nodes;
00453 nnode_t** clocks;
00454 int num_clocks;
00455
00456
00457
00458 nnode_t ***forward_levels;
00459 int num_forward_levels;
00460 int* num_at_forward_level;
00461 nnode_t ***backward_levels;
00462 int num_backward_levels;
00463 int* num_at_backward_level;
00464
00465 nnode_t ***sequential_level_nodes;
00466 int num_sequential_levels;
00467 int* num_at_sequential_level;
00468
00469 nnode_t ***sequential_level_combinational_termination_node;
00470 int num_sequential_level_combinational_termination_nodes;
00471 int* num_at_sequential_level_combinational_termination_node;
00472
00473 STRING_CACHE *nets_sc;
00474 STRING_CACHE *out_pins_sc;
00475 STRING_CACHE *nodes_sc;
00476
00477 netlist_stats_t *stats;
00478
00479 t_type_ptr type;
00480 };
00481
00482 struct netlist_stats_t_t
00483 {
00484 int num_inputs;
00485 int num_outputs;
00486 int num_ff_nodes;
00487 int num_logic_nodes;
00488 int num_nodes;
00489
00490 float average_fanin;
00491 int *fanin_distribution;
00492 int num_fanin_distribution;
00493
00494 long num_output_pins;
00495 float average_output_pins_per_node;
00496 float average_fanout;
00497 int *fanout_distribution;
00498 int num_fanout_distribution;
00499
00500
00501 long num_edges_fo;
00502 long num_edges_fi;
00503
00504 int **combinational_shape;
00505 int *num_combinational_shape_for_sequential_level;
00506 };
00507
00508 #endif // NET_TYPES_H