From b08f7be81f4ca872937b85033d05fdb76e061186 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Note Date: Tue, 25 Dec 2007 21:27:31 +0100 Subject: [PATCH] [xdl2bit] first compiling and running version of xdl2bit for virtex4 --- _far_v4.h | 14 ++++++++ _far_v5.h | 12 +++++++ bitstream_parser_common.c | 71 ++++++++++++++++++++++++++++++++++++--- bitstream_v4.c | 21 ++++++++++++ xdl/Makefile.am | 12 +++++-- xdl/xdl_parser.y | 7 +++- 6 files changed, 129 insertions(+), 8 deletions(-) diff --git a/_far_v4.h b/_far_v4.h index f12d856..490109e 100644 --- a/_far_v4.h +++ b/_far_v4.h @@ -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, diff --git a/_far_v5.h b/_far_v5.h index 6056941..c39a1f3 100644 --- a/_far_v5.h +++ b/_far_v5.h @@ -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, diff --git a/bitstream_parser_common.c b/bitstream_parser_common.c index 9e49af9..f0996a8 100644 --- a/bitstream_parser_common.c +++ b/bitstream_parser_common.c @@ -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) @@ -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 */ @@ -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) { diff --git a/bitstream_v4.c b/bitstream_v4.c index ce0dea8..1e15c6d 100644 --- a/bitstream_v4.c +++ b/bitstream_v4.c @@ -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; /* diff --git a/xdl/Makefile.am b/xdl/Makefile.am index 4e7b08f..d4c1435 100644 --- a/xdl/Makefile.am +++ b/xdl/Makefile.am @@ -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@ diff --git a/xdl/xdl_parser.y b/xdl/xdl_parser.y index dc1d0ad..f495ec7 100644 --- a/xdl/xdl_parser.y +++ b/xdl/xdl_parser.y @@ -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 */ } }