diff options
author | Emmanuel Mogenet <emogenet@gmail.com> | 2017-04-16 21:22:16 +0200 |
---|---|---|
committer | Emmanuel Mogenet <emogenet@gmail.com> | 2017-04-16 21:22:16 +0200 |
commit | 5e2df60d66d601f327d9c31e1880806aee6eb2e4 (patch) | |
tree | 5023ec436c1ea5b55ccc645db0c30d44168e7e7c | |
parent | 5f15887ceb8460aa5b5120b1fc4f90b6ebfd06cb (diff) | |
download | ghdl-5e2df60d66d601f327d9c31e1880806aee6eb2e4.tar.gz ghdl-5e2df60d66d601f327d9c31e1880806aee6eb2e4.tar.bz2 ghdl-5e2df60d66d601f327d9c31e1880806aee6eb2e4.zip |
Move skip flag to its own array in ghwlib
-rw-r--r-- | src/grt/ghwdump.c | 2 | ||||
-rw-r--r-- | src/grt/ghwlib.c | 79 | ||||
-rw-r--r-- | src/grt/ghwlib.h | 4 |
3 files changed, 49 insertions, 36 deletions
diff --git a/src/grt/ghwdump.c b/src/grt/ghwdump.c index 3c399cf92..9bea0a17f 100644 --- a/src/grt/ghwdump.c +++ b/src/grt/ghwdump.c @@ -274,7 +274,7 @@ main (int argc, char **argv) { if (!filter_done) { - ghw_filter_values (hp, signal_set, nb_signals); + ghw_filter_signals (hp, signal_set, nb_signals); filter_done = 1; } ghw_disp_values (hp); diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index 4ac721ee0..c16936b1e 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -839,6 +839,7 @@ ghw_read_hie (struct ghw_handler *h) h->hie = blk; h->nbr_sigs++; + h->skip_sigs = NULL; h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig)); memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig)); @@ -1345,45 +1346,57 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } -static int -is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal) -{ - int i; - - for (i = 0; i < nb_signals_to_keep; ++i) - { - if (signal==signals_to_keep[i]) - return 0; +static char is_skip_signal( + int *signals_to_keep, + int nb_signals_to_keep, + int signal +) { + int i; + for(i=0; i<nb_signals_to_keep; ++i) { + if(signal==signals_to_keep[i]) { + return 0; + } } - return 1; + return 1; } -void -ghw_filter_values (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep) -{ - int i; - - for (i = 0; i < h->nbr_sigs; ++i) - { - struct ghw_sig *s = &(h->sigs[i]); - s->skip = is_skip_signal (signals_to_keep, nb_signals_to_keep, i); +void ghw_filter_signals( + struct ghw_handler *h, + int *signals_to_keep, + int nb_signals_to_keep +) { + int i; + if(0<nb_signals_to_keep && 0!=signals_to_keep) { + if(0==h->skip_sigs) { + h->skip_sigs = (char*)malloc(sizeof(char)*h->nbr_sigs); + } + for(i=0; i<h->nbr_sigs; ++i) { + h->skip_sigs[i] = is_skip_signal( + signals_to_keep, + nb_signals_to_keep, + i + ); + } + } else { + if(0!=h->skip_sigs) { + free(h->skip_sigs); + h->skip_sigs = 0; + } } } -void -ghw_disp_values (struct ghw_handler *h) -{ - int i; - - for (i = 0; i < h->nbr_sigs; i++) - { - struct ghw_sig *s = &h->sigs[i]; - if (s->type != NULL && !(s->skip)) - { - printf ("#%d: ", i); - ghw_disp_value (s->val, s->type); - printf ("\n"); - } +void ghw_disp_values( + struct ghw_handler *h +) { + int i; + for (i = 0; i < h->nbr_sigs; i++) { + struct ghw_sig *s = &h->sigs[i]; + int skip = (0!=h->skip_sigs && (0!=h->skip_sigs[i])); + if(s->type != NULL && !skip) { + printf ("#%d: ", i); + ghw_disp_value (s->val, s->type); + printf ("\n"); + } } } diff --git a/src/grt/ghwlib.h b/src/grt/ghwlib.h index 145e6c2dd..11917542a 100644 --- a/src/grt/ghwlib.h +++ b/src/grt/ghwlib.h @@ -256,7 +256,6 @@ struct ghw_sig { union ghw_type *type; union ghw_val *val; - int skip; }; enum ghw_hie_kind { @@ -333,6 +332,7 @@ struct ghw_handler /* Non-composite (or basic) signals. */ int nbr_sigs; + char *skip_sigs; struct ghw_sig *sigs; /* Hierarchy. */ @@ -359,7 +359,7 @@ void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top); int ghw_read_base (struct ghw_handler *h); -void ghw_filter_values (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep); +void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep); void ghw_disp_values (struct ghw_handler *h); |