Skip to content

Commit

Permalink
[xdl2bit] first compiling and running version of xdl2bit for virtex4
Browse files Browse the repository at this point in the history
  • Loading branch information
jbnote committed Dec 25, 2007
1 parent 356a40b commit b08f7be
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 8 deletions.
14 changes: 14 additions & 0 deletions _far_v4.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ chip_struct_t bitdescr[XC4VLX__NUM] = {
.row_count = 6, },
};

static const gchar *
chipfiles[XC4VLX__NUM] = {
[XC4VLX15] = "xc4vlx15",
[XC4VLX25] = "xc4vlx25",
[XC4VLX40] = "xc4vlx40",
[XC4VLX60] = "xc4vlx60",
[XC4VLX80] = "xc4vlx80",
[XC4VLX100] = "xc4vlx100",
[XC4VLX160] = "xc4vlx160",
[XC4VLX200] = "xc4vlx200",
};

#define CHIPS__NUM XC4VLX__NUM

typedef enum _ba_v4_col_type {
BA_TYPE_CLB = 0,
BA_TYPE_BRAM_INT,
Expand Down
12 changes: 12 additions & 0 deletions _far_v5.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ chip_struct_t bitdescr[XC5VLX__NUM] = {
},
};

static const gchar *
chipfiles[XC5VLX__NUM] = {
[XC5VLX30] = "xc5vlx30",
[XC5VLX50] = "xc5vlx50",
[XC5VLX85] = "xc5vlx85",
[XC5VLX110] = "xc5vlx110",
[XC5VLX220] = "xc5vlx220",
[XC5VLX330] = "xc5vlx330",
};

#define CHIPS__NUM XC5VLX__NUM

typedef enum parser_state {
STATE_IDLE = 0,
STATE_UNSYNCHED,
Expand Down
71 changes: 67 additions & 4 deletions bitstream_parser_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,23 @@ frames_of_type(const chip_struct_t *chip_struct,
return 2 * chip_struct->row_count * type_col_count(col_count,type) * frame_count_v[type];
}

static inline gsize
total_frame_count(const chip_struct_t *chip_struct) {
gsize total_size = 0;
design_col_t type;
/* We need room for the frames themselves */
for (type = 0; type < VC__NB_CFG; type++)
total_size += frames_of_type(chip_struct, type);
return total_size;
}

static void
alloc_indexer(bitstream_parsed_t *parsed) {
const chip_struct_t *chip_struct = parsed->chip_struct;
gsize total_size = 0;
gsize type_offset = 0;
design_col_t type;
gsize total_size = 0;
const gchar ***type_lut, **frame_array;
design_col_t type;

/* The frame array is a triple-lookup array:
- first index is index type (design_col_t, length VC__NB_CFG)
Expand All @@ -330,8 +340,7 @@ alloc_indexer(bitstream_parsed_t *parsed) {
total_size += VC__NB_CFG * sizeof(gchar **);

/* We need room for the frames themselves */
for (type = 0; type < VC__NB_CFG; type++)
total_size += frames_of_type(chip_struct, type) * sizeof(gchar *);
total_size += total_frame_count(chip_struct) * sizeof(gchar *);

/* We allocate only one big array with the type_lut at the beginning
and the frame_array at the end */
Expand Down Expand Up @@ -359,6 +368,60 @@ free_indexer(bitstream_parsed_t *parsed) {
g_array_free(frames, TRUE);
}

/* XXX these functions burden the read-only case. To be put elsewhere
at some point */
static void
fill_indexer(bitstream_parsed_t *parsed) {
gchar **frame_array = (gchar **) &parsed->frames[VC__NB_CFG];
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned total_frames = total_frame_count(chip_struct);
const unsigned framelen = chip_struct->framelen;
uint32_t *current_frame;
unsigned i;

/* Alloc *all* frames. A bit tedious... */
current_frame = g_new0(uint32_t, total_frames * framelen);

for(i = 0; i < total_frames; i++) {
frame_array[i] = (char *)current_frame;
current_frame += framelen;
}
}

static void
empty_indexer(bitstream_parsed_t *parsed) {
gchar **frame_array = (gchar **) &parsed->frames[VC__NB_CFG];
/* Free *all* frames at once. Easy... */
g_free (frame_array[0]);
}

int
alloc_wbitstream(bitstream_parsed_t *parsed) {
/* Lookup the name */
const header_option_p *devopt = get_option(&parsed->header, DEVICE_TYPE);
const char *name = devopt->data;
int i;

for (i = CHIPS__NUM - 1; i >= 0; i--) {
const char *chipname = chipfiles[i];
if (!strncmp(name,chipname,strlen(chipname))) {
parsed->chip_struct = &bitdescr[i];
alloc_indexer(parsed);
fill_indexer(parsed);
return 0;
}
}
return -1;
}

void
free_wbitstream(bitstream_parsed_t *parsed) {
empty_indexer(parsed);
free_indexer(parsed);
}

/* XXX End-of-burden */

void
iterate_over_frames(const bitstream_parsed_t *parsed,
frame_iterator_t iter, void *itdat) {
Expand Down
21 changes: 21 additions & 0 deletions bitstream_v4.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,27 @@ query_bitstream_luts(const bitstream_parsed_t *bitstream,
return;
}

void
set_bitstream_lut(const bitstream_parsed_t *bitstream,
const csite_descr_t *site,
const guint16 lut_val, const unsigned lut_i) {
(void) bitstream;
(void) site;
(void) lut_val;
(void) lut_i;
}

void set_bitstream_site_bits(const bitstream_parsed_t * bitstream,
const csite_descr_t *site,
const uint32_t vals,
const guint cfgbits[], const gsize nbits) {
(void) bitstream;
(void) site;
(void) vals;
(void) cfgbits;
(void) nbits;
}

typedef int property_t;

/*
Expand Down
12 changes: 9 additions & 3 deletions xdl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ SHARED_SRC = ../bitarray.c ../bitheader.c ../filedump.c \
../localpips.c ../wiring.c ../keyfile.c \
../analysis.c ../connexity.c ../xdlout.c ../sites.c \
../bitstream_write.c
V2_SRC = ../bitstream.c ../bitstream_parser.c ../codes/crc-ibm.c
PARSER_SRC = xdl2bit.c xdl_lexer.l xdl_parser.y parser.h

bin_PROGRAMS = xdl2bit xdl2bit_v4

bin_PROGRAMS = xdl2bit
xdl2bit_SOURCES = xdl2bit.c xdl_lexer.l xdl_parser.y parser.h $(SHARED_SRC) $(V2_SRC)
V2_SRC = ../bitstream.c ../bitstream_parser.c ../codes/crc-ibm.c
xdl2bit_SOURCES = $(PARSER_SRC) $(SHARED_SRC) $(V2_SRC)
xdl2bit_CFLAGS = $(AM_CFLAGS) @GLIB_CFLAGS@ -DVIRTEX2
xdl2bit_LDADD = @GLIB_LIBS@ @GTK_LIBS@

V4_SRC = ../bitstream_v4.c ../bitstream_parser_common.c ../codes/crc32-c.c ../codes/xhamming.c
xdl2bit_v4_SOURCES = $(PARSER_SRC) $(SHARED_SRC) $(V4_SRC)
xdl2bit_v4_CFLAGS = $(AM_CFLAGS) @GLIB_CFLAGS@ -DVIRTEX4
xdl2bit_v4_LDADD = @GLIB_LIBS@ @GTK_LIBS@
7 changes: 6 additions & 1 deletion xdl/xdl_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,13 @@ static void write_property(const parser_t *parser,
return;
}
if (!strcmp(prop, "_GND_SOURCE")) {
/* I've only ever seen Y, so check for this assumption. */
#if defined(VIRTEX2)
/* I've only ever seen Y, and i'd like to be informed of other
possibilities, so check for this assumption. */
assert(peek_property(parser) && !strcmp(peek_property(parser),"Y"));
#elif defined(VIRTEX4)
assert(peek_property(parser) && !strcmp(peek_property(parser),"HARD0"));
#endif /* defined */
}
}

Expand Down

0 comments on commit b08f7be

Please sign in to comment.