Compare commits
No commits in common. "ae2e6552ce5acc579b4015685345289d6f34ffe7" and "0834cf0c0de949112cd35f72a81354df1f5a70ae" have entirely different histories.
ae2e6552ce
...
0834cf0c0d
@ -5,11 +5,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int fpga_generate_bitstream(struct fpga_chain *chain,
|
int fpga_generate_bitstream(struct fpga_chain *chain,
|
||||||
char *filename, int ascii)
|
char *filename)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
FILE *bitstream = stdout;
|
FILE *bitstream = stderr;
|
||||||
|
|
||||||
if (strcmp(filename, "-")) {
|
if (strcmp(filename, "-")) {
|
||||||
bitstream = fopen(filename, "wb");
|
bitstream = fopen(filename, "wb");
|
||||||
@ -37,13 +37,9 @@ int fpga_generate_bitstream(struct fpga_chain *chain,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < chain->head[i]->type->isp_length; ++j) {
|
for (int j = 0; j < chain->head[i]->type->isp_length; ++j) {
|
||||||
if (ascii)
|
fprintf(bitstream, "%02X ", buf[j] & 0xFF);
|
||||||
fprintf(bitstream, "%02X ", buf[j] & 0xFF);
|
|
||||||
else
|
|
||||||
fputc(buf[j] & 0xFF, bitstream);
|
|
||||||
}
|
}
|
||||||
if (ascii)
|
fprintf(bitstream, "\n");
|
||||||
fprintf(bitstream, "\n");
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
#include "fpga_cell.h"
|
#include "fpga_cell.h"
|
||||||
|
|
||||||
int fpga_generate_bitstream(struct fpga_chain *chain,
|
int fpga_generate_bitstream(struct fpga_chain *chain,
|
||||||
char *filename, int ascii);
|
char *filename);
|
||||||
|
|
||||||
#endif // FPGA_H
|
#endif // FPGA_H
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#include "fpga_fdef_loader.h"
|
#include "fpga_fdef_loader.h"
|
||||||
#include "fpga_global.h"
|
#include "fpga_global.h"
|
||||||
#include "fpga.h"
|
#include "fpga.h"
|
||||||
#include "unistd.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
#define E_FDEF 1
|
#define E_FDEF 1
|
||||||
#define E_BITSTREAM 2
|
#define E_BITSTREAM 2
|
||||||
@ -14,47 +12,11 @@ int development_test_main(int argc, char *argv[])
|
|||||||
struct fpga_cell *entry_cell;
|
struct fpga_cell *entry_cell;
|
||||||
struct fpga_chain *chain;
|
struct fpga_chain *chain;
|
||||||
|
|
||||||
int opt;
|
|
||||||
char *fdef_filename = "fdef/4x4.fdef";
|
char *fdef_filename = "fdef/4x4.fdef";
|
||||||
char *kst_filename = "-";
|
|
||||||
char *bitstream_filename = "-";
|
char *bitstream_filename = "-";
|
||||||
int bitstream_ascii = 0;
|
|
||||||
|
|
||||||
set_log_level(LL_DEBUG);
|
set_log_level(LL_DEBUG);
|
||||||
|
|
||||||
while((opt = getopt(argc, argv, "f:i:o:a")) != -1)
|
|
||||||
{
|
|
||||||
switch(opt)
|
|
||||||
{
|
|
||||||
case 'f':
|
|
||||||
fdef_filename = optarg;
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
kst_filename = optarg;
|
|
||||||
report(LL_WARNING, "Input not yet implemented.");
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
bitstream_filename = optarg;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
bitstream_ascii = 1;
|
|
||||||
break;
|
|
||||||
case ':':
|
|
||||||
case '?':
|
|
||||||
printf("Usage: %s [-f fdef] [-i input.kst] [-o output.bin] [-h]\n"
|
|
||||||
"Generate bitstreams for the TTL-FPGA.\n\n"
|
|
||||||
"When INPUT or OUTPUT is -, read/write standard input.\n\n"
|
|
||||||
" -f\tFDEF FPGA description file, default fdef/4x4.fdef\n"
|
|
||||||
" -i\tKousaten input file, default stdin\n"
|
|
||||||
" -o\tOutput file, default stdout\n"
|
|
||||||
" -a\tGenerate output as ASCII HEX\n",
|
|
||||||
argv[0]);
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entry_cell = fpga_fdef_loader_load(fdef_filename);
|
entry_cell = fpga_fdef_loader_load(fdef_filename);
|
||||||
if (!entry_cell) {
|
if (!entry_cell) {
|
||||||
report(LL_CRITICAL, "Error loading FDEF.");
|
report(LL_CRITICAL, "Error loading FDEF.");
|
||||||
@ -72,9 +34,9 @@ int development_test_main(int argc, char *argv[])
|
|||||||
/* TODO: Configure application specific logic */
|
/* TODO: Configure application specific logic */
|
||||||
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->lut_in_sel[0] = 'A';
|
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->lut_in_sel[0] = 'A';
|
||||||
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->drive_sel[0] = 'C';
|
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->drive_sel[0] = 'C';
|
||||||
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->LUT4 = 0x0F;
|
((struct fpga_cell_lut34 *)(entry_cell->cell_connections[RIGHT]))->LUT4 = 0;
|
||||||
|
|
||||||
if (fpga_generate_bitstream(chain, bitstream_filename, bitstream_ascii)) {
|
if (fpga_generate_bitstream(chain, bitstream_filename)) {
|
||||||
report(LL_ERROR, "Bitstream generation failed.");
|
report(LL_ERROR, "Bitstream generation failed.");
|
||||||
return E_BITSTREAM;
|
return E_BITSTREAM;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user