disable auto-crc by default
This commit is contained in:
parent
3116d6af9d
commit
99a855dddd
10
bit2fp.c
10
bit2fp.c
|
@ -12,7 +12,7 @@
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
struct fpga_model model;
|
struct fpga_model model;
|
||||||
int bit_header, bit_regs, fp_header, pull_model, file_arg, flags;
|
int bit_header, bit_regs, bit_crc, fp_header, pull_model, file_arg, flags;
|
||||||
int print_swbits, rc = -1;
|
int print_swbits, rc = -1;
|
||||||
struct fpga_config config;
|
struct fpga_config config;
|
||||||
|
|
||||||
|
@ -21,13 +21,14 @@ int main(int argc, char** argv)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
"%s - bitstream to floorplan\n"
|
"%s - bitstream to floorplan\n"
|
||||||
"Usage: %s [--bit-header] [--bit-regs] [--no-model] [--no-fp-header]\n"
|
"Usage: %s [--bit-header] [--bit-regs] [--bit-crc] [--no-model]\n"
|
||||||
" %*s [--printf-swbits] <bitstream_file>\n"
|
" %*s [--no-fp-header] [--printf-swbits] <bitstream_file>\n"
|
||||||
"\n", argv[0], argv[0], (int) strlen(argv[0]), "");
|
"\n", argv[0], argv[0], (int) strlen(argv[0]), "");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
bit_header = 0;
|
bit_header = 0;
|
||||||
bit_regs = 0;
|
bit_regs = 0;
|
||||||
|
bit_crc = 0;
|
||||||
pull_model = 1;
|
pull_model = 1;
|
||||||
fp_header = 1;
|
fp_header = 1;
|
||||||
file_arg = 1;
|
file_arg = 1;
|
||||||
|
@ -38,6 +39,8 @@ int main(int argc, char** argv)
|
||||||
bit_header = 1;
|
bit_header = 1;
|
||||||
else if (!strcmp(argv[file_arg], "--bit-regs"))
|
else if (!strcmp(argv[file_arg], "--bit-regs"))
|
||||||
bit_regs = 1;
|
bit_regs = 1;
|
||||||
|
else if (!strcmp(argv[file_arg], "--bit-crc"))
|
||||||
|
bit_crc = 1;
|
||||||
else if (!strcmp(argv[file_arg], "--no-model"))
|
else if (!strcmp(argv[file_arg], "--no-model"))
|
||||||
pull_model = 0;
|
pull_model = 0;
|
||||||
else if (!strcmp(argv[file_arg], "--no-fp-header"))
|
else if (!strcmp(argv[file_arg], "--no-fp-header"))
|
||||||
|
@ -83,6 +86,7 @@ int main(int argc, char** argv)
|
||||||
flags = DUMP_BITS;
|
flags = DUMP_BITS;
|
||||||
if (bit_header) flags |= DUMP_HEADER_STR;
|
if (bit_header) flags |= DUMP_HEADER_STR;
|
||||||
if (bit_regs) flags |= DUMP_REGS;
|
if (bit_regs) flags |= DUMP_REGS;
|
||||||
|
if (bit_crc) flags |= DUMP_CRC;
|
||||||
if ((rc = dump_config(&config, flags))) FAIL(rc);
|
if ((rc = dump_config(&config, flags))) FAIL(rc);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
fail:
|
fail:
|
||||||
|
|
|
@ -17,6 +17,7 @@ enum fpga_config_reg {
|
||||||
#define REG_NOOP -1 // pseudo register for noops
|
#define REG_NOOP -1 // pseudo register for noops
|
||||||
|
|
||||||
#define COR1_DEF 0x3D00
|
#define COR1_DEF 0x3D00
|
||||||
|
#define COR1_CRC_BYPASS 0x0010
|
||||||
#define COR2_DEF 0x09EE
|
#define COR2_DEF 0x09EE
|
||||||
|
|
||||||
#define MASK_DEF 0xCF
|
#define MASK_DEF 0xCF
|
||||||
|
@ -66,6 +67,9 @@ struct fpga_bits
|
||||||
int len;
|
int len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Use the default value together with COR1 CRC_BYPASS
|
||||||
|
#define DEFAULT_AUTO_CRC 0x9876DEFC
|
||||||
|
|
||||||
struct fpga_config
|
struct fpga_config
|
||||||
{
|
{
|
||||||
char header_str[4][MAX_HEADER_STR_LEN];
|
char header_str[4][MAX_HEADER_STR_LEN];
|
||||||
|
@ -78,6 +82,7 @@ struct fpga_config
|
||||||
int FLR_reg;
|
int FLR_reg;
|
||||||
|
|
||||||
struct fpga_bits bits;
|
struct fpga_bits bits;
|
||||||
|
uint32_t auto_crc;
|
||||||
};
|
};
|
||||||
|
|
||||||
int read_bitfile(struct fpga_config* cfg, FILE* f);
|
int read_bitfile(struct fpga_config* cfg, FILE* f);
|
||||||
|
@ -85,6 +90,7 @@ int read_bitfile(struct fpga_config* cfg, FILE* f);
|
||||||
#define DUMP_HEADER_STR 0x0001
|
#define DUMP_HEADER_STR 0x0001
|
||||||
#define DUMP_REGS 0x0002
|
#define DUMP_REGS 0x0002
|
||||||
#define DUMP_BITS 0x0004
|
#define DUMP_BITS 0x0004
|
||||||
|
#define DUMP_CRC 0x0008
|
||||||
int dump_config(struct fpga_config* cfg, int flags);
|
int dump_config(struct fpga_config* cfg, int flags);
|
||||||
|
|
||||||
void free_config(struct fpga_config* cfg);
|
void free_config(struct fpga_config* cfg);
|
||||||
|
|
|
@ -351,9 +351,9 @@ static int bitpos_is_set(struct extract_state* es, int y, int x,
|
||||||
|
|
||||||
if (swpos->minor == 20) {
|
if (swpos->minor == 20) {
|
||||||
two_bits_val = ((get_bit(es->bits, row_num, es->model->x_major[x],
|
two_bits_val = ((get_bit(es->bits, row_num, es->model->x_major[x],
|
||||||
20, start_in_frame + swpos->two_bits_o) != 0) << 0)
|
20, start_in_frame + swpos->two_bits_o) != 0) << 1)
|
||||||
| ((get_bit(es->bits, row_num, es->model->x_major[x],
|
| ((get_bit(es->bits, row_num, es->model->x_major[x],
|
||||||
20, start_in_frame + swpos->two_bits_o+1) != 0) << 1);
|
20, start_in_frame + swpos->two_bits_o+1) != 0) << 0);
|
||||||
if (two_bits_val != swpos->two_bits_val)
|
if (two_bits_val != swpos->two_bits_val)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ static void dump_header(struct fpga_config* cfg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_regs(struct fpga_config* cfg, int start, int end)
|
static int dump_regs(struct fpga_config* cfg, int start, int end, int dump_crc)
|
||||||
{
|
{
|
||||||
uint16_t u16;
|
uint16_t u16;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
@ -156,8 +156,10 @@ static int dump_regs(struct fpga_config* cfg, int start, int end)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cfg->reg[i].reg == CRC) {
|
if (cfg->reg[i].reg == CRC) {
|
||||||
// Don't print CRC cfg->reg[i].int_v for cleaner diff.
|
if (dump_crc)
|
||||||
printf("T1 CRC\n");
|
printf("T1 CRC 0x%X\n", cfg->reg[i].int_v);
|
||||||
|
else
|
||||||
|
printf("T1 CRC\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cfg->reg[i].reg == COR1) {
|
if (cfg->reg[i].reg == COR1) {
|
||||||
|
@ -905,7 +907,7 @@ int dump_config(struct fpga_config* cfg, int flags)
|
||||||
if (flags & DUMP_HEADER_STR)
|
if (flags & DUMP_HEADER_STR)
|
||||||
dump_header(cfg);
|
dump_header(cfg);
|
||||||
if (flags & DUMP_REGS) {
|
if (flags & DUMP_REGS) {
|
||||||
rc = dump_regs(cfg, /*start*/ 0, cfg->num_regs_before_bits);
|
rc = dump_regs(cfg, /*start*/ 0, cfg->num_regs_before_bits, flags & DUMP_CRC);
|
||||||
if (rc) FAIL(rc);
|
if (rc) FAIL(rc);
|
||||||
}
|
}
|
||||||
if (flags & DUMP_BITS) {
|
if (flags & DUMP_BITS) {
|
||||||
|
@ -915,9 +917,11 @@ int dump_config(struct fpga_config* cfg, int flags)
|
||||||
if (rc) FAIL(rc);
|
if (rc) FAIL(rc);
|
||||||
printf_iob(cfg->bits.d, cfg->bits.len,
|
printf_iob(cfg->bits.d, cfg->bits.len,
|
||||||
BRAM_DATA_START + BRAM_DATA_LEN, 896*2/8);
|
BRAM_DATA_START + BRAM_DATA_LEN, 896*2/8);
|
||||||
|
if (flags & DUMP_CRC)
|
||||||
|
printf("auto-crc 0x%X\n", cfg->auto_crc);
|
||||||
}
|
}
|
||||||
if (flags & DUMP_REGS) {
|
if (flags & DUMP_REGS) {
|
||||||
rc = dump_regs(cfg, cfg->num_regs_before_bits, cfg->num_regs);
|
rc = dump_regs(cfg, cfg->num_regs_before_bits, cfg->num_regs, flags & DUMP_CRC);
|
||||||
if (rc) FAIL(rc);
|
if (rc) FAIL(rc);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1021,6 +1025,7 @@ static int read_bits(struct fpga_config* cfg, uint8_t* d, int len, int inpos, in
|
||||||
cfg->bits.len = (4*505 + 4*144) * 130 + 896*2;
|
cfg->bits.len = (4*505 + 4*144) * 130 + 896*2;
|
||||||
cfg->bits.d = calloc(cfg->bits.len, 1 /* elsize */);
|
cfg->bits.d = calloc(cfg->bits.len, 1 /* elsize */);
|
||||||
if (!cfg->bits.d) FAIL(ENOMEM);
|
if (!cfg->bits.d) FAIL(ENOMEM);
|
||||||
|
cfg->auto_crc = 0;
|
||||||
|
|
||||||
FAR_block = -1;
|
FAR_block = -1;
|
||||||
FAR_row = -1;
|
FAR_row = -1;
|
||||||
|
@ -1185,8 +1190,7 @@ static int read_bits(struct fpga_config* cfg, uint8_t* d, int len, int inpos, in
|
||||||
if (u16) FAIL(EINVAL);
|
if (u16) FAIL(EINVAL);
|
||||||
}
|
}
|
||||||
src_off += 2*u32;
|
src_off += 2*u32;
|
||||||
// two CRC words
|
cfg->auto_crc = __be32_to_cpu(*(uint32_t*)&d[src_off]);
|
||||||
u32 = __be32_to_cpu(*(uint32_t*)&d[src_off]);
|
|
||||||
src_off += 4;
|
src_off += 4;
|
||||||
}
|
}
|
||||||
rc = EINVAL;
|
rc = EINVAL;
|
||||||
|
@ -1455,7 +1459,7 @@ static struct fpga_config_reg_rw s_defregs_before_bits[] =
|
||||||
{{ CMD, .int_v = CMD_RCRC },
|
{{ CMD, .int_v = CMD_RCRC },
|
||||||
{ REG_NOOP },
|
{ REG_NOOP },
|
||||||
{ FLR, .int_v = 896 },
|
{ FLR, .int_v = 896 },
|
||||||
{ COR1, .int_v = COR1_DEF },
|
{ COR1, .int_v = COR1_DEF | COR1_CRC_BYPASS },
|
||||||
{ COR2, .int_v = COR2_DEF },
|
{ COR2, .int_v = COR2_DEF },
|
||||||
{ IDCODE, .int_v = XC6SLX9 },
|
{ IDCODE, .int_v = XC6SLX9 },
|
||||||
{ MASK, .int_v = MASK_DEF },
|
{ MASK, .int_v = MASK_DEF },
|
||||||
|
@ -1498,7 +1502,7 @@ static struct fpga_config_reg_rw s_defregs_after_bits[] =
|
||||||
{ CMD, .int_v = CMD_START },
|
{ CMD, .int_v = CMD_START },
|
||||||
{ MASK, .int_v = MASK_DEF | MASK_SECURITY },
|
{ MASK, .int_v = MASK_DEF | MASK_SECURITY },
|
||||||
{ CTL, .int_v = CTL_DEF },
|
{ CTL, .int_v = CTL_DEF },
|
||||||
{ CRC },
|
{ CRC, .int_v = DEFAULT_AUTO_CRC },
|
||||||
{ CMD, .int_v = CMD_DESYNC },
|
{ CMD, .int_v = CMD_DESYNC },
|
||||||
{ REG_NOOP }, { REG_NOOP }, { REG_NOOP }, { REG_NOOP },
|
{ REG_NOOP }, { REG_NOOP }, { REG_NOOP }, { REG_NOOP },
|
||||||
{ REG_NOOP }, { REG_NOOP }, { REG_NOOP }, { REG_NOOP },
|
{ REG_NOOP }, { REG_NOOP }, { REG_NOOP }, { REG_NOOP },
|
||||||
|
@ -1665,7 +1669,8 @@ static int write_bits(FILE* f, struct fpga_model* model)
|
||||||
nwritten = fwrite(&u16, /*size*/ 1, sizeof(u16), f);
|
nwritten = fwrite(&u16, /*size*/ 1, sizeof(u16), f);
|
||||||
if (nwritten != sizeof(u16)) FAIL(errno);
|
if (nwritten != sizeof(u16)) FAIL(errno);
|
||||||
|
|
||||||
u32 = 0; // todo: 32-bit auto-crc value
|
// todo: support real auto-crc calculation
|
||||||
|
u32 = DEFAULT_AUTO_CRC;
|
||||||
u32 = __cpu_to_be32(u32);
|
u32 = __cpu_to_be32(u32);
|
||||||
nwritten = fwrite(&u32, /*size*/ 1, sizeof(u32), f);
|
nwritten = fwrite(&u32, /*size*/ 1, sizeof(u32), f);
|
||||||
if (nwritten != sizeof(u32)) FAIL(errno);
|
if (nwritten != sizeof(u32)) FAIL(errno);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user