Compare commits

..

No commits in common. "eeae61ad473b38207300e6d0b81cf6840f5b86ef" and "d81c6d1037278f78653874875a9a9e49d2f1ac2f" have entirely different histories.

4 changed files with 23 additions and 125 deletions

View File

@ -662,7 +662,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
case SREF: case SREF:
if (current_cell == NULL) { if (current_cell == NULL) {
GDS_ERROR("Cell Reference outside of cell"); GDS_ERROR("Path outside of cell");
run = -3; run = -3;
break; break;
} }
@ -810,11 +810,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
case SNAME: case SNAME:
if (current_s_reference) { name_cell_ref(current_s_reference, read, workbuff);
name_cell_ref(current_s_reference, (unsigned int)read, workbuff);
} else {
GDS_ERROR("reference name set outside of cell reference.\n");
}
break; break;
case WIDTH: case WIDTH:
if (!current_graphics) { if (!current_graphics) {
@ -867,7 +863,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
if (current_graphics->gfx_type == GRAPHIC_PATH) { if (current_graphics->gfx_type == GRAPHIC_PATH) {
current_graphics->path_render_type = (enum path_type)gds_convert_signed_int16(workbuff); current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff);
GDS_INF("\t\tPathtype: %d\n", current_graphics->path_render_type); GDS_INF("\t\tPathtype: %d\n", current_graphics->path_render_type);
} else { } else {
GDS_WARN("Path type defined inside non-path graphics object. Ignoring"); GDS_WARN("Path type defined inside non-path graphics object. Ignoring");

View File

@ -84,117 +84,31 @@ int gds_tree_check_cell_references(struct gds_library *lib)
} }
/** /**
* @brief Check if list contains a cell * @brief This function sets the marker element in the check structure of each cell to zero.
* @param list GList to check. May be a null pointer * @param lib Library to work with
* @param cell Cell to check for * @return 0 if successful; negative if a fault (null pointer, ...) occured.
* @return 0 if cell is not in list. 1 if cell is in list
*/ */
static int gds_tree_check_list_contains_cell(GList *list, struct gds_cell *cell) { static int gds_tree_check_clear_cell_check_marker(struct gds_library *lib)
GList *iter;
for (iter = list; iter != NULL; iter = g_list_next(iter)) {
if ((struct gds_cell *)iter->data == cell)
return 1;
}
return 0;
}
/**
* @brief This function follows down the reference list of a cell and marks each visited subcell and detects loops
* @param cell_to_check The cell to check for reference loops
* @param visited_cells Pointer to list head. May be zero.
* @return 0 if no loops exist; error in processing: <0; loop found: >0
*/
static int gds_tree_check_iterate_ref_and_check(struct gds_cell *cell_to_check, GList **visited_cells)
{ {
GList *ref_iter;
struct gds_cell_instance *ref;
struct gds_cell *sub_cell;
int res;
if (!cell_to_check)
return -1;
/* Check if this cell is already contained in visited cells. This indicates a loop */
if (gds_tree_check_list_contains_cell(*visited_cells, cell_to_check))
return 1;
/* Add cell to visited cell list */
*visited_cells = g_list_append(*visited_cells, (gpointer)cell_to_check);
/* Mark references and process sub cells */
for (ref_iter = cell_to_check->child_cells; ref_iter != NULL; ref_iter = g_list_next(ref_iter)) {
ref = (struct gds_cell_instance *)ref_iter->data;
if (!ref)
return -1;
sub_cell = ref->cell_ref;
/* If cell is not resolved, ignore. No harm there */
if (!sub_cell)
continue;
res = gds_tree_check_iterate_ref_and_check(sub_cell, visited_cells);
if (res < 0) {
/* Error. return. */
return -3;
} else if (res > 0) {
/* Loop in subcell found. Propagate to top */
return 1;
}
}
/* Remove cell from visted cells */
*visited_cells = g_list_remove(*visited_cells, cell_to_check);
/* No error found in this chain */
return 0;
}
int gds_tree_check_reference_loops(struct gds_library *lib)
{
int res;
int loop_count = 0;
GList *cell_iter; GList *cell_iter;
struct gds_cell *cell_to_check; struct gds_cell *cell;
GList *visited_cells = NULL;
if (!lib) if (!lib)
return -1; return -1;
for (cell_iter = lib->cells; cell_iter != NULL; cell_iter = g_list_next(cell_iter)) { for (cell_iter = lib->cells; cell_iter != NULL; cell_iter = g_list_next(cell_iter)) {
cell_to_check = (struct gds_cell *)cell_iter->data; cell = (struct gds_cell *)cell_iter->data;
/* A broken cell reference will be counted fatal in this case */ if (!cell)
if (!cell_to_check)
return -2; return -2;
/* iterate through references and check if loop exists */ cell->checks._internal.marker = 0;
res = gds_tree_check_iterate_ref_and_check(cell_to_check, &visited_cells); }
if (res < 0) {
/* Error */
return res;
} else if (res > 0) {
/* Loop found: increment loop count and flag cell */
cell_to_check->checks.affected_by_reference_loop = 1;
loop_count++;
} else if (res == 0) {
/* No error found for this cell */
cell_to_check->checks.affected_by_reference_loop = 0;
} }
} int gds_tree_check_reference_loops(struct gds_library *lib)
{
if (visited_cells) { return 0;
fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n");
g_list_free(visited_cells);
}
return loop_count;
} }
/** @} */ /** @} */

View File

@ -38,7 +38,6 @@
#include "cairo-output/cairo-output.h" #include "cairo-output/cairo-output.h"
#include "trigonometric/cell-trigonometrics.h" #include "trigonometric/cell-trigonometrics.h"
#include "tree-renderer/lib-cell-renderer.h" #include "tree-renderer/lib-cell-renderer.h"
#include "gds-parser/gds-tree-checker.h"
/** /**
* @brief User data supplied to callback function of the open button * @brief User data supplied to callback function of the open button
@ -116,7 +115,6 @@ static void on_load_gds(gpointer button, gpointer user)
char *filename; char *filename;
GString *mod_date; GString *mod_date;
GString *acc_date; GString *acc_date;
unsigned int cell_error_level;
open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window, GTK_FILE_CHOOSER_ACTION_OPEN, open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window, GTK_FILE_CHOOSER_ACTION_OPEN,
"Cancel", GTK_RESPONSE_CANCEL, "Open GDSII", GTK_RESPONSE_ACCEPT, NULL); "Cancel", GTK_RESPONSE_CANCEL, "Open GDSII", GTK_RESPONSE_ACCEPT, NULL);
@ -164,11 +162,6 @@ static void on_load_gds(gpointer button, gpointer user)
CELL_SEL_ACCESSDATE, acc_date->str, CELL_SEL_ACCESSDATE, acc_date->str,
-1); -1);
/* Check this library. This might take a while */
(void)gds_tree_check_cell_references(gds_lib);
(void)gds_tree_check_reference_loops(gds_lib);
/* Delete GStrings including string data. */ /* Delete GStrings including string data. */
/* Cell store copies String type data items */ /* Cell store copies String type data items */
g_string_free(mod_date, TRUE); g_string_free(mod_date, TRUE);
@ -182,21 +175,16 @@ static void on_load_gds(gpointer button, gpointer user)
mod_date = generate_string_from_date(&gds_c->mod_time); mod_date = generate_string_from_date(&gds_c->mod_time);
acc_date = generate_string_from_date(&gds_c->access_time); acc_date = generate_string_from_date(&gds_c->access_time);
/* Get the checking results for this cell */ /* Add cell to tree store model
cell_error_level = 0; * CELL_SEL_CELL_COLOR will always be green,
if (gds_c->checks.unresolved_child_count) * because no cell cehcker is implemented, yet.
cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN; */
/* Check if it is completely b0rken */
if (gds_c->checks.affected_by_reference_loop)
cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
/* Add cell to tree store model */
gtk_tree_store_set (store, &celliter, gtk_tree_store_set (store, &celliter,
CELL_SEL_CELL, gds_c, CELL_SEL_CELL, gds_c,
CELL_SEL_MODDATE, mod_date->str, CELL_SEL_MODDATE, mod_date->str,
CELL_SEL_ACCESSDATE, acc_date->str, CELL_SEL_ACCESSDATE, acc_date->str,
CELL_SEL_CELL_ERROR_STATE, cell_error_level, -1); CELL_SEL_CELL_ERROR_STATE, 0, // TODO: implement cell checker
-1);
/* Delete GStrings including string data. */ /* Delete GStrings including string data. */
/* Cell store copies String type data items */ /* Cell store copies String type data items */

View File

@ -52,9 +52,9 @@ static void convert_error_level_to_color(GdkRGBA *color, unsigned int error_leve
color->green = 0.0; color->green = 0.0;
} else if (error_level & LIB_CELL_RENDERER_ERROR_WARN) { } else if (error_level & LIB_CELL_RENDERER_ERROR_WARN) {
/* Only warning set; orange color */ /* Only warning set; orange color */
color->red = 1.0; color->red = 0.6;
color->blue = 0.0; color->blue = 0.0;
color->green = 0.6; color->green = 0.4;
} else { } else {
/* Everything okay; green color */ /* Everything okay; green color */
color->red = (double)61.0/(double)255.0; color->red = (double)61.0/(double)255.0;