Compare commits
4 Commits
d81c6d1037
...
eeae61ad47
Author | SHA1 | Date | |
---|---|---|---|
eeae61ad47 | |||
3146ca801f | |||
43fdab4533 | |||
59835018af |
@ -662,7 +662,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
break;
|
||||
case SREF:
|
||||
if (current_cell == NULL) {
|
||||
GDS_ERROR("Path outside of cell");
|
||||
GDS_ERROR("Cell Reference outside of cell");
|
||||
run = -3;
|
||||
break;
|
||||
}
|
||||
@ -810,7 +810,11 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
break;
|
||||
|
||||
case SNAME:
|
||||
name_cell_ref(current_s_reference, read, workbuff);
|
||||
if (current_s_reference) {
|
||||
name_cell_ref(current_s_reference, (unsigned int)read, workbuff);
|
||||
} else {
|
||||
GDS_ERROR("reference name set outside of cell reference.\n");
|
||||
}
|
||||
break;
|
||||
case WIDTH:
|
||||
if (!current_graphics) {
|
||||
@ -863,7 +867,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
break;
|
||||
}
|
||||
if (current_graphics->gfx_type == GRAPHIC_PATH) {
|
||||
current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff);
|
||||
current_graphics->path_render_type = (enum path_type)gds_convert_signed_int16(workbuff);
|
||||
GDS_INF("\t\tPathtype: %d\n", current_graphics->path_render_type);
|
||||
} else {
|
||||
GDS_WARN("Path type defined inside non-path graphics object. Ignoring");
|
||||
|
@ -84,31 +84,117 @@ int gds_tree_check_cell_references(struct gds_library *lib)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function sets the marker element in the check structure of each cell to zero.
|
||||
* @param lib Library to work with
|
||||
* @return 0 if successful; negative if a fault (null pointer, ...) occured.
|
||||
* @brief Check if list contains a cell
|
||||
* @param list GList to check. May be a null pointer
|
||||
* @param cell Cell to check for
|
||||
* @return 0 if cell is not in list. 1 if cell is in list
|
||||
*/
|
||||
static int gds_tree_check_clear_cell_check_marker(struct gds_library *lib)
|
||||
static int gds_tree_check_list_contains_cell(GList *list, struct gds_cell *cell) {
|
||||
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;
|
||||
struct gds_cell *cell;
|
||||
struct gds_cell *cell_to_check;
|
||||
GList *visited_cells = NULL;
|
||||
|
||||
|
||||
if (!lib)
|
||||
return -1;
|
||||
|
||||
for (cell_iter = lib->cells; cell_iter != NULL; cell_iter = g_list_next(cell_iter)) {
|
||||
cell = (struct gds_cell *)cell_iter->data;
|
||||
cell_to_check = (struct gds_cell *)cell_iter->data;
|
||||
|
||||
if (!cell)
|
||||
/* A broken cell reference will be counted fatal in this case */
|
||||
if (!cell_to_check)
|
||||
return -2;
|
||||
|
||||
cell->checks._internal.marker = 0;
|
||||
}
|
||||
}
|
||||
/* iterate through references and check if loop exists */
|
||||
res = gds_tree_check_iterate_ref_and_check(cell_to_check, &visited_cells);
|
||||
|
||||
int gds_tree_check_reference_loops(struct gds_library *lib)
|
||||
{
|
||||
return 0;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (visited_cells) {
|
||||
fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n");
|
||||
g_list_free(visited_cells);
|
||||
}
|
||||
|
||||
return loop_count;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "cairo-output/cairo-output.h"
|
||||
#include "trigonometric/cell-trigonometrics.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
|
||||
@ -115,6 +116,7 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
char *filename;
|
||||
GString *mod_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,
|
||||
"Cancel", GTK_RESPONSE_CANCEL, "Open GDSII", GTK_RESPONSE_ACCEPT, NULL);
|
||||
@ -162,6 +164,11 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
CELL_SEL_ACCESSDATE, acc_date->str,
|
||||
-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. */
|
||||
/* Cell store copies String type data items */
|
||||
g_string_free(mod_date, TRUE);
|
||||
@ -175,16 +182,21 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
mod_date = generate_string_from_date(&gds_c->mod_time);
|
||||
acc_date = generate_string_from_date(&gds_c->access_time);
|
||||
|
||||
/* Add cell to tree store model
|
||||
* CELL_SEL_CELL_COLOR will always be green,
|
||||
* because no cell cehcker is implemented, yet.
|
||||
*/
|
||||
/* Get the checking results for this cell */
|
||||
cell_error_level = 0;
|
||||
if (gds_c->checks.unresolved_child_count)
|
||||
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,
|
||||
CELL_SEL_CELL, gds_c,
|
||||
CELL_SEL_MODDATE, mod_date->str,
|
||||
CELL_SEL_ACCESSDATE, acc_date->str,
|
||||
CELL_SEL_CELL_ERROR_STATE, 0, // TODO: implement cell checker
|
||||
-1);
|
||||
CELL_SEL_CELL_ERROR_STATE, cell_error_level, -1);
|
||||
|
||||
/* Delete GStrings including string data. */
|
||||
/* Cell store copies String type data items */
|
||||
|
@ -52,9 +52,9 @@ static void convert_error_level_to_color(GdkRGBA *color, unsigned int error_leve
|
||||
color->green = 0.0;
|
||||
} else if (error_level & LIB_CELL_RENDERER_ERROR_WARN) {
|
||||
/* Only warning set; orange color */
|
||||
color->red = 0.6;
|
||||
color->red = 1.0;
|
||||
color->blue = 0.0;
|
||||
color->green = 0.4;
|
||||
color->green = 0.6;
|
||||
} else {
|
||||
/* Everything okay; green color */
|
||||
color->red = (double)61.0/(double)255.0;
|
||||
|
Loading…
Reference in New Issue
Block a user