mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-17 23:11:53 +02:00
c9af8cd0fe
using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
134 lines
2.1 KiB
C
134 lines
2.1 KiB
C
/*
|
|
* bitset.c - Arbitrary-length bit sets
|
|
*
|
|
* Written 2010 by Werner Almesberger
|
|
* Copyright 2010 by Werner Almesberger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "util.h"
|
|
#include "bitset.h"
|
|
|
|
|
|
struct bitset {
|
|
int v_n;
|
|
unsigned *v;
|
|
};
|
|
|
|
#define BITS (sizeof(unsigned)*8)
|
|
|
|
|
|
struct bitset *bitset_new(int n)
|
|
{
|
|
struct bitset *new;
|
|
|
|
new = alloc_type(struct bitset);
|
|
new->v_n = (n+BITS-1) & ~(BITS-1);
|
|
new->v = zalloc_size(sizeof(unsigned)*new->v_n);
|
|
return new;
|
|
}
|
|
|
|
|
|
struct bitset *bitset_clone(const struct bitset *old)
|
|
{
|
|
struct bitset *new;
|
|
size_t bytes;
|
|
|
|
new = alloc_type(struct bitset);
|
|
bytes = sizeof(unsigned)*old->v_n;
|
|
new->v_n = old->v_n;
|
|
new->v = alloc_size(bytes);
|
|
memcpy(new->v, old->v, bytes);
|
|
return new;
|
|
}
|
|
|
|
|
|
void bitset_free(struct bitset *set)
|
|
{
|
|
free(set->v);
|
|
free(set);
|
|
}
|
|
|
|
|
|
void bitset_set(struct bitset *set, int n)
|
|
{
|
|
assert(n < set->v_n*BITS);
|
|
set->v[n/BITS] |= 1U << (n % BITS);
|
|
}
|
|
|
|
|
|
void bitset_clear(struct bitset *set, int n)
|
|
{
|
|
assert(n < set->v_n*BITS);
|
|
set->v[n/BITS] &= ~(1U << (n % BITS));
|
|
}
|
|
|
|
|
|
int bitset_pick(const struct bitset *set, int n)
|
|
{
|
|
assert(n < set->v_n*BITS);
|
|
return !!(set->v[n/BITS] & (1U << (n % BITS)));
|
|
}
|
|
|
|
|
|
int bitset_is_empty(const struct bitset *set)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i != set->v_n; i++)
|
|
if (set->v[i])
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
|
|
void bitset_zero(struct bitset *a)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i != a->v_n; i++)
|
|
a->v[i] = 0;
|
|
}
|
|
|
|
|
|
void bitset_and(struct bitset *a, const struct bitset *b)
|
|
{
|
|
int i;
|
|
|
|
assert(a->v_n == b->v_n);
|
|
for (i = 0; i != a->v_n; i++)
|
|
a->v[i] &= b->v[i];
|
|
}
|
|
|
|
|
|
void bitset_or(struct bitset *a, const struct bitset *b)
|
|
{
|
|
int i;
|
|
|
|
assert(a->v_n == b->v_n);
|
|
for (i = 0; i != a->v_n; i++)
|
|
a->v[i] |= b->v[i];
|
|
}
|
|
|
|
|
|
int bitset_ge(const struct bitset *a, const struct bitset *b)
|
|
{
|
|
int i;
|
|
|
|
assert(a->v_n == b->v_n);
|
|
for (i = 0; i != a->v_n; i++)
|
|
if (~a->v[i] & b->v[i])
|
|
return 0;
|
|
return 1;
|
|
}
|