read_xml_config_file.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "types.h"
#include "globals.h"
#include "ezxml.h"
#include "read_xml_config_file.h"
#include "read_xml_util.h"
Include dependency graph for read_xml_config_file.c:

Go to the source code of this file.

Functions

void read_verilog_files (ezxml_t a_node, config_t *config)
void read_outputs (ezxml_t a_node, config_t *config)
void read_debug_switches (ezxml_t a_node, config_t *config)
void read_optimizations (ezxml_t a_node, config_t *config)
void set_default_optimization_settings (config_t *config)
void read_config_file (char *file_name)

Variables

config_t configuration

Function Documentation

void read_config_file ( char *  file_name  ) 

Definition at line 47 of file read_xml_config_file.c.

00048 {
00049         ezxml_t doc, next;
00050 
00051         /* Parse the xml file */
00052         oassert(file_name != NULL);
00053         doc = ezxml_parse_file(file_name);
00054 
00055         if (doc == NULL) 
00056         {
00057                 printf("error: could not parse xml configuration file\n");
00058                 return;
00059         }
00060 
00061         /* Root element should be config */
00062         CheckElement(doc, "config");
00063 
00064         /* Process the verilog files */
00065         next = FindElement(doc, "verilog_files", (boolean)TRUE);
00066         read_verilog_files(next, &configuration);
00067         FreeNode(next);
00068 
00069         /* Process the output */
00070         next = FindElement(doc, "output", (boolean)TRUE);
00071         read_outputs(next, &configuration);
00072         FreeNode(next);
00073 
00074         /* Process the optimizations */
00075         set_default_optimization_settings(&configuration);
00076         next = FindElement(doc, "optimizations", (boolean)FALSE);
00077         if (next)
00078         {
00079                 read_optimizations(next, &configuration);
00080                 FreeNode(next);         
00081         }
00082 
00083         /* Process the debug switches */
00084         next = FindElement(doc, "debug_outputs", (boolean)TRUE);
00085         read_debug_switches(next, &configuration);
00086         FreeNode(next);
00087 
00088         /* Release the full XML tree */
00089         FreeNode(doc);
00090         return;
00091 }

Here is the call graph for this function:

Here is the caller graph for this function:

void read_debug_switches ( ezxml_t  a_node,
config_t config 
)

Definition at line 167 of file read_xml_config_file.c.

00168 {
00169         ezxml_t child;
00170 
00171         child = ezxml_child(a_node, "output_ast_graphs");
00172         if (child != NULL)
00173         {
00174                 config->output_ast_graphs = atoi(ezxml_txt(child));
00175                 ezxml_set_txt(child, "");
00176                 FreeNode(child);
00177         }
00178 
00179         child = ezxml_child(a_node, "output_netlist_graphs");
00180         if (child != NULL)
00181         {
00182                 config->output_netlist_graphs = atoi(ezxml_txt(child));
00183                 ezxml_set_txt(child, "");
00184                 FreeNode(child);
00185         }
00186 
00187         child = ezxml_child(a_node, "debug_output_path");
00188         if (child != NULL)
00189         {
00190                 config->debug_output_path = strdup(ezxml_txt(child));
00191                 ezxml_set_txt(child, "");
00192                 FreeNode(child);
00193         }
00194 
00195         child = ezxml_child(a_node, "print_parse_tokens");
00196         if (child != NULL)
00197         {
00198                 config->print_parse_tokens = atoi(ezxml_txt(child));
00199                 ezxml_set_txt(child, "");
00200                 FreeNode(child);
00201         }
00202 
00203         child = ezxml_child(a_node, "output_preproc_source");
00204         if (child != NULL)
00205         {
00206                 config->output_preproc_source = atoi(ezxml_txt(child));
00207                 ezxml_set_txt(child, "");
00208                 FreeNode(child);
00209         }
00210 
00211         return;
00212 }

Here is the caller graph for this function:

void read_optimizations ( ezxml_t  a_node,
config_t config 
)

Definition at line 230 of file read_xml_config_file.c.

00231 {
00232         const char *prop;
00233         ezxml_t child;
00234 
00235         child = ezxml_child(a_node, "multiply");
00236         if (child != NULL)
00237         {
00238                 prop = FindProperty(child, "size", (boolean)FALSE);
00239                 if (prop != NULL)
00240                 {
00241                         config->min_hard_multiplier = atoi(prop);
00242                         ezxml_set_attr(child, "size", NULL);
00243                 }
00244                 else /* Default: No minimum hard multiply size */
00245                         config->min_hard_multiplier = 0;
00246                 
00247                 prop = FindProperty(child, "fixed", (boolean)FALSE);
00248                 if (prop != NULL)
00249                 {
00250                         config->fixed_hard_multiplier = atoi(prop);
00251                         ezxml_set_attr(child, "fixed", NULL);
00252                 }
00253                 else /* Default: No fixed hard multiply size */
00254                         config->fixed_hard_multiplier = 0;
00255 
00256                 prop = FindProperty(child, "fracture", (boolean)FALSE);
00257                 if (prop != NULL)
00258                 {
00259                         config->fracture_hard_multiplier = atoi(prop);
00260                         ezxml_set_attr(child, "fracture", NULL);
00261                 }
00262                 else /* Default: use fractured hard multiply size */
00263                         config->fracture_hard_multiplier = 1;
00264                 FreeNode(child);
00265         }
00266 
00267         child = ezxml_child(a_node, "memory");
00268         if (child != NULL)
00269         {
00270                 prop = FindProperty(child, "split_memory_width", (boolean)FALSE);
00271                 if (prop != NULL)
00272                 {
00273                         config->split_memory_width = atoi(prop);
00274                         ezxml_set_attr(child, "split_memory_width", NULL);
00275                 }
00276                 else /* Default: Do not split memory width! */
00277                         config->split_memory_width = 0;
00278                 
00279                 prop = FindProperty(child, "split_memory_depth", (boolean)FALSE);
00280                 if (prop != NULL)
00281                 {
00282                         if (strcmp(prop, "min") == 0)
00283                                 config->split_memory_depth = -1;
00284                         else if (strcmp(prop, "max") == 0)
00285                                 config->split_memory_depth = -2;
00286                         else
00287                                 config->split_memory_depth = atoi(prop);
00288                         ezxml_set_attr(child, "split_memory_depth", NULL);
00289                 }
00290                 else /* Default: Do not split memory depth! */
00291                         config->split_memory_depth = 0;
00292                 
00293                 FreeNode(child);
00294         }
00295 
00296         return;
00297 }

Here is the caller graph for this function:

void read_outputs ( ezxml_t  a_node,
config_t config 
)

Definition at line 121 of file read_xml_config_file.c.

00122 {
00123         ezxml_t child;
00124 
00125         child = ezxml_child(a_node, "output_type");
00126         if (child != NULL)
00127         {
00128                 config->output_type = strdup(ezxml_txt(child));
00129                 ezxml_set_txt(child, "");
00130                 FreeNode(child);
00131         }
00132 
00133         child = ezxml_child(a_node, "output_path_and_name");
00134         if (child != NULL)
00135         {
00136                 global_args.output_file = strdup(ezxml_txt(child));
00137                 ezxml_set_txt(child, "");
00138                 FreeNode(child);
00139         }
00140 
00141         child = ezxml_child(a_node, "target");
00142         if (child != NULL)
00143         {
00144                 ezxml_t junk = child;
00145 
00146                 child = ezxml_child(child, "arch_file");
00147                 if (child != NULL)
00148                 {
00149                         /* Two arch files specified? */
00150                         if (global_args.arch_file != NULL) 
00151                         {
00152                                 printf("Error: Arch file specified in config file AND command line\n");
00153                                 exit(-1);
00154                         }
00155                         global_args.arch_file = strdup(ezxml_txt(child));
00156                         ezxml_set_txt(child, "");
00157                         FreeNode(child);
00158                 }
00159                 FreeNode(junk);
00160         }
00161         return;
00162 }

Here is the caller graph for this function:

void read_verilog_files ( ezxml_t  a_node,
config_t config 
)

Definition at line 96 of file read_xml_config_file.c.

00097 {
00098         ezxml_t child;
00099         ezxml_t junk;
00100 
00101         child = ezxml_child(a_node, "verilog_file");
00102         while (child != NULL)
00103         {
00104                 if (global_args.verilog_file == NULL)
00105                 {
00106                         config->list_of_file_names = (char**)realloc(config->list_of_file_names, sizeof(char*)*(config->num_list_of_file_names+1));
00107                         config->list_of_file_names[config->num_list_of_file_names] = strdup(ezxml_txt(child));
00108                         config->num_list_of_file_names ++;
00109                 }
00110                 ezxml_set_txt(child, "");
00111                 junk = child;
00112                 child = ezxml_next(child);
00113                 FreeNode(junk);
00114         }
00115         return;
00116 }

Here is the caller graph for this function:

void set_default_optimization_settings ( config_t config  ) 

Definition at line 217 of file read_xml_config_file.c.

00218 {
00219         config->min_hard_multiplier = 0;
00220         config->fixed_hard_multiplier = 0;
00221         config->fracture_hard_multiplier = 1;
00222         config->split_memory_width = FALSE;
00223         config->split_memory_depth = FALSE;
00224         return;
00225 }

Here is the caller graph for this function:


Variable Documentation

Definition at line 33 of file read_xml_config_file.c.

Generated on Tue Aug 2 10:43:49 2011 for ODIN_II by  doxygen 1.6.3