broke up the 5000 line model.c into 7 sub-files
This commit is contained in:
parent
d6c71c0b40
commit
b06d618030
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -3,7 +3,13 @@ bit2txt.o
|
||||||
draw_svg_tiles
|
draw_svg_tiles
|
||||||
draw_svg_tiles.o
|
draw_svg_tiles.o
|
||||||
helper.o
|
helper.o
|
||||||
model.o
|
model_main.o
|
||||||
|
model_tiles.o
|
||||||
|
model_devices.o
|
||||||
|
model_ports.o
|
||||||
|
model_conns.o
|
||||||
|
model_switches.o
|
||||||
|
model_helper.o
|
||||||
new_fp
|
new_fp
|
||||||
new_fp.o
|
new_fp.o
|
||||||
hstrrep
|
hstrrep
|
||||||
|
|
24
Makefile
24
Makefile
|
@ -11,13 +11,15 @@
|
||||||
CFLAGS = -Wall -g
|
CFLAGS = -Wall -g
|
||||||
LDLIBS = -lxml2
|
LDLIBS = -lxml2
|
||||||
|
|
||||||
|
MODEL_OBJ = model_main.o model_tiles.o model_devices.o model_ports.o model_conns.o model_switches.o model_helper.o
|
||||||
|
|
||||||
all: bit2txt draw_svg_tiles new_fp hstrrep sort_seq merge_seq
|
all: bit2txt draw_svg_tiles new_fp hstrrep sort_seq merge_seq
|
||||||
|
|
||||||
new_fp: new_fp.o model.o helper.o
|
new_fp: new_fp.o $(MODEL_OBJ) helper.o
|
||||||
|
|
||||||
new_fp.o: new_fp.c model.h helper.h
|
new_fp.o: new_fp.c model.h helper.h
|
||||||
|
|
||||||
draw_svg_tiles: draw_svg_tiles.o model.o helper.o
|
draw_svg_tiles: draw_svg_tiles.o $(MODEL_OBJ) helper.o
|
||||||
|
|
||||||
draw_svg_tiles.o: draw_svg_tiles.c model.h helper.h
|
draw_svg_tiles.o: draw_svg_tiles.c model.h helper.h
|
||||||
|
|
||||||
|
@ -41,9 +43,21 @@ hstrrep: hstrrep.o helper.o
|
||||||
|
|
||||||
helper.o: helper.c helper.h
|
helper.o: helper.c helper.h
|
||||||
|
|
||||||
model.o: model.c model.h
|
model_main.o: model_main.c model.h
|
||||||
|
|
||||||
xc6slx9_empty.fp: new_fp model.c model.h
|
model_tiles.o: model_tiles.c model.h
|
||||||
|
|
||||||
|
model_devices.o: model_devices.c model.h
|
||||||
|
|
||||||
|
model_ports.o: model_ports.c model.h
|
||||||
|
|
||||||
|
model_conns.o: model_conns.c model.h
|
||||||
|
|
||||||
|
model_switches.o: model_switches.c model.h
|
||||||
|
|
||||||
|
model_helper.o: model_helper.c model.h
|
||||||
|
|
||||||
|
xc6slx9_empty.fp: new_fp
|
||||||
./new_fp > $@
|
./new_fp > $@
|
||||||
|
|
||||||
xc6slx9.svg: draw_svg_tiles
|
xc6slx9.svg: draw_svg_tiles
|
||||||
|
@ -89,7 +103,7 @@ clean:
|
||||||
rm -f bit2txt bit2txt.o \
|
rm -f bit2txt bit2txt.o \
|
||||||
draw_svg_tiles draw_svg_tiles.o \
|
draw_svg_tiles draw_svg_tiles.o \
|
||||||
new_fp new_fp.o \
|
new_fp new_fp.o \
|
||||||
helper.o model.o hstrrep hstrrep.o \
|
helper.o $(MODEL_OBJ) hstrrep hstrrep.o \
|
||||||
sort_seq sort_seq.o \
|
sort_seq sort_seq.o \
|
||||||
merge_seq merge_seq.o \
|
merge_seq merge_seq.o \
|
||||||
xc6slx9_empty.fp xc6slx9_empty.conns xc6slx9_empty.ports \
|
xc6slx9_empty.fp xc6slx9_empty.conns xc6slx9_empty.ports \
|
||||||
|
|
117
model.h
117
model.h
|
@ -261,6 +261,8 @@ void is_in_row(const struct fpga_model* model, int y,
|
||||||
int row_num(int y, struct fpga_model* model);
|
int row_num(int y, struct fpga_model* model);
|
||||||
int row_pos(int y, struct fpga_model* model);
|
int row_pos(int y, struct fpga_model* model);
|
||||||
|
|
||||||
|
const char* logicin_s(int wire, int routing_io);
|
||||||
|
|
||||||
enum fpgadev_type
|
enum fpgadev_type
|
||||||
{
|
{
|
||||||
DEV_LOGIC_M,
|
DEV_LOGIC_M,
|
||||||
|
@ -361,3 +363,118 @@ int fpga_build_model(struct fpga_model* model,
|
||||||
void fpga_free_model(struct fpga_model* model);
|
void fpga_free_model(struct fpga_model* model);
|
||||||
|
|
||||||
const char* fpga_tiletype_str(enum fpga_tile_type type);
|
const char* fpga_tiletype_str(enum fpga_tile_type type);
|
||||||
|
|
||||||
|
int init_tiles(struct fpga_model* model);
|
||||||
|
int init_conns(struct fpga_model* model);
|
||||||
|
int init_ports(struct fpga_model* model);
|
||||||
|
int init_devices(struct fpga_model* model);
|
||||||
|
int init_switches(struct fpga_model* model);
|
||||||
|
|
||||||
|
const char* pf(const char* fmt, ...);
|
||||||
|
const char* wpref(struct fpga_model* model, int y, int x, const char* wire_name);
|
||||||
|
char next_non_whitespace(const char* s);
|
||||||
|
char last_major(const char* str, int cur_o);
|
||||||
|
int has_connpt(struct fpga_model* model, int y, int x, const char* name);
|
||||||
|
int add_connpt_name(struct fpga_model* model, int y, int x, const char* connpt_name);
|
||||||
|
|
||||||
|
int has_device(struct fpga_model* model, int y, int x, int dev);
|
||||||
|
int add_connpt_2(struct fpga_model* model, int y, int x,
|
||||||
|
const char* connpt_name, const char* suffix1, const char* suffix2);
|
||||||
|
|
||||||
|
typedef int (*add_conn_f)(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2);
|
||||||
|
#define NOPREF_BI_F add_conn_bi
|
||||||
|
#define PREF_BI_F add_conn_bi_pref
|
||||||
|
#define NOPREF_UNI_F add_conn_uni
|
||||||
|
#define PREF_UNI_F add_conn_uni_pref
|
||||||
|
|
||||||
|
int add_conn_uni(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2);
|
||||||
|
int add_conn_uni_pref(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2);
|
||||||
|
int add_conn_bi(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2);
|
||||||
|
int add_conn_bi_pref(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2);
|
||||||
|
int add_conn_range(struct fpga_model* model, add_conn_f add_conn_func, int y1, int x1, const char* name1, int start1, int last1, int y2, int x2, const char* name2, int start2);
|
||||||
|
|
||||||
|
// COUNT_DOWN can be OR'ed to start_count to make
|
||||||
|
// the enumerated wires count from start_count down.
|
||||||
|
#define COUNT_DOWN 0x100
|
||||||
|
#define COUNT_MASK 0xFF
|
||||||
|
|
||||||
|
struct w_point // wire point
|
||||||
|
{
|
||||||
|
const char* name;
|
||||||
|
int start_count; // if there is a %i in the name, this is the start number
|
||||||
|
int y, x;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NO_INCREMENT 0
|
||||||
|
|
||||||
|
struct w_net
|
||||||
|
{
|
||||||
|
// if !last_inc, no incrementing will happen (NO_INCREMENT)
|
||||||
|
// if last_inc > 0, incrementing will happen to
|
||||||
|
// the %i in the name from 0:last_inc, for a total
|
||||||
|
// of last_inc+1 wires.
|
||||||
|
int last_inc;
|
||||||
|
struct w_point pts[40];
|
||||||
|
};
|
||||||
|
|
||||||
|
int add_conn_net(struct fpga_model* model, add_conn_f add_conn_func, struct w_net* net);
|
||||||
|
|
||||||
|
int add_switch(struct fpga_model* model, int y, int x, const char* from,
|
||||||
|
const char* to, int is_bidirectional);
|
||||||
|
|
||||||
|
struct seed_data
|
||||||
|
{
|
||||||
|
int x_flags;
|
||||||
|
const char* str;
|
||||||
|
};
|
||||||
|
|
||||||
|
void seed_strx(struct fpga_model* model, struct seed_data* data);
|
||||||
|
|
||||||
|
// The LWF flags are OR'ed into the logic_wire enum
|
||||||
|
#define LWF_SOUTH0 0x0100
|
||||||
|
#define LWF_NORTH3 0x0200
|
||||||
|
#define LWF_BIDIR 0x0400
|
||||||
|
#define LWF_FAN_B 0x0800
|
||||||
|
#define LWF_WIRE_MASK 0x00FF // namespace for the enums
|
||||||
|
|
||||||
|
enum logicin_wire {
|
||||||
|
/* 0 */ X_A1 = 0,
|
||||||
|
X_A2, X_A3, X_A4, X_A5, X_A6, X_AX,
|
||||||
|
/* 7 */ X_B1, X_B2, X_B3, X_B4, X_B5, X_B6, X_BX,
|
||||||
|
/* 14 */ X_C1, X_C2, X_C3, X_C4, X_C5, X_C6, X_CE, X_CX,
|
||||||
|
/* 22 */ X_D1, X_D2, X_D3, X_D4, X_D5, X_D6, X_DX,
|
||||||
|
/* 29 */ M_A1, M_A2, M_A3, M_A4, M_A5, M_A6, M_AX, M_AI,
|
||||||
|
/* 37 */ M_B1, M_B2, M_B3, M_B4, M_B5, M_B6, M_BX, M_BI,
|
||||||
|
/* 45 */ M_C1, M_C2, M_C3, M_C4, M_C5, M_C6, M_CE, M_CX, M_CI,
|
||||||
|
/* 54 */ M_D1, M_D2, M_D3, M_D4, M_D5, M_D6, M_DX, M_DI,
|
||||||
|
/* 62 */ M_WE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum logicout_wire {
|
||||||
|
/* 0 */ X_A = 0,
|
||||||
|
X_AMUX, X_AQ, X_B, X_BMUX, X_BQ,
|
||||||
|
/* 6 */ X_C, X_CMUX, X_CQ, X_D, X_DMUX, X_DQ,
|
||||||
|
/* 12 */ M_A, M_AMUX, M_AQ, M_B, M_BMUX, M_BQ,
|
||||||
|
/* 18 */ M_C, M_CMUX, M_CQ, M_D, M_DMUX, M_DQ
|
||||||
|
};
|
||||||
|
|
||||||
|
// The extra wires must not overlap with logicin_wire or logicout_wire
|
||||||
|
// namespaces so that they can be combined with either of them.
|
||||||
|
enum extra_wires {
|
||||||
|
UNDEF = 100,
|
||||||
|
FAN_B,
|
||||||
|
GFAN0,
|
||||||
|
GFAN1,
|
||||||
|
LOGICIN20,
|
||||||
|
LOGICIN21,
|
||||||
|
LOGICIN44,
|
||||||
|
LOGICIN52,
|
||||||
|
LOGICIN_N21,
|
||||||
|
LOGICIN_N28,
|
||||||
|
LOGICIN_N52,
|
||||||
|
LOGICIN_N60,
|
||||||
|
LOGICIN_S20,
|
||||||
|
LOGICIN_S36,
|
||||||
|
LOGICIN_S44,
|
||||||
|
LOGICIN_S62
|
||||||
|
};
|
||||||
|
|
1834
model_conns.c
Normal file
1834
model_conns.c
Normal file
File diff suppressed because it is too large
Load Diff
273
model_devices.c
Normal file
273
model_devices.c
Normal file
|
@ -0,0 +1,273 @@
|
||||||
|
//
|
||||||
|
// Author: Wolfgang Spraul
|
||||||
|
//
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// For details see the UNLICENSE file at the root of the source tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "model.h"
|
||||||
|
|
||||||
|
int init_devices(struct fpga_model* model)
|
||||||
|
{
|
||||||
|
int x, y, i, j;
|
||||||
|
struct fpga_tile* tile;
|
||||||
|
|
||||||
|
// DCM, PLL_ADV
|
||||||
|
for (i = 0; i < model->cfg_rows; i++) {
|
||||||
|
y = TOP_IO_TILES + HALF_ROW + i*ROW_SIZE;
|
||||||
|
if (y > model->center_y) y++; // central regs
|
||||||
|
tile = YX_TILE(model, y-1, model->center_x-CENTER_CMTPLL_O);
|
||||||
|
if (i%2) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_DCM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_DCM;
|
||||||
|
} else
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_PLL_ADV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BSCAN
|
||||||
|
tile = YX_TILE(model, TOP_IO_TILES, model->x_width-RIGHT_IO_DEVS_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BSCAN;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BSCAN;
|
||||||
|
|
||||||
|
// BSCAN, OCT_CALIBRATE
|
||||||
|
tile = YX_TILE(model, TOP_IO_TILES+1, model->x_width-RIGHT_IO_DEVS_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BSCAN;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BSCAN;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OCT_CALIBRATE;
|
||||||
|
|
||||||
|
// ICAP, SPI_ACCESS, OCT_CALIBRATE
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_IO_TILES-1,
|
||||||
|
model->x_width-RIGHT_IO_DEVS_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_ICAP;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_SPI_ACCESS;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OCT_CALIBRATE;
|
||||||
|
|
||||||
|
// STARTUP, POST_CRC_INTERNAL, SLAVE_SPI, SUSPEND_SYNC
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_IO_TILES-2,
|
||||||
|
model->x_width-RIGHT_IO_DEVS_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_STARTUP;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_POST_CRC_INTERNAL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_SLAVE_SPI;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_SUSPEND_SYNC;
|
||||||
|
|
||||||
|
// BUFGMUX
|
||||||
|
tile = YX_TILE(model, model->center_y, model->center_x);
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFGMUX;
|
||||||
|
|
||||||
|
// BUFIO, BUFIO_FB, BUFPLL, BUFPLL_MCB
|
||||||
|
tile = YX_TILE(model, TOP_OUTER_ROW, model->center_x-CENTER_CMTPLL_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL_MCB;
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO_FB;
|
||||||
|
}
|
||||||
|
tile = YX_TILE(model, model->center_y, LEFT_OUTER_COL);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL_MCB;
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO_FB;
|
||||||
|
}
|
||||||
|
tile = YX_TILE(model, model->center_y, model->x_width - RIGHT_OUTER_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL_MCB;
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO_FB;
|
||||||
|
}
|
||||||
|
tile = YX_TILE(model, model->y_height - BOT_OUTER_ROW, model->center_x-CENTER_CMTPLL_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFPLL_MCB;
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFIO_FB;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BUFH
|
||||||
|
for (i = 0; i < model->cfg_rows; i++) {
|
||||||
|
y = TOP_IO_TILES + HALF_ROW + i*ROW_SIZE;
|
||||||
|
if (y > model->center_y) y++; // central regs
|
||||||
|
tile = YX_TILE(model, y, model->center_x);
|
||||||
|
for (j = 0; j < 32; j++)
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BUFH;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BRAM
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_FABRIC_BRAM_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
if (tile->flags & TF_BRAM_DEV) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BRAM16;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BRAM8;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_BRAM8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MACC
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_FABRIC_MACC_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
if (tile->flags & TF_MACC_DEV)
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_MACC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ILOGIC/OLOGIC/IODELAY
|
||||||
|
for (x = LEFT_SIDE_WIDTH; x < model->x_width - RIGHT_SIDE_WIDTH; x++) {
|
||||||
|
if (is_atx(X_LOGIC_COL, model, x)
|
||||||
|
&& !is_atx(X_ROUTING_NO_IO, model, x-1)) {
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
tile = YX_TILE(model, TOP_IO_TILES+i, x);
|
||||||
|
for (j = 0; j <= 1; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_ILOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OLOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IODELAY;
|
||||||
|
}
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_IO_TILES-i-1, x);
|
||||||
|
for (j = 0; j <= 1; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_ILOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OLOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IODELAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_LEFT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, LEFT_IO_DEVS);
|
||||||
|
for (j = 0; j <= 1; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_ILOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OLOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IODELAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_aty(Y_RIGHT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, model->x_width-RIGHT_IO_DEVS_O);
|
||||||
|
for (j = 0; j <= 1; j++) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_ILOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_OLOGIC;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IODELAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IOB
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_OUTER_LEFT, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_LEFT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_OUTER_RIGHT, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_RIGHT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_FABRIC_LOGIC_ROUTING_COL|X_CENTER_ROUTING_COL, model, x)
|
||||||
|
&& !is_atx(X_ROUTING_NO_IO, model, x)) {
|
||||||
|
tile = YX_TILE(model, TOP_OUTER_ROW, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_OUTER_ROW, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBM;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_IOBS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TIEOFF
|
||||||
|
tile = YX_TILE(model, model->center_y, LEFT_OUTER_COL);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
tile = YX_TILE(model, model->center_y, model->x_width-RIGHT_OUTER_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
tile = YX_TILE(model, TOP_OUTER_ROW, model->center_x-1);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_OUTER_ROW, model->center_x-CENTER_CMTPLL_O);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_LEFT_IO_DEVS_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_LEFT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_RIGHT_IO_DEVS_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_RIGHT_WIRED, model, y)) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_CENTER_CMTPLL_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
if (tile->flags & TF_PLL_DEV)
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_ROUTING_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_ROW_HORIZ_AXSYMM|Y_CHIP_HORIZ_REGS,
|
||||||
|
model, y))
|
||||||
|
continue;
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_LOGIC_COL, model, x)
|
||||||
|
&& !is_atx(X_ROUTING_NO_IO, model, x-1)) {
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
tile = YX_TILE(model, TOP_IO_TILES+i, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
tile = YX_TILE(model, model->y_height-BOT_IO_TILES-i-1, x);
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_TIEOFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// LOGIC
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_LOGIC_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
if (tile->flags & TF_LOGIC_XM_DEV) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_LOGIC_X;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_LOGIC_M;
|
||||||
|
}
|
||||||
|
if (tile->flags & TF_LOGIC_XL_DEV) {
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_LOGIC_X;
|
||||||
|
tile->devices[tile->num_devices++].type = DEV_LOGIC_L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
574
model_helper.c
Normal file
574
model_helper.c
Normal file
|
@ -0,0 +1,574 @@
|
||||||
|
//
|
||||||
|
// Author: Wolfgang Spraul
|
||||||
|
//
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// For details see the UNLICENSE file at the root of the source tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "model.h"
|
||||||
|
|
||||||
|
#define NUM_PF_BUFS 16
|
||||||
|
|
||||||
|
const char* pf(const char* fmt, ...)
|
||||||
|
{
|
||||||
|
// safe to call it NUM_PF_BUFStimes in 1 expression,
|
||||||
|
// such as function params or a net structure
|
||||||
|
static char pf_buf[NUM_PF_BUFS][128];
|
||||||
|
static int last_buf = 0;
|
||||||
|
va_list list;
|
||||||
|
last_buf = (last_buf+1)%NUM_PF_BUFS;
|
||||||
|
pf_buf[last_buf][0] = 0;
|
||||||
|
va_start(list, fmt);
|
||||||
|
vsnprintf(pf_buf[last_buf], sizeof(pf_buf[0]), fmt, list);
|
||||||
|
va_end(list);
|
||||||
|
return pf_buf[last_buf];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* wpref(struct fpga_model* model, int y, int x, const char* wire_name)
|
||||||
|
{
|
||||||
|
static char buf[8][128];
|
||||||
|
static int last_buf = 0;
|
||||||
|
char* prefix;
|
||||||
|
|
||||||
|
if (is_aty(Y_CHIP_HORIZ_REGS, model, y)) {
|
||||||
|
prefix = is_atx(X_CENTER_REGS_COL, model, x+3)
|
||||||
|
? "REGC_INT_" : "REGH_";
|
||||||
|
} else if (is_aty(Y_ROW_HORIZ_AXSYMM, model, y))
|
||||||
|
prefix = "HCLK_";
|
||||||
|
else if (is_aty(Y_INNER_TOP, model, y))
|
||||||
|
prefix = "IOI_TTERM_";
|
||||||
|
else if (is_aty(Y_INNER_BOTTOM, model, y))
|
||||||
|
prefix = "IOI_BTERM_";
|
||||||
|
else
|
||||||
|
prefix = "";
|
||||||
|
|
||||||
|
last_buf = (last_buf+1)%8;
|
||||||
|
buf[last_buf][0] = 0;
|
||||||
|
strcpy(buf[last_buf], prefix);
|
||||||
|
strcat(buf[last_buf], wire_name);
|
||||||
|
return buf[last_buf];
|
||||||
|
}
|
||||||
|
|
||||||
|
int has_connpt(struct fpga_model* model, int y, int x,
|
||||||
|
const char* name)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile;
|
||||||
|
uint16_t name_i;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (strarray_find(&model->str, name, &i))
|
||||||
|
ABORT(1);
|
||||||
|
if (i == STRIDX_NO_ENTRY)
|
||||||
|
return 0;
|
||||||
|
name_i = i;
|
||||||
|
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == name_i)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _add_connpt_name(struct fpga_model* model, int y, int x,
|
||||||
|
const char* connpt_name, int warn_if_duplicate, uint16_t* name_i,
|
||||||
|
int* conn_point_o);
|
||||||
|
|
||||||
|
int add_connpt_name(struct fpga_model* model, int y, int x,
|
||||||
|
const char* connpt_name)
|
||||||
|
{
|
||||||
|
return _add_connpt_name(model, y, x, connpt_name,
|
||||||
|
1 /* warn_if_duplicate */,
|
||||||
|
0 /* name_i */, 0 /* conn_point_o */);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CONN_NAMES_INCREMENT 128
|
||||||
|
|
||||||
|
static int _add_connpt_name(struct fpga_model* model, int y, int x,
|
||||||
|
const char* connpt_name, int warn_if_duplicate, uint16_t* name_i,
|
||||||
|
int* conn_point_o)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile;
|
||||||
|
uint16_t _name_i;
|
||||||
|
int rc, i;
|
||||||
|
|
||||||
|
tile = &model->tiles[y * model->x_width + x];
|
||||||
|
rc = strarray_add(&model->str, connpt_name, &i);
|
||||||
|
if (rc) return rc;
|
||||||
|
if (i > 0xFFFF) {
|
||||||
|
fprintf(stderr, "Internal error in %s:%i\n", __FILE__, __LINE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_name_i = i;
|
||||||
|
if (name_i) *name_i = i;
|
||||||
|
|
||||||
|
// Search for an existing connection point under name.
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == _name_i)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (conn_point_o) *conn_point_o = i;
|
||||||
|
if (i < tile->num_conn_point_names) {
|
||||||
|
if (warn_if_duplicate)
|
||||||
|
fprintf(stderr,
|
||||||
|
"Duplicate connection point name y%02i x%02u %s\n",
|
||||||
|
y, x, connpt_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// This is the first connection under name, add name.
|
||||||
|
if (!(tile->num_conn_point_names % CONN_NAMES_INCREMENT)) {
|
||||||
|
uint16_t* new_ptr = realloc(tile->conn_point_names,
|
||||||
|
(tile->num_conn_point_names+CONN_NAMES_INCREMENT)*2*sizeof(uint16_t));
|
||||||
|
if (!new_ptr) {
|
||||||
|
fprintf(stderr, "Out of memory %s:%i\n", __FILE__, __LINE__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
tile->conn_point_names = new_ptr;
|
||||||
|
}
|
||||||
|
tile->conn_point_names[tile->num_conn_point_names*2] = tile->num_conn_point_dests;
|
||||||
|
tile->conn_point_names[tile->num_conn_point_names*2+1] = _name_i;
|
||||||
|
tile->num_conn_point_names++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int has_device(struct fpga_model* model, int y, int x, int dev)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile = YX_TILE(model, y, x);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < tile->num_devices; i++) {
|
||||||
|
if (tile->devices[i].type == dev)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_connpt_2(struct fpga_model* model, int y, int x,
|
||||||
|
const char* connpt_name, const char* suffix1, const char* suffix2)
|
||||||
|
{
|
||||||
|
char name_buf[64];
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
snprintf(name_buf, sizeof(name_buf), "%s%s", connpt_name, suffix1);
|
||||||
|
rc = add_connpt_name(model, y, x, name_buf);
|
||||||
|
if (rc) goto xout;
|
||||||
|
snprintf(name_buf, sizeof(name_buf), "%s%s", connpt_name, suffix2);
|
||||||
|
rc = add_connpt_name(model, y, x, name_buf);
|
||||||
|
if (rc) goto xout;
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CONNS_INCREMENT 128
|
||||||
|
#undef DBG_ADD_CONN_UNI
|
||||||
|
|
||||||
|
int add_conn_uni(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile;
|
||||||
|
uint16_t name1_i, name2_i;
|
||||||
|
uint16_t* new_ptr;
|
||||||
|
int conn_start, num_conn_point_dests_for_this_wire, rc, j, conn_point_o;
|
||||||
|
|
||||||
|
rc = _add_connpt_name(model, y1, x1, name1, 0 /* warn_if_duplicate */,
|
||||||
|
&name1_i, &conn_point_o);
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
rc = strarray_add(&model->str, name2, &j);
|
||||||
|
if (rc) return rc;
|
||||||
|
if (j > 0xFFFF) {
|
||||||
|
fprintf(stderr, "Internal error in %s:%i\n", __FILE__, __LINE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
name2_i = j;
|
||||||
|
tile = &model->tiles[y1 * model->x_width + x1];
|
||||||
|
conn_start = tile->conn_point_names[conn_point_o*2];
|
||||||
|
if (conn_point_o+1 >= tile->num_conn_point_names)
|
||||||
|
num_conn_point_dests_for_this_wire = tile->num_conn_point_dests - conn_start;
|
||||||
|
else
|
||||||
|
num_conn_point_dests_for_this_wire = tile->conn_point_names[(conn_point_o+1)*2] - conn_start;
|
||||||
|
|
||||||
|
// Is the connection made a second time?
|
||||||
|
for (j = conn_start; j < conn_start + num_conn_point_dests_for_this_wire; j++) {
|
||||||
|
if (tile->conn_point_dests[j*3] == x2
|
||||||
|
&& tile->conn_point_dests[j*3+1] == y2
|
||||||
|
&& tile->conn_point_dests[j*3+2] == name2_i) {
|
||||||
|
fprintf(stderr, "Duplicate conn (num_conn_point_dests %i): y%02i x%02i %s - y%02i x%02i %s.\n",
|
||||||
|
num_conn_point_dests_for_this_wire, y1, x1, name1, y2, x2, name2);
|
||||||
|
for (j = conn_start; j < conn_start + num_conn_point_dests_for_this_wire; j++) {
|
||||||
|
fprintf(stderr, "c%i: y%02i x%02i %s -> y%02i x%02i %s\n", j,
|
||||||
|
y1, x1, name1,
|
||||||
|
tile->conn_point_dests[j*3+1], tile->conn_point_dests[j*3],
|
||||||
|
strarray_lookup(&model->str, tile->conn_point_dests[j*3+2]));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(tile->num_conn_point_dests % CONNS_INCREMENT)) {
|
||||||
|
new_ptr = realloc(tile->conn_point_dests, (tile->num_conn_point_dests+CONNS_INCREMENT)*3*sizeof(uint16_t));
|
||||||
|
if (!new_ptr) {
|
||||||
|
fprintf(stderr, "Out of memory %s:%i\n", __FILE__, __LINE__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
tile->conn_point_dests = new_ptr;
|
||||||
|
}
|
||||||
|
if (tile->num_conn_point_dests > j)
|
||||||
|
memmove(&tile->conn_point_dests[(j+1)*3], &tile->conn_point_dests[j*3], (tile->num_conn_point_dests-j)*3*sizeof(uint16_t));
|
||||||
|
tile->conn_point_dests[j*3] = x2;
|
||||||
|
tile->conn_point_dests[j*3+1] = y2;
|
||||||
|
tile->conn_point_dests[j*3+2] = name2_i;
|
||||||
|
tile->num_conn_point_dests++;
|
||||||
|
while (conn_point_o+1 < tile->num_conn_point_names) {
|
||||||
|
tile->conn_point_names[(conn_point_o+1)*2]++;
|
||||||
|
conn_point_o++;
|
||||||
|
}
|
||||||
|
#if DBG_ADD_CONN_UNI
|
||||||
|
printf("conn_point_dests for y%02i x%02i %s now:\n", y1, x1, name1);
|
||||||
|
for (j = conn_start; j < conn_start + num_conn_point_dests_for_this_wire+1; j++) {
|
||||||
|
fprintf(stderr, "c%i: y%02i x%02i %s -> y%02i x%02i %s\n", j, y1, x1, name1,
|
||||||
|
tile->conn_point_dests[j*3+1], tile->conn_point_dests[j*3],
|
||||||
|
strarray_lookup(&model->str, tile->conn_point_dests[j*3+2]));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_conn_uni_pref(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2)
|
||||||
|
{
|
||||||
|
return add_conn_uni(model,
|
||||||
|
y1, x1, wpref(model, y1, x1, name1),
|
||||||
|
y2, x2, wpref(model, y2, x2, name2));
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_conn_bi(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2)
|
||||||
|
{
|
||||||
|
int rc = add_conn_uni(model, y1, x1, name1, y2, x2, name2);
|
||||||
|
if (rc) return rc;
|
||||||
|
return add_conn_uni(model, y2, x2, name2, y1, x1, name1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_conn_bi_pref(struct fpga_model* model, int y1, int x1, const char* name1, int y2, int x2, const char* name2)
|
||||||
|
{
|
||||||
|
return add_conn_bi(model,
|
||||||
|
y1, x1, wpref(model, y1, x1, name1),
|
||||||
|
y2, x2, wpref(model, y2, x2, name2));
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_conn_range(struct fpga_model* model, add_conn_f add_conn_func, int y1, int x1, const char* name1, int start1, int last1, int y2, int x2, const char* name2, int start2)
|
||||||
|
{
|
||||||
|
char buf1[128], buf2[128];
|
||||||
|
int rc, i;
|
||||||
|
|
||||||
|
if (last1 <= start1)
|
||||||
|
return (*add_conn_func)(model, y1, x1, name1, y2, x2, name2);
|
||||||
|
for (i = start1; i <= last1; i++) {
|
||||||
|
snprintf(buf1, sizeof(buf1), name1, i);
|
||||||
|
if (start2 & COUNT_DOWN)
|
||||||
|
snprintf(buf2, sizeof(buf2), name2, (start2 & COUNT_MASK)-(i-start1));
|
||||||
|
else
|
||||||
|
snprintf(buf2, sizeof(buf2), name2, (start2 & COUNT_MASK)+(i-start1));
|
||||||
|
rc = (*add_conn_func)(model, y1, x1, buf1, y2, x2, buf2);
|
||||||
|
if (rc) return rc;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_conn_net(struct fpga_model* model, add_conn_f add_conn_func, struct w_net* net)
|
||||||
|
{
|
||||||
|
int i, j, rc;
|
||||||
|
|
||||||
|
for (i = 0; net->pts[i].name[0] && i < sizeof(net->pts)/sizeof(net->pts[0]); i++) {
|
||||||
|
for (j = i+1; net->pts[j].name[0] && j < sizeof(net->pts)/sizeof(net->pts[0]); j++) {
|
||||||
|
rc = add_conn_range(model, add_conn_func,
|
||||||
|
net->pts[i].y, net->pts[i].x,
|
||||||
|
net->pts[i].name,
|
||||||
|
net->pts[i].start_count,
|
||||||
|
net->pts[i].start_count + net->last_inc,
|
||||||
|
net->pts[j].y, net->pts[j].x,
|
||||||
|
net->pts[j].name,
|
||||||
|
net->pts[j].start_count);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SWITCH_ALLOC_INCREMENT 64
|
||||||
|
|
||||||
|
#define DBG_ALLOW_ADDPOINTS
|
||||||
|
|
||||||
|
int add_switch(struct fpga_model* model, int y, int x, const char* from,
|
||||||
|
const char* to, int is_bidirectional)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile = YX_TILE(model, y, x);
|
||||||
|
int rc, i, from_idx, to_idx, from_connpt_o, to_connpt_o;
|
||||||
|
uint32_t new_switch;
|
||||||
|
|
||||||
|
// later this can be strarray_find() and not strarray_add(), but
|
||||||
|
// then we need all wires and ports to be present first...
|
||||||
|
#ifdef DBG_ALLOW_ADDPOINTS
|
||||||
|
rc = strarray_add(&model->str, from, &from_idx);
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = strarray_add(&model->str, to, &to_idx);
|
||||||
|
if (rc) goto xout;
|
||||||
|
#else
|
||||||
|
rc = strarray_find(&model->str, from, &from_idx);
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = strarray_find(&model->str, to, &to_idx);
|
||||||
|
if (rc) goto xout;
|
||||||
|
#endif
|
||||||
|
if (from_idx == STRIDX_NO_ENTRY || to_idx == STRIDX_NO_ENTRY) {
|
||||||
|
fprintf(stderr, "No string for switch from %s (%i) or %s (%i).\n",
|
||||||
|
from, from_idx, to, to_idx);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
from_connpt_o = -1;
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == from_idx) {
|
||||||
|
from_connpt_o = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DBG_ALLOW_ADDPOINTS
|
||||||
|
if (from_connpt_o == -1) {
|
||||||
|
rc = add_connpt_name(model, y, x, from);
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == from_idx) {
|
||||||
|
from_connpt_o = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
to_connpt_o = -1;
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == to_idx) {
|
||||||
|
to_connpt_o = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DBG_ALLOW_ADDPOINTS
|
||||||
|
if (to_connpt_o == -1) {
|
||||||
|
rc = add_connpt_name(model, y, x, to);
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 0; i < tile->num_conn_point_names; i++) {
|
||||||
|
if (tile->conn_point_names[i*2+1] == to_idx) {
|
||||||
|
to_connpt_o = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (from_connpt_o == -1 || to_connpt_o == -1) {
|
||||||
|
fprintf(stderr, "No conn point for switch from %s (%i/%i) or %s (%i/%i).\n",
|
||||||
|
from, from_idx, from_connpt_o, to, to_idx, to_connpt_o);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (from_connpt_o > SWITCH_MAX_CONNPT_O
|
||||||
|
|| to_connpt_o > SWITCH_MAX_CONNPT_O) {
|
||||||
|
fprintf(stderr, "Internal error in %s:%i (from_o %i to_o %i)\n",
|
||||||
|
__FILE__, __LINE__, from_connpt_o, to_connpt_o);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
new_switch = (from_connpt_o << 15) | to_connpt_o;
|
||||||
|
if (is_bidirectional)
|
||||||
|
new_switch |= SWITCH_BIDIRECTIONAL;
|
||||||
|
|
||||||
|
for (i = 0; i < tile->num_switches; i++) {
|
||||||
|
if ((tile->switches[i] & 0x3FFFFFFF) == (new_switch & 0x3FFFFFFF)) {
|
||||||
|
fprintf(stderr, "Internal error in %s:%i duplicate switch from %s to %s\n",
|
||||||
|
__FILE__, __LINE__, from, to);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(tile->num_switches % SWITCH_ALLOC_INCREMENT)) {
|
||||||
|
uint32_t* new_ptr = realloc(tile->switches,
|
||||||
|
(tile->num_switches+SWITCH_ALLOC_INCREMENT)*sizeof(*tile->switches));
|
||||||
|
if (!new_ptr) {
|
||||||
|
fprintf(stderr, "Out of memory %s:%i\n", __FILE__, __LINE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tile->switches = new_ptr;
|
||||||
|
}
|
||||||
|
tile->switches[tile->num_switches++] = new_switch;
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void seed_strx(struct fpga_model* model, struct seed_data* data)
|
||||||
|
{
|
||||||
|
int x, i;
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
model->tmp_str[x] = 0;
|
||||||
|
for (i = 0; data[i].x_flags; i++) {
|
||||||
|
if (is_atx(data[i].x_flags, model, x))
|
||||||
|
model->tmp_str[x] = data[i].str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char next_non_whitespace(const char* s)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; s[i] == ' '; i++);
|
||||||
|
return s[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
char last_major(const char* str, int cur_o)
|
||||||
|
{
|
||||||
|
for (; cur_o; cur_o--) {
|
||||||
|
if (str[cur_o-1] >= 'A' && str[cur_o-1] <= 'Z')
|
||||||
|
return str[cur_o-1];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_aty(int check, struct fpga_model* model, int y)
|
||||||
|
{
|
||||||
|
if (y < 0) return 0;
|
||||||
|
if (check & Y_INNER_TOP && y == TOP_INNER_ROW) return 1;
|
||||||
|
if (check & Y_INNER_BOTTOM && y == model->y_height-BOT_INNER_ROW) return 1;
|
||||||
|
if (check & Y_CHIP_HORIZ_REGS && y == model->center_y) return 1;
|
||||||
|
if (check & (Y_ROW_HORIZ_AXSYMM|Y_BOTTOM_OF_ROW)) {
|
||||||
|
int row_pos;
|
||||||
|
is_in_row(model, y, 0 /* row_num */, &row_pos);
|
||||||
|
if (check & Y_ROW_HORIZ_AXSYMM && row_pos == 8) return 1;
|
||||||
|
if (check & Y_BOTTOM_OF_ROW && row_pos == 16) return 1;
|
||||||
|
}
|
||||||
|
if (check & Y_LEFT_WIRED && model->tiles[y*model->x_width].flags & TF_WIRED) return 1;
|
||||||
|
if (check & Y_RIGHT_WIRED && model->tiles[y*model->x_width + model->x_width-RIGHT_OUTER_O].flags & TF_WIRED) return 1;
|
||||||
|
if (check & Y_TOPBOT_IO_RANGE
|
||||||
|
&& ((y > TOP_INNER_ROW && y <= TOP_INNER_ROW + TOP_IO_TILES)
|
||||||
|
|| (y >= model->y_height - BOT_INNER_ROW - BOT_IO_TILES && y < model->y_height - BOT_INNER_ROW))) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_atx(int check, struct fpga_model* model, int x)
|
||||||
|
{
|
||||||
|
if (x < 0) return 0;
|
||||||
|
if (check & X_OUTER_LEFT && !x) return 1;
|
||||||
|
if (check & X_INNER_LEFT && x == 1) return 1;
|
||||||
|
if (check & X_INNER_RIGHT && x == model->x_width-2) return 1;
|
||||||
|
if (check & X_OUTER_RIGHT && x == model->x_width-1) return 1;
|
||||||
|
if (check & X_ROUTING_COL
|
||||||
|
&& (model->tiles[x].flags & TF_FABRIC_ROUTING_COL
|
||||||
|
|| x == LEFT_IO_ROUTING || x == model->x_width-5
|
||||||
|
|| x == model->center_x-3)) return 1;
|
||||||
|
if (model->tiles[x].flags & TF_FABRIC_ROUTING_COL) {
|
||||||
|
if (check & X_ROUTING_TO_BRAM_COL
|
||||||
|
&& model->tiles[x+1].flags & TF_FABRIC_BRAM_VIA_COL
|
||||||
|
&& model->tiles[x+2].flags & TF_FABRIC_BRAM_COL) return 1;
|
||||||
|
if (check & X_ROUTING_TO_MACC_COL
|
||||||
|
&& model->tiles[x+1].flags & TF_FABRIC_MACC_VIA_COL
|
||||||
|
&& model->tiles[x+2].flags & TF_FABRIC_MACC_COL) return 1;
|
||||||
|
}
|
||||||
|
if (check & X_ROUTING_NO_IO && model->tiles[x].flags & TF_ROUTING_NO_IO) return 1;
|
||||||
|
if (check & X_LOGIC_COL
|
||||||
|
&& (model->tiles[x].flags & TF_FABRIC_LOGIC_COL
|
||||||
|
|| x == model->center_x-2)) return 1;
|
||||||
|
if (check & X_FABRIC_ROUTING_COL && model->tiles[x].flags & TF_FABRIC_ROUTING_COL) return 1;
|
||||||
|
// todo: the routing/no_io flags could be cleaned up
|
||||||
|
if (check & X_FABRIC_LOGIC_ROUTING_COL
|
||||||
|
&& model->tiles[x].flags & TF_FABRIC_ROUTING_COL
|
||||||
|
&& model->tiles[x+1].flags & TF_FABRIC_LOGIC_COL) return 1;
|
||||||
|
if (check & X_FABRIC_LOGIC_COL && model->tiles[x].flags & TF_FABRIC_LOGIC_COL) return 1;
|
||||||
|
if (check & X_FABRIC_BRAM_ROUTING_COL
|
||||||
|
&& model->tiles[x].flags & TF_FABRIC_ROUTING_COL
|
||||||
|
&& model->tiles[x+1].flags & TF_FABRIC_BRAM_VIA_COL
|
||||||
|
&& model->tiles[x+2].flags & TF_FABRIC_BRAM_COL) return 1;
|
||||||
|
if (check & X_FABRIC_MACC_ROUTING_COL
|
||||||
|
&& model->tiles[x].flags & TF_FABRIC_ROUTING_COL
|
||||||
|
&& model->tiles[x+1].flags & TF_FABRIC_MACC_VIA_COL
|
||||||
|
&& model->tiles[x+2].flags & TF_FABRIC_MACC_COL) return 1;
|
||||||
|
if (check & X_FABRIC_BRAM_VIA_COL && model->tiles[x].flags & TF_FABRIC_BRAM_VIA_COL) return 1;
|
||||||
|
if (check & X_FABRIC_MACC_VIA_COL && model->tiles[x].flags & TF_FABRIC_MACC_VIA_COL) return 1;
|
||||||
|
if (check & X_FABRIC_BRAM_COL && model->tiles[x].flags & TF_FABRIC_BRAM_COL) return 1;
|
||||||
|
if (check & X_FABRIC_MACC_COL && model->tiles[x].flags & TF_FABRIC_MACC_COL) return 1;
|
||||||
|
if (check & X_CENTER_ROUTING_COL && x == model->center_x-3) return 1;
|
||||||
|
if (check & X_CENTER_LOGIC_COL && x == model->center_x-2) return 1;
|
||||||
|
if (check & X_CENTER_CMTPLL_COL && x == model->center_x-1) return 1;
|
||||||
|
if (check & X_CENTER_REGS_COL && x == model->center_x) return 1;
|
||||||
|
if (check & X_LEFT_IO_ROUTING_COL && x == LEFT_IO_ROUTING) return 1;
|
||||||
|
if (check & X_LEFT_IO_DEVS_COL && x == LEFT_IO_DEVS) return 1;
|
||||||
|
if (check & X_RIGHT_IO_ROUTING_COL
|
||||||
|
&& x == model->x_width-RIGHT_IO_ROUTING_O) return 1;
|
||||||
|
if (check & X_RIGHT_IO_DEVS_COL
|
||||||
|
&& x == model->x_width-RIGHT_IO_DEVS_O) return 1;
|
||||||
|
if (check & X_LEFT_SIDE && x < model->center_x) return 1;
|
||||||
|
if (check & X_LEFT_MCB && x == LEFT_MCB_COL) return 1;
|
||||||
|
if (check & X_RIGHT_MCB && x == model->x_width-RIGHT_MCB_O) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_atyx(int check, struct fpga_model* model, int y, int x)
|
||||||
|
{
|
||||||
|
struct fpga_tile* tile;
|
||||||
|
|
||||||
|
if (y < 0 || x < 0) return 0;
|
||||||
|
if (check & YX_ROUTING_TILE
|
||||||
|
&& (model->tiles[x].flags & TF_FABRIC_ROUTING_COL
|
||||||
|
|| x == LEFT_IO_ROUTING || x == model->x_width-5
|
||||||
|
|| x == model->center_x-3)) {
|
||||||
|
int row_pos;
|
||||||
|
is_in_row(model, y, 0 /* row_num */, &row_pos);
|
||||||
|
if (row_pos >= 0 && row_pos != 8) return 1;
|
||||||
|
}
|
||||||
|
tile = YX_TILE(model, y, x);
|
||||||
|
if (check & YX_IO_ROUTING
|
||||||
|
&& (tile->type == IO_ROUTING || tile->type == ROUTING_IO_L)) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void is_in_row(const struct fpga_model* model, int y,
|
||||||
|
int* row_num, int* row_pos)
|
||||||
|
{
|
||||||
|
int dist_to_center;
|
||||||
|
|
||||||
|
if (row_num) *row_num = -1;
|
||||||
|
if (row_pos) *row_pos = -1;
|
||||||
|
if (y < 2) return;
|
||||||
|
// normalize y to beginning of rows
|
||||||
|
y -= 2;
|
||||||
|
|
||||||
|
// calculate distance to center and check
|
||||||
|
// that y is not pointing to the center
|
||||||
|
dist_to_center = (model->cfg_rows/2)*(8+1/*middle of row*/+8);
|
||||||
|
if (y == dist_to_center) return;
|
||||||
|
if (y > dist_to_center) y--;
|
||||||
|
|
||||||
|
// check that y is not pointing past the last row
|
||||||
|
if (y >= model->cfg_rows*(8+1+8)) return;
|
||||||
|
|
||||||
|
if (row_num) *row_num = model->cfg_rows-(y/(8+1+8))-1;
|
||||||
|
if (row_pos) *row_pos = y%(8+1+8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int row_num(int y, struct fpga_model* model)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
is_in_row(model, y, &result, 0 /* row_pos */);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int row_pos(int y, struct fpga_model* model)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
is_in_row(model, y, 0 /* row_num */, &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* logicin_s(int wire, int routing_io)
|
||||||
|
{
|
||||||
|
if (routing_io && ((wire & LWF_WIRE_MASK) == X_A5 || (wire & LWF_WIRE_MASK) == X_B4))
|
||||||
|
return pf("INT_IOI_LOGICIN_B%i", wire & LWF_WIRE_MASK);
|
||||||
|
return pf("LOGICIN_B%i", wire & LWF_WIRE_MASK);
|
||||||
|
}
|
218
model_main.c
Normal file
218
model_main.c
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
//
|
||||||
|
// Author: Wolfgang Spraul
|
||||||
|
//
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// For details see the UNLICENSE file at the root of the source tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "model.h"
|
||||||
|
|
||||||
|
int fpga_build_model(struct fpga_model* model, int fpga_rows, const char* columns,
|
||||||
|
const char* left_wiring, const char* right_wiring)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
memset(model, 0, sizeof(*model));
|
||||||
|
model->cfg_rows = fpga_rows;
|
||||||
|
strncpy(model->cfg_columns, columns, sizeof(model->cfg_columns)-1);
|
||||||
|
strncpy(model->cfg_left_wiring, left_wiring,
|
||||||
|
sizeof(model->cfg_left_wiring)-1);
|
||||||
|
strncpy(model->cfg_right_wiring, right_wiring,
|
||||||
|
sizeof(model->cfg_right_wiring)-1);
|
||||||
|
strarray_init(&model->str, STRIDX_64K);
|
||||||
|
|
||||||
|
// The order of tiles, then devices, then ports, then
|
||||||
|
// connections and finally switches is important so
|
||||||
|
// that the codes can build upon each other.
|
||||||
|
|
||||||
|
rc = init_tiles(model);
|
||||||
|
if (rc) return rc;
|
||||||
|
|
||||||
|
rc = init_devices(model);
|
||||||
|
if (rc) return rc;
|
||||||
|
|
||||||
|
rc = init_ports(model);
|
||||||
|
if (rc) return rc;
|
||||||
|
|
||||||
|
rc = init_conns(model);
|
||||||
|
if (rc) return rc;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
rc = init_switches(model);
|
||||||
|
if (rc) return rc;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fpga_free_model(struct fpga_model* model)
|
||||||
|
{
|
||||||
|
if (!model) return;
|
||||||
|
free(model->tmp_str);
|
||||||
|
strarray_free(&model->str);
|
||||||
|
free(model->tiles);
|
||||||
|
memset(model, 0, sizeof(*model));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* fpga_ttstr[] = // tile type strings
|
||||||
|
{
|
||||||
|
[NA] = "NA",
|
||||||
|
[ROUTING] = "ROUTING",
|
||||||
|
[ROUTING_BRK] = "ROUTING_BRK",
|
||||||
|
[ROUTING_VIA] = "ROUTING_VIA",
|
||||||
|
[HCLK_ROUTING_XM] = "HCLK_ROUTING_XM",
|
||||||
|
[HCLK_ROUTING_XL] = "HCLK_ROUTING_XL",
|
||||||
|
[HCLK_LOGIC_XM] = "HCLK_LOGIC_XM",
|
||||||
|
[HCLK_LOGIC_XL] = "HCLK_LOGIC_XL",
|
||||||
|
[LOGIC_XM] = "LOGIC_XM",
|
||||||
|
[LOGIC_XL] = "LOGIC_XL",
|
||||||
|
[REGH_ROUTING_XM] = "REGH_ROUTING_XM",
|
||||||
|
[REGH_ROUTING_XL] = "REGH_ROUTING_XL",
|
||||||
|
[REGH_LOGIC_XM] = "REGH_LOGIC_XM",
|
||||||
|
[REGH_LOGIC_XL] = "REGH_LOGIC_XL",
|
||||||
|
[BRAM_ROUTING] = "BRAM_ROUTING",
|
||||||
|
[BRAM_ROUTING_BRK] = "BRAM_ROUTING_BRK",
|
||||||
|
[BRAM] = "BRAM",
|
||||||
|
[BRAM_ROUTING_TERM_T] = "BRAM_ROUTING_TERM_T",
|
||||||
|
[BRAM_ROUTING_TERM_B] = "BRAM_ROUTING_TERM_B",
|
||||||
|
[BRAM_ROUTING_VIA_TERM_T] = "BRAM_ROUTING_VIA_TERM_T",
|
||||||
|
[BRAM_ROUTING_VIA_TERM_B] = "BRAM_ROUTING_VIA_TERM_B",
|
||||||
|
[BRAM_TERM_LT] = "BRAM_TERM_LT",
|
||||||
|
[BRAM_TERM_RT] = "BRAM_TERM_RT",
|
||||||
|
[BRAM_TERM_LB] = "BRAM_TERM_LB",
|
||||||
|
[BRAM_TERM_RB] = "BRAM_TERM_RB",
|
||||||
|
[HCLK_BRAM_ROUTING] = "HCLK_BRAM_ROUTING",
|
||||||
|
[HCLK_BRAM_ROUTING_VIA] = "HCLK_BRAM_ROUTING_VIA",
|
||||||
|
[HCLK_BRAM] = "HCLK_BRAM",
|
||||||
|
[REGH_BRAM_ROUTING] = "REGH_BRAM_ROUTING",
|
||||||
|
[REGH_BRAM_ROUTING_VIA] = "REGH_BRAM_ROUTING_VIA",
|
||||||
|
[REGH_BRAM_L] = "REGH_BRAM_L",
|
||||||
|
[REGH_BRAM_R] = "REGH_BRAM_R",
|
||||||
|
[MACC] = "MACC",
|
||||||
|
[HCLK_MACC_ROUTING] = "HCLK_MACC_ROUTING",
|
||||||
|
[HCLK_MACC_ROUTING_VIA] = "HCLK_MACC_ROUTING_VIA",
|
||||||
|
[HCLK_MACC] = "HCLK_MACC",
|
||||||
|
[REGH_MACC_ROUTING] = "REGH_MACC_ROUTING",
|
||||||
|
[REGH_MACC_ROUTING_VIA] = "REGH_MACC_ROUTING_VIA",
|
||||||
|
[REGH_MACC_L] = "REGH_MACC_L",
|
||||||
|
[PLL_T] = "PLL_T",
|
||||||
|
[DCM_T] = "DCM_T",
|
||||||
|
[PLL_B] = "PLL_B",
|
||||||
|
[DCM_B] = "DCM_B",
|
||||||
|
[REG_T] = "REG_T",
|
||||||
|
[REG_TERM_T] = "REG_TERM_T",
|
||||||
|
[REG_TERM_B] = "REG_TERM_B",
|
||||||
|
[REG_B] = "REG_B",
|
||||||
|
[REGV_TERM_T] = "REGV_TERM_T",
|
||||||
|
[REGV_TERM_B] = "REGV_TERM_B",
|
||||||
|
[HCLK_REGV] = "HCLK_REGV",
|
||||||
|
[REGV] = "REGV",
|
||||||
|
[REGV_BRK] = "REGV_BRK",
|
||||||
|
[REGV_T] = "REGV_T",
|
||||||
|
[REGV_B] = "REGV_B",
|
||||||
|
[REGV_MIDBUF_T] = "REGV_MIDBUF_T",
|
||||||
|
[REGV_HCLKBUF_T] = "REGV_HCLKBUF_T",
|
||||||
|
[REGV_HCLKBUF_B] = "REGV_HCLKBUF_B",
|
||||||
|
[REGV_MIDBUF_B] = "REGV_MIDBUF_B",
|
||||||
|
[REGC_ROUTING] = "REGC_ROUTING",
|
||||||
|
[REGC_LOGIC] = "REGC_LOGIC",
|
||||||
|
[REGC_CMT] = "REGC_CMT",
|
||||||
|
[CENTER] = "CENTER",
|
||||||
|
[IO_T] = "IO_T",
|
||||||
|
[IO_B] = "IO_B",
|
||||||
|
[IO_TERM_T] = "IO_TERM_T",
|
||||||
|
[IO_TERM_B] = "IO_TERM_B",
|
||||||
|
[IO_ROUTING] = "IO_ROUTING",
|
||||||
|
[IO_LOGIC_TERM_T] = "IO_LOGIC_TERM_T",
|
||||||
|
[IO_LOGIC_TERM_B] = "IO_LOGIC_TERM_B",
|
||||||
|
[IO_OUTER_T] = "IO_OUTER_T",
|
||||||
|
[IO_INNER_T] = "IO_INNER_T",
|
||||||
|
[IO_OUTER_B] = "IO_OUTER_B",
|
||||||
|
[IO_INNER_B] = "IO_INNER_B",
|
||||||
|
[IO_BUFPLL_TERM_T] = "IO_BUFPLL_TERM_T",
|
||||||
|
[IO_LOGIC_REG_TERM_T] = "IO_LOGIC_REG_TERM_T",
|
||||||
|
[IO_BUFPLL_TERM_B] = "IO_BUFPLL_TERM_B",
|
||||||
|
[IO_LOGIC_REG_TERM_B] = "IO_LOGIC_REG_TERM_B",
|
||||||
|
[LOGIC_ROUTING_TERM_B] = "LOGIC_ROUTING_TERM_B",
|
||||||
|
[LOGIC_NOIO_TERM_B] = "LOGIC_NOIO_TERM_B",
|
||||||
|
[MACC_ROUTING_TERM_T] = "MACC_ROUTING_TERM_T",
|
||||||
|
[MACC_ROUTING_TERM_B] = "MACC_ROUTING_TERM_B",
|
||||||
|
[MACC_VIA_TERM_T] = "MACC_VIA_TERM_T",
|
||||||
|
[MACC_TERM_TL] = "MACC_TERM_TL",
|
||||||
|
[MACC_TERM_TR] = "MACC_TERM_TR",
|
||||||
|
[MACC_TERM_BL] = "MACC_TERM_BL",
|
||||||
|
[MACC_TERM_BR] = "MACC_TERM_BR",
|
||||||
|
[ROUTING_VIA_REGC] = "ROUTING_VIA_REGC",
|
||||||
|
[ROUTING_VIA_IO] = "ROUTING_VIA_IO",
|
||||||
|
[ROUTING_VIA_IO_DCM] = "ROUTING_VIA_IO_DCM",
|
||||||
|
[ROUTING_VIA_CARRY] = "ROUTING_VIA_CARRY",
|
||||||
|
[CORNER_TERM_L] = "CORNER_TERM_L",
|
||||||
|
[CORNER_TERM_R] = "CORNER_TERM_R",
|
||||||
|
[IO_TERM_L_UPPER_TOP] = "IO_TERM_L_UPPER_TOP",
|
||||||
|
[IO_TERM_L_UPPER_BOT] = "IO_TERM_L_UPPER_BOT",
|
||||||
|
[IO_TERM_L_LOWER_TOP] = "IO_TERM_L_LOWER_TOP",
|
||||||
|
[IO_TERM_L_LOWER_BOT] = "IO_TERM_L_LOWER_BOT",
|
||||||
|
[IO_TERM_R_UPPER_TOP] = "IO_TERM_R_UPPER_TOP",
|
||||||
|
[IO_TERM_R_UPPER_BOT] = "IO_TERM_R_UPPER_BOT",
|
||||||
|
[IO_TERM_R_LOWER_TOP] = "IO_TERM_R_LOWER_TOP",
|
||||||
|
[IO_TERM_R_LOWER_BOT] = "IO_TERM_R_LOWER_BOT",
|
||||||
|
[IO_TERM_L] = "IO_TERM_L",
|
||||||
|
[IO_TERM_R] = "IO_TERM_R",
|
||||||
|
[HCLK_TERM_L] = "HCLK_TERM_L",
|
||||||
|
[HCLK_TERM_R] = "HCLK_TERM_R",
|
||||||
|
[REGH_IO_TERM_L] = "REGH_IO_TERM_L",
|
||||||
|
[REGH_IO_TERM_R] = "REGH_IO_TERM_R",
|
||||||
|
[REG_L] = "REG_L",
|
||||||
|
[REG_R] = "REG_R",
|
||||||
|
[IO_PCI_L] = "IO_PCI_L",
|
||||||
|
[IO_PCI_R] = "IO_PCI_R",
|
||||||
|
[IO_RDY_L] = "IO_RDY_L",
|
||||||
|
[IO_RDY_R] = "IO_RDY_R",
|
||||||
|
[IO_L] = "IO_L",
|
||||||
|
[IO_R] = "IO_R",
|
||||||
|
[IO_PCI_CONN_L] = "IO_PCI_CONN_L",
|
||||||
|
[IO_PCI_CONN_R] = "IO_PCI_CONN_R",
|
||||||
|
[CORNER_TERM_T] = "CORNER_TERM_T",
|
||||||
|
[CORNER_TERM_B] = "CORNER_TERM_B",
|
||||||
|
[ROUTING_IO_L] = "ROUTING_IO_L",
|
||||||
|
[HCLK_ROUTING_IO_L] = "HCLK_ROUTING_IO_L",
|
||||||
|
[HCLK_ROUTING_IO_R] = "HCLK_ROUTING_IO_R",
|
||||||
|
[REGH_ROUTING_IO_L] = "REGH_ROUTING_IO_L",
|
||||||
|
[REGH_ROUTING_IO_R] = "REGH_ROUTING_IO_R",
|
||||||
|
[ROUTING_IO_L_BRK] = "ROUTING_IO_L_BRK",
|
||||||
|
[ROUTING_GCLK] = "ROUTING_GCLK",
|
||||||
|
[REGH_IO_L] = "REGH_IO_L",
|
||||||
|
[REGH_IO_R] = "REGH_IO_R",
|
||||||
|
[REGH_MCB] = "REGH_MCB",
|
||||||
|
[HCLK_MCB] = "HCLK_MCB",
|
||||||
|
[ROUTING_IO_VIA_L] = "ROUTING_IO_VIA_L",
|
||||||
|
[ROUTING_IO_VIA_R] = "ROUTING_IO_VIA_R",
|
||||||
|
[ROUTING_IO_PCI_CE_L] = "ROUTING_IO_PCI_CE_L",
|
||||||
|
[ROUTING_IO_PCI_CE_R] = "ROUTING_IO_PCI_CE_R",
|
||||||
|
[CORNER_TL] = "CORNER_TL",
|
||||||
|
[CORNER_BL] = "CORNER_BL",
|
||||||
|
[CORNER_TR_UPPER] = "CORNER_TR_UPPER",
|
||||||
|
[CORNER_TR_LOWER] = "CORNER_TR_LOWER",
|
||||||
|
[CORNER_BR_UPPER] = "CORNER_BR_UPPER",
|
||||||
|
[CORNER_BR_LOWER] = "CORNER_BR_LOWER",
|
||||||
|
[HCLK_IO_TOP_UP_L] = "HCLK_IO_TOP_UP_L",
|
||||||
|
[HCLK_IO_TOP_UP_R] = "HCLK_IO_TOP_UP_R",
|
||||||
|
[HCLK_IO_TOP_SPLIT_L] = "HCLK_IO_TOP_SPLIT_L",
|
||||||
|
[HCLK_IO_TOP_SPLIT_R] = "HCLK_IO_TOP_SPLIT_R",
|
||||||
|
[HCLK_IO_TOP_DN_L] = "HCLK_IO_TOP_DN_L",
|
||||||
|
[HCLK_IO_TOP_DN_R] = "HCLK_IO_TOP_DN_R",
|
||||||
|
[HCLK_IO_BOT_UP_L] = "HCLK_IO_BOT_UP_L",
|
||||||
|
[HCLK_IO_BOT_UP_R] = "HCLK_IO_BOT_UP_R",
|
||||||
|
[HCLK_IO_BOT_SPLIT_L] = "HCLK_IO_BOT_SPLIT_L",
|
||||||
|
[HCLK_IO_BOT_SPLIT_R] = "HCLK_IO_BOT_SPLIT_R",
|
||||||
|
[HCLK_IO_BOT_DN_L] = "HCLK_IO_BOT_DN_L",
|
||||||
|
[HCLK_IO_BOT_DN_R] = "HCLK_IO_BOT_DN_R",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* fpga_tiletype_str(enum fpga_tile_type type)
|
||||||
|
{
|
||||||
|
if (type >= sizeof(fpga_ttstr)/sizeof(fpga_ttstr[0])
|
||||||
|
|| !fpga_ttstr[type]) return "UNK";
|
||||||
|
return fpga_ttstr[type];
|
||||||
|
}
|
444
model_ports.c
Normal file
444
model_ports.c
Normal file
|
@ -0,0 +1,444 @@
|
||||||
|
//
|
||||||
|
// Author: Wolfgang Spraul
|
||||||
|
//
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// For details see the UNLICENSE file at the root of the source tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "model.h"
|
||||||
|
|
||||||
|
static int add_io_connpts(struct fpga_model* model, int y, int x, const char* prefix, int num_devs)
|
||||||
|
{
|
||||||
|
int i, rc;
|
||||||
|
|
||||||
|
for (i = 0; i < num_devs; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_O%i_PINW", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_IBUF%i_PINW", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_T%i_PINW", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_PADOUT%i", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DIFFI_IN%i", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DIFFO_IN%i", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DIFFO_OUT%i", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_PCI_RDY%i", prefix, i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum which_side
|
||||||
|
{
|
||||||
|
TOP_S, BOTTOM_S, RIGHT_S, LEFT_S
|
||||||
|
};
|
||||||
|
|
||||||
|
static int init_iologic_ports(struct fpga_model* model, int y, int x, enum which_side side)
|
||||||
|
{
|
||||||
|
static const char* prefix, *suffix1, *suffix2;
|
||||||
|
int rc, i;
|
||||||
|
|
||||||
|
switch (side) {
|
||||||
|
case TOP_S: prefix = "TIOI"; break;
|
||||||
|
case BOTTOM_S: prefix = "BIOI"; break;
|
||||||
|
case LEFT_S: prefix = "LIOI"; break;
|
||||||
|
case RIGHT_S: prefix = "RIOI"; break;
|
||||||
|
default: ABORT(1);
|
||||||
|
}
|
||||||
|
if (side == LEFT_S || side == RIGHT_S) {
|
||||||
|
suffix1 = "_M";
|
||||||
|
suffix2 = "_S";
|
||||||
|
} else {
|
||||||
|
suffix1 = "_STUB";
|
||||||
|
suffix2 = "_S_STUB";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = X_A /* 0 */; i <= M_DQ /* 23 */; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("IOI_INTER_LOGICOUT%i", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_GND_TIEOFF", prefix));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_VCC_TIEOFF", prefix));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_KEEP1_STUB", prefix));
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 0; i <= 4; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, pf("AUXADDR%i_IODELAY", i), suffix1, suffix2);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
rc = add_connpt_2(model, y, x, "AUXSDOIN_IODELAY", suffix1, suffix2);
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, "AUXSDO_IODELAY", suffix1, suffix2);
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, "MEMUPDATE_IODELAY", suffix1, suffix2);
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
rc = add_connpt_name(model, y, x, "OUTN_IODELAY_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "STUB_OUTN_IODELAY_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "OUTP_IODELAY_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "STUB_OUTP_IODELAY_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
for (i = 1; i <= 4; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, pf("Q%i_ILOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("D%i_OLOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("T%i_OLOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("SHIFTIN%i_OLOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("SHIFTOUT%i_OLOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, pf("CFB%i_ILOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("CLK%i_ILOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, pf("CLK%i_OLOGIC_SITE", i), "", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
static const char* mcb_2[] = {
|
||||||
|
"BITSLIP_ILOGIC_SITE", "BUSY_IODELAY_SITE",
|
||||||
|
"CAL_IODELAY_SITE", "CE0_ILOGIC_SITE",
|
||||||
|
"CE_IODELAY_SITE", "CIN_IODELAY_SITE",
|
||||||
|
"CLKDIV_ILOGIC_SITE", "CLKDIV_OLOGIC_SITE",
|
||||||
|
"CLK_IODELAY_SITE", "DATAOUT_IODELAY_SITE",
|
||||||
|
"DDLY2_ILOGIC_SITE", "DDLY_ILOGIC_SITE",
|
||||||
|
"DFB_ILOGIC_SITE", "D_ILOGIC_IDATAIN_IODELAY",
|
||||||
|
"D_ILOGIC_SITE", "DOUT_IODELAY_SITE",
|
||||||
|
"FABRICOUT_ILOGIC_SITE", "IDATAIN_IODELAY_SITE",
|
||||||
|
"INCDEC_ILOGIC_SITE", "INC_IODELAY_SITE",
|
||||||
|
"IOCE_ILOGIC_SITE", "IOCE_OLOGIC_SITE",
|
||||||
|
"IOCLK1_IODELAY_SITE", "IOCLK_IODELAY_SITE",
|
||||||
|
"LOAD_IODELAY_SITE", "OCE_OLOGIC_SITE",
|
||||||
|
"ODATAIN_IODELAY_SITE", "OFB_ILOGIC_SITE",
|
||||||
|
"OQ_OLOGIC_SITE", "RCLK_IODELAY_SITE",
|
||||||
|
"READEN_IODELAY_UNUSED_SITE", "REV_ILOGIC_SITE",
|
||||||
|
"REV_OLOGIC_SITE", "RST_IODELAY_SITE",
|
||||||
|
"SHIFTIN_ILOGIC_SITE", "SHIFTOUT_ILOGIC_SITE",
|
||||||
|
"SR_ILOGIC_SITE", "SR_OLOGIC_SITE",
|
||||||
|
"TCE_OLOGIC_SITE", "TFB_ILOGIC_SITE",
|
||||||
|
"T_IODELAY_SITE", "TOUT_IODELAY_SITE",
|
||||||
|
"TQ_OLOGIC_SITE", "TRAIN_OLOGIC_SITE",
|
||||||
|
"VALID_ILOGIC_SITE", "" };
|
||||||
|
|
||||||
|
for (i = 0; mcb_2[i][0]; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, mcb_2[i], "", "_S");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc = add_connpt_name(model, y, x, "DATAOUT2_IODELAY_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "DATAOUT2_IODELAY2_SITE_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
for (i = 0; i <= 2; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, pf("IOI_CLK%iINTER", i),
|
||||||
|
"_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, pf("IOI_CLKDIST_IOCE%i", i),
|
||||||
|
"_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
rc = add_connpt_2(model, y, x, "IOI_CLKDIST_CLK0_ILOGIC", "_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, "IOI_CLKDIST_CLK0_OLOGIC", "_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_2(model, y, x, "IOI_CLKDIST_CLK1", "_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
if (side == TOP_S || side == BOTTOM_S) {
|
||||||
|
static const char* mcb_2[] = {
|
||||||
|
"IOI_MCB_DQIEN", "IOI_MCB_INBYP",
|
||||||
|
"IOI_MCB_IN", "IOI_MCB_OUTN",
|
||||||
|
"IOI_MCB_OUTP", "" };
|
||||||
|
static const char* mcb_1[] = {
|
||||||
|
"IOI_MCB_DRPADD", "IOI_MCB_DRPBROADCAST",
|
||||||
|
"IOI_MCB_DRPCLK", "IOI_MCB_DRPCS",
|
||||||
|
"IOI_MCB_DRPSDI", "IOI_MCB_DRPSDO",
|
||||||
|
"IOI_MCB_DRPTRAIN", "" };
|
||||||
|
|
||||||
|
for (i = 0; mcb_2[i][0]; i++) {
|
||||||
|
rc = add_connpt_2(model, y, x, mcb_2[i], "_M", "_S");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; mcb_1[i][0]; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, mcb_1[i]);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int init_ports(struct fpga_model* model)
|
||||||
|
{
|
||||||
|
int x, y, i, j, k, row_num, row_pos, rc;
|
||||||
|
|
||||||
|
// inner and outer IO tiles (ILOGIC/ILOGIC/IODELAY)
|
||||||
|
for (x = LEFT_SIDE_WIDTH; x < model->x_width - RIGHT_SIDE_WIDTH; x++) {
|
||||||
|
if (has_device(model, TOP_OUTER_IO, x, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, TOP_OUTER_IO, x, TOP_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (has_device(model, TOP_INNER_IO, x, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, TOP_INNER_IO, x, TOP_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (has_device(model, model->y_height - BOT_INNER_IO, x, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, model->y_height - BOT_INNER_IO, x, BOTTOM_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (has_device(model, model->y_height - BOT_OUTER_IO, x, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, model->y_height - BOT_OUTER_IO, x, BOTTOM_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (has_device(model, y, LEFT_IO_DEVS, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, y, LEFT_IO_DEVS, LEFT_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (has_device(model, y, model->x_width - RIGHT_IO_DEVS_O, DEV_ILOGIC)) {
|
||||||
|
rc = init_iologic_ports(model, y, model->x_width - RIGHT_IO_DEVS_O, RIGHT_S);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IO tiles
|
||||||
|
for (x = LEFT_SIDE_WIDTH; x < model->x_width - RIGHT_SIDE_WIDTH; x++) {
|
||||||
|
if (YX_TILE(model, 0, x)->type == IO_T) {
|
||||||
|
rc = add_io_connpts(model, 0 /* y */, x, "TIOB",
|
||||||
|
4 /* num_devs */);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (YX_TILE(model, model->y_height - BOT_OUTER_ROW, x)->type == IO_B) {
|
||||||
|
rc = add_io_connpts(model, model->y_height
|
||||||
|
- BOT_OUTER_ROW, x, "BIOB", 4 /* num_devs */);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (YX_TILE(model, y, 0)->type == IO_L) {
|
||||||
|
rc = add_io_connpts(model, y, 0 /* x */, "LIOB",
|
||||||
|
2 /* num_devs */);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
if (YX_TILE(model, y, model->x_width - RIGHT_OUTER_O)->type == IO_R) {
|
||||||
|
rc = add_io_connpts(model, y, model->x_width
|
||||||
|
- RIGHT_OUTER_O, "RIOB", 2 /* num_devs */);
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (x = 0; x < model->x_width; x++) {
|
||||||
|
if (is_atx(X_ROUTING_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (is_aty(Y_ROW_HORIZ_AXSYMM|Y_CHIP_HORIZ_REGS,
|
||||||
|
model, y))
|
||||||
|
continue;
|
||||||
|
rc = add_connpt_name(model, y, x, "VCC_WIRE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "GND_WIRE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "KEEP1_WIRE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "FAN");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "FAN_B");
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
if (!is_atyx(YX_IO_ROUTING, model, y, x)) {
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("GFAN%i", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!is_atx(X_CENTER_ROUTING_COL, model, x)
|
||||||
|
|| is_aty(Y_TOPBOT_IO_RANGE, model, y)) {
|
||||||
|
// In the center those 2 wires are connected
|
||||||
|
// to the PLL, but elsewhere? Not clear what they
|
||||||
|
// connect to...
|
||||||
|
rc = add_connpt_name(model, y, x,
|
||||||
|
logicin_s(X_A5, 1 /* routing_io */));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x,
|
||||||
|
logicin_s(X_B4, 1 /* routing_io */));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_FABRIC_BRAM_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (YX_TILE(model, y, x)->flags & TF_BRAM_DEV) {
|
||||||
|
|
||||||
|
static const char* pass_str[3] = {"RAMB16BWER", "RAMB8BWER_0", "RAMB8BWER_1"};
|
||||||
|
// pass 0 is ramb16, pass 1 and 2 are for ramb8
|
||||||
|
for (i = 0; i <= 2; i++) {
|
||||||
|
for (j = 'A'; j <= 'B'; j++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_CLK%c", pass_str[i], j));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_EN%c", pass_str[i], j));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_REGCE%c", pass_str[i], j));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_RST%c", pass_str[i], j));
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (k = 0; k <= (!i ? 3 : 1); k++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DIP%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DOP%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_WE%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (k = 0; k <= (!i ? 13 : 12); k++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_ADDR%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (k = 0; k <= (!i ? 31 : 15); k++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DI%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_DO%c%i", pass_str[i], j, k));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_FABRIC_MACC_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (YX_TILE(model, y, x)->flags & TF_MACC_DEV) {
|
||||||
|
static const char* pref[] = {"CE", "RST", ""};
|
||||||
|
static const char* seq[] = {"A", "B", "C", "D", "M", "P", "OPMODE", ""};
|
||||||
|
|
||||||
|
is_in_row(model, y, &row_num, &row_pos);
|
||||||
|
if (!row_num && row_pos == LAST_POS_IN_ROW) {
|
||||||
|
rc = add_connpt_name(model, y, x, "CARRYIN_DSP48A1_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 0; i <= 47; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("PCIN%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = add_connpt_name(model, y, x, "CLK_DSP48A1_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "CARRYOUT_DSP48A1_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "CARRYOUTF_DSP48A1_SITE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
|
||||||
|
for (i = 0; pref[i][0]; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%sCARRYIN_DSP48A1_SITE", pref[i]));
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (j = 0; seq[j][0]; j++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s%s_DSP48A1_SITE", pref[i], seq[j]));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i <= 17; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("A%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("B%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("D%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("BCOUT%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= 47; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("C%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("P%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("PCOUT%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= 35; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("M%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= 7; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("OPMODE%i_DSP48A1_SITE", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_atx(X_LOGIC_COL, model, x)) {
|
||||||
|
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||||
|
if (YX_TILE(model, y, x)->flags & (TF_LOGIC_XM_DEV|TF_LOGIC_XL_DEV)) {
|
||||||
|
const char* pref[2];
|
||||||
|
|
||||||
|
if (YX_TILE(model, y, x)->flags & TF_LOGIC_XM_DEV) {
|
||||||
|
// The first SLICEM on the bottom has a given C_IN port.
|
||||||
|
if (is_aty(Y_INNER_BOTTOM, model, y+3)) {
|
||||||
|
rc = add_connpt_name(model, y, x, "M_CIN");
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
rc = add_connpt_name(model, y, x, "M_COUT");
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, "M_WE");
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 'A'; i <= 'D'; i++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("M_%cI", i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
pref[0] = "M";
|
||||||
|
pref[1] = "X";
|
||||||
|
} else { // LOGIC_XL
|
||||||
|
rc = add_connpt_name(model, y, x, "XL_COUT");
|
||||||
|
if (rc) goto xout;
|
||||||
|
pref[0] = "L";
|
||||||
|
pref[1] = "XX";
|
||||||
|
}
|
||||||
|
for (k = 0; k <= 1; k++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_CE", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_SR", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_CLK", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
for (i = 'A'; i <= 'D'; i++) {
|
||||||
|
for (j = 1; j <= 6; j++) {
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_%c%i", pref[k], i, j));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_%c", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_%cMUX", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_%cQ", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
rc = add_connpt_name(model, y, x, pf("%s_%cX", pref[k], i));
|
||||||
|
if (rc) goto xout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
xout:
|
||||||
|
return rc;
|
||||||
|
}
|
1052
model_switches.c
Normal file
1052
model_switches.c
Normal file
File diff suppressed because it is too large
Load Diff
545
model_tiles.c
Normal file
545
model_tiles.c
Normal file
|
@ -0,0 +1,545 @@
|
||||||
|
//
|
||||||
|
// Author: Wolfgang Spraul
|
||||||
|
//
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// For details see the UNLICENSE file at the root of the source tree.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "model.h"
|
||||||
|
|
||||||
|
int init_tiles(struct fpga_model* model)
|
||||||
|
{
|
||||||
|
int tile_rows, tile_columns, i, j, k, l, row_top_y, left_side;
|
||||||
|
int start, end, no_io;
|
||||||
|
char cur_cfgcol, last_col;
|
||||||
|
struct fpga_tile* tile_i0;
|
||||||
|
|
||||||
|
tile_rows = 1 /* middle */ + (8+1+8)*model->cfg_rows + 2+2 /* two extra tiles at top and bottom */;
|
||||||
|
tile_columns = LEFT_SIDE_WIDTH + RIGHT_SIDE_WIDTH;
|
||||||
|
for (i = 0; model->cfg_columns[i] != 0; i++) {
|
||||||
|
if (model->cfg_columns[i] == 'L' || model->cfg_columns[i] == 'M')
|
||||||
|
tile_columns += 2; // 2 for logic blocks L/M
|
||||||
|
else if (model->cfg_columns[i] == 'B' || model->cfg_columns[i] == 'D')
|
||||||
|
tile_columns += 3; // 3 for bram or macc
|
||||||
|
else if (model->cfg_columns[i] == 'R')
|
||||||
|
tile_columns += 2+2; // 2+2 for middle IO+logic+PLL/DCM
|
||||||
|
}
|
||||||
|
model->tmp_str = malloc((tile_columns > tile_rows ? tile_columns : tile_rows) * sizeof(*model->tmp_str));
|
||||||
|
if (!model->tmp_str) {
|
||||||
|
fprintf(stderr, "%i: Out of memory.\n", __LINE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
model->x_width = tile_columns;
|
||||||
|
model->y_height = tile_rows;
|
||||||
|
model->center_x = -1;
|
||||||
|
model->tiles = calloc(tile_columns * tile_rows, sizeof(struct fpga_tile));
|
||||||
|
if (!model->tiles) {
|
||||||
|
fprintf(stderr, "%i: Out of memory.\n", __LINE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < tile_rows * tile_columns; i++)
|
||||||
|
model->tiles[i].type = NA;
|
||||||
|
if (!(tile_rows % 2))
|
||||||
|
fprintf(stderr, "Unexpected even number of tile rows (%i).\n", tile_rows);
|
||||||
|
model->center_y = 2 /* top IO files */ + (model->cfg_rows/2)*(8+1/*middle of row clock*/+8);
|
||||||
|
|
||||||
|
//
|
||||||
|
// top, bottom, center:
|
||||||
|
// go through columns from left to right, rows from top to bottom
|
||||||
|
//
|
||||||
|
|
||||||
|
left_side = 1; // turn off (=right side) when reaching the 'R' middle column
|
||||||
|
i = 5; // skip left IO columns
|
||||||
|
for (j = 0; model->cfg_columns[j]; j++) {
|
||||||
|
cur_cfgcol = model->cfg_columns[j];
|
||||||
|
switch (cur_cfgcol) {
|
||||||
|
case 'L':
|
||||||
|
case 'l':
|
||||||
|
case 'M':
|
||||||
|
case 'm':
|
||||||
|
no_io = (next_non_whitespace(&model->cfg_columns[j+1]) == 'n');
|
||||||
|
last_col = last_major(model->cfg_columns, j);
|
||||||
|
|
||||||
|
model->tiles[i].flags |= TF_FABRIC_ROUTING_COL;
|
||||||
|
if (no_io) model->tiles[i].flags |= TF_ROUTING_NO_IO;
|
||||||
|
model->tiles[i+1].flags |= TF_FABRIC_LOGIC_COL;
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles (center row)
|
||||||
|
start = ((k == model->cfg_rows-1 && !no_io) ? 2 : 0);
|
||||||
|
end = ((k == 0 && !no_io) ? 14 : 16);
|
||||||
|
for (l = start; l < end; l++) {
|
||||||
|
tile_i0 = &model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i];
|
||||||
|
if (l < 15 || (!k && no_io))
|
||||||
|
tile_i0->type = ROUTING;
|
||||||
|
else
|
||||||
|
tile_i0->type = ROUTING_BRK;
|
||||||
|
if (cur_cfgcol == 'L') {
|
||||||
|
tile_i0[1].flags |= TF_LOGIC_XL_DEV;
|
||||||
|
tile_i0[1].type = LOGIC_XL;
|
||||||
|
} else {
|
||||||
|
tile_i0[1].flags |= TF_LOGIC_XM_DEV;
|
||||||
|
tile_i0[1].type = LOGIC_XM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cur_cfgcol == 'L') {
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i].type = HCLK_ROUTING_XL;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 1].type = HCLK_LOGIC_XL;
|
||||||
|
} else {
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i].type = HCLK_ROUTING_XM;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 1].type = HCLK_LOGIC_XM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_col == 'R') {
|
||||||
|
model->tiles[tile_columns + i].type = IO_BUFPLL_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = IO_BUFPLL_TERM_B;
|
||||||
|
} else {
|
||||||
|
model->tiles[tile_columns + i].type = IO_TERM_T;
|
||||||
|
if (!no_io)
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = IO_TERM_B;
|
||||||
|
else
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = LOGIC_ROUTING_TERM_B;
|
||||||
|
}
|
||||||
|
if (!no_io) {
|
||||||
|
model->tiles[i].type = IO_T;
|
||||||
|
model->tiles[(tile_rows-1)*tile_columns + i].type = IO_B;
|
||||||
|
model->tiles[2*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[3*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i].type = IO_ROUTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_col == 'R') {
|
||||||
|
model->tiles[tile_columns + i + 1].type = IO_LOGIC_REG_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = IO_LOGIC_REG_TERM_B;
|
||||||
|
} else {
|
||||||
|
model->tiles[tile_columns + i + 1].type = IO_LOGIC_TERM_T;
|
||||||
|
if (!no_io)
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = IO_LOGIC_TERM_B;
|
||||||
|
else
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = LOGIC_NOIO_TERM_B;
|
||||||
|
}
|
||||||
|
if (!no_io) {
|
||||||
|
model->tiles[2*tile_columns + i + 1].type = IO_OUTER_T;
|
||||||
|
model->tiles[2*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[3*tile_columns + i + 1].type = IO_INNER_T;
|
||||||
|
model->tiles[3*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i + 1].type = IO_INNER_B;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i + 1].type = IO_OUTER_B;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cur_cfgcol == 'L') {
|
||||||
|
model->tiles[model->center_y*tile_columns + i].type = REGH_ROUTING_XL;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 1].type = REGH_LOGIC_XL;
|
||||||
|
} else {
|
||||||
|
model->tiles[model->center_y*tile_columns + i].type = REGH_ROUTING_XM;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 1].type = REGH_LOGIC_XM;
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
if (next_non_whitespace(&model->cfg_columns[j+1]) == 'g') {
|
||||||
|
if (left_side)
|
||||||
|
model->left_gclk_sep_x = i+2;
|
||||||
|
else
|
||||||
|
model->right_gclk_sep_x = i+2;
|
||||||
|
}
|
||||||
|
model->tiles[i].flags |= TF_FABRIC_ROUTING_COL;
|
||||||
|
model->tiles[i].flags |= TF_ROUTING_NO_IO; // no_io always on for BRAM
|
||||||
|
model->tiles[i+1].flags |= TF_FABRIC_BRAM_VIA_COL;
|
||||||
|
model->tiles[i+2].flags |= TF_FABRIC_BRAM_COL;
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles
|
||||||
|
for (l = 0; l < 16; l++) {
|
||||||
|
tile_i0 = &model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i];
|
||||||
|
if (l < 15)
|
||||||
|
tile_i0->type = BRAM_ROUTING;
|
||||||
|
else
|
||||||
|
tile_i0->type = BRAM_ROUTING_BRK;
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i + 1].type = ROUTING_VIA;
|
||||||
|
if (!(l%4)) {
|
||||||
|
model->tiles[(row_top_y+3+(l<8?l:l+1))*tile_columns + i + 2].type = BRAM;
|
||||||
|
model->tiles[(row_top_y+3+(l<8?l:l+1))*tile_columns + i + 2].flags |= TF_BRAM_DEV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i].type = HCLK_BRAM_ROUTING;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 1].type = HCLK_BRAM_ROUTING_VIA;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 2].type = HCLK_BRAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
model->tiles[tile_columns + i].type = BRAM_ROUTING_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = BRAM_ROUTING_TERM_B;
|
||||||
|
model->tiles[tile_columns + i + 1].type = BRAM_ROUTING_VIA_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = BRAM_ROUTING_VIA_TERM_B;
|
||||||
|
model->tiles[tile_columns + i + 2].type = left_side ? BRAM_TERM_LT : BRAM_TERM_RT;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 2].type = left_side ? BRAM_TERM_LB : BRAM_TERM_RB;
|
||||||
|
|
||||||
|
model->tiles[model->center_y*tile_columns + i].type = REGH_BRAM_ROUTING;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 1].type = REGH_BRAM_ROUTING_VIA;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 2].type = left_side ? REGH_BRAM_L : REGH_BRAM_R;
|
||||||
|
i += 3;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
model->tiles[i].flags |= TF_FABRIC_ROUTING_COL;
|
||||||
|
model->tiles[i].flags |= TF_ROUTING_NO_IO; // no_io always on for MACC
|
||||||
|
model->tiles[i+1].flags |= TF_FABRIC_MACC_VIA_COL;
|
||||||
|
model->tiles[i+2].flags |= TF_FABRIC_MACC_COL;
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles
|
||||||
|
for (l = 0; l < 16; l++) {
|
||||||
|
tile_i0 = &model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i];
|
||||||
|
if (l < 15)
|
||||||
|
tile_i0->type = ROUTING;
|
||||||
|
else
|
||||||
|
tile_i0->type = ROUTING_BRK;
|
||||||
|
tile_i0[1].type = ROUTING_VIA;
|
||||||
|
if (!(l%4)) {
|
||||||
|
model->tiles[(row_top_y+3+(l<8?l:l+1))*tile_columns + i + 2].type = MACC;
|
||||||
|
model->tiles[(row_top_y+3+(l<8?l:l+1))*tile_columns + i + 2].flags |= TF_MACC_DEV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i].type = HCLK_MACC_ROUTING;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 1].type = HCLK_MACC_ROUTING_VIA;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 2].type = HCLK_MACC;
|
||||||
|
}
|
||||||
|
|
||||||
|
model->tiles[tile_columns + i].type = MACC_ROUTING_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = MACC_ROUTING_TERM_B;
|
||||||
|
model->tiles[tile_columns + i + 1].type = MACC_VIA_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = IO_LOGIC_TERM_B;
|
||||||
|
model->tiles[tile_columns + i + 2].type = left_side ? MACC_TERM_TL : MACC_TERM_TR;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 2].type = left_side ? MACC_TERM_BL : MACC_TERM_BR;
|
||||||
|
|
||||||
|
model->tiles[model->center_y*tile_columns + i].type = REGH_MACC_ROUTING;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 1].type = REGH_MACC_ROUTING_VIA;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 2].type = REGH_MACC_L;
|
||||||
|
i += 3;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
if (next_non_whitespace(&model->cfg_columns[j+1]) != 'M') {
|
||||||
|
// We expect a LOGIC_XM column to follow the center for
|
||||||
|
// the top and bottom bufpll and reg routing.
|
||||||
|
fprintf(stderr, "Expecting LOGIC_XM after center but found '%c'\n", model->cfg_columns[j+1]);
|
||||||
|
}
|
||||||
|
model->center_x = i+3;
|
||||||
|
|
||||||
|
left_side = 0;
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles
|
||||||
|
|
||||||
|
for (l = 0; l < 16; l++) {
|
||||||
|
tile_i0 = &model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i];
|
||||||
|
|
||||||
|
if ((k < model->cfg_rows-1 || l >= 2) && (k || l<14)) {
|
||||||
|
if (l < 15)
|
||||||
|
tile_i0->type = ROUTING;
|
||||||
|
else
|
||||||
|
tile_i0->type = ROUTING_BRK;
|
||||||
|
if (l == 7)
|
||||||
|
tile_i0[1].type = ROUTING_VIA_IO;
|
||||||
|
else if (l == 8)
|
||||||
|
tile_i0[1].type = (k%2) ? ROUTING_VIA_CARRY : ROUTING_VIA_IO_DCM;
|
||||||
|
else if (l == 15 && k==model->cfg_rows/2)
|
||||||
|
tile_i0[1].type = ROUTING_VIA_REGC;
|
||||||
|
else {
|
||||||
|
tile_i0[1].type = LOGIC_XL;
|
||||||
|
tile_i0[1].flags |= TF_LOGIC_XL_DEV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (l == 7
|
||||||
|
|| (l == 8 && !(k%2))) { // even row, together with DCM
|
||||||
|
tile_i0->type = IO_ROUTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l == 7) {
|
||||||
|
if (k%2) { // odd
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 2].flags |= TF_PLL_DEV;
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 2].type = (k<(model->cfg_rows/2)) ? PLL_B : PLL_T;
|
||||||
|
} else { // even
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 2].flags |= TF_DCM_DEV;
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 2].type = (k<(model->cfg_rows/2)) ? DCM_B : DCM_T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// four midbuf tiles, in the middle of the top and bottom halves
|
||||||
|
if (l == 15) {
|
||||||
|
if (k == model->cfg_rows*3/4)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + i + 3].type = REGV_MIDBUF_T;
|
||||||
|
else if (k == model->cfg_rows/4)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + i + 3].type = REGV_HCLKBUF_B;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + i + 3].type = REGV_BRK;
|
||||||
|
} else if (l == 0 && k == model->cfg_rows*3/4-1) {
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 3].type = REGV_HCLKBUF_T;
|
||||||
|
} else if (l == 0 && k == model->cfg_rows/4-1) {
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + i + 3].type = REGV_MIDBUF_B;
|
||||||
|
} else if (l == 8) {
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + i + 3].type = (k<model->cfg_rows/2) ? REGV_B : REGV_T;
|
||||||
|
} else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + i + 3].type = REGV;
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i].type = HCLK_ROUTING_XL;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 1].type = HCLK_LOGIC_XL;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + i + 3].type = HCLK_REGV;
|
||||||
|
}
|
||||||
|
model->tiles[i].type = IO_T;
|
||||||
|
model->tiles[(tile_rows-1)*tile_columns + i].type = IO_B;
|
||||||
|
model->tiles[tile_columns + i].type = IO_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i].type = IO_TERM_B;
|
||||||
|
model->tiles[2*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[3*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i].type = IO_ROUTING;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i].type = IO_ROUTING;
|
||||||
|
|
||||||
|
model->tiles[tile_columns + i + 1].type = IO_LOGIC_REG_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 1].type = IO_LOGIC_REG_TERM_B;
|
||||||
|
model->tiles[2*tile_columns + i + 1].type = IO_OUTER_T;
|
||||||
|
model->tiles[2*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[3*tile_columns + i + 1].type = IO_INNER_T;
|
||||||
|
model->tiles[3*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i + 1].type = IO_INNER_B;
|
||||||
|
model->tiles[(tile_rows-4)*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i + 1].type = IO_OUTER_B;
|
||||||
|
model->tiles[(tile_rows-3)*tile_columns + i + 1].flags |= TF_IOLOGIC_DELAY_DEV;
|
||||||
|
|
||||||
|
model->tiles[i + 2].type = REG_T;
|
||||||
|
model->tiles[tile_columns + i + 2].type = REG_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 2].type = REG_TERM_B;
|
||||||
|
model->tiles[(tile_rows-1)*tile_columns + i + 2].type = REG_B;
|
||||||
|
model->tiles[tile_columns + i + 3].type = REGV_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + i + 3].type = REGV_TERM_B;
|
||||||
|
|
||||||
|
model->tiles[model->center_y*tile_columns + i].type = REGC_ROUTING;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 1].type = REGC_LOGIC;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 2].type = REGC_CMT;
|
||||||
|
model->tiles[model->center_y*tile_columns + i + 3].type = CENTER;
|
||||||
|
|
||||||
|
i += 4;
|
||||||
|
break;
|
||||||
|
case ' ': // space used to make string more readable only
|
||||||
|
case 'g': // global clock separator
|
||||||
|
case 'n': // noio for logic blocks
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Ignoring unexpected column identifier '%c'\n", cur_cfgcol);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// left IO
|
||||||
|
//
|
||||||
|
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles
|
||||||
|
|
||||||
|
for (l = 0; l < 16; l++) {
|
||||||
|
//
|
||||||
|
// +0
|
||||||
|
//
|
||||||
|
if (model->cfg_left_wiring[(model->cfg_rows-1-k)*16+l] == 'W') {
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns].flags |= TF_WIRED;
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns].type = IO_L;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// +1
|
||||||
|
//
|
||||||
|
if ((k == model->cfg_rows-1 && !l) || (!k && l==15))
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 1].type = CORNER_TERM_L;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 12)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 1].type = IO_TERM_L_UPPER_TOP;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 13)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 1].type = IO_TERM_L_UPPER_BOT;
|
||||||
|
else if (k == (model->cfg_rows/2)-1 && !l)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + 1].type = IO_TERM_L_LOWER_TOP;
|
||||||
|
else if (k == (model->cfg_rows/2)-1 && l == 1)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + 1].type = IO_TERM_L_LOWER_BOT;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 1].type = IO_TERM_L;
|
||||||
|
//
|
||||||
|
// +2
|
||||||
|
//
|
||||||
|
if (model->cfg_left_wiring[(model->cfg_rows-1-k)*16+l] == 'W') {
|
||||||
|
if (l == 15 && k && k != model->cfg_rows/2)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 2].type = ROUTING_IO_L_BRK;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 2].type = ROUTING_IO_L;
|
||||||
|
} else { // unwired
|
||||||
|
if (k && k != model->cfg_rows/2 && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 2].type = ROUTING_BRK;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 14)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 2].type = ROUTING_GCLK;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 2].type = ROUTING;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// +3
|
||||||
|
//
|
||||||
|
if (model->cfg_left_wiring[(model->cfg_rows-1-k)*16+l] == 'W') {
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 3].type = ROUTING_IO_VIA_L;
|
||||||
|
} else { // unwired
|
||||||
|
if (k == model->cfg_rows-1 && !l) {
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + 3].type = CORNER_TL;
|
||||||
|
} else if (!k && l == 15) {
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 3].type = CORNER_BL;
|
||||||
|
} else {
|
||||||
|
if (k && k != model->cfg_rows/2 && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + 3].type = ROUTING_VIA_CARRY;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + 3].type = ROUTING_VIA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 1].type = HCLK_TERM_L;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 2].type = HCLK_ROUTING_IO_L;
|
||||||
|
if (k >= model->cfg_rows/2) { // top half
|
||||||
|
if (k > (model->cfg_rows*3)/4)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_TOP_UP_L;
|
||||||
|
else if (k == (model->cfg_rows*3)/4)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_TOP_SPLIT_L;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_TOP_DN_L;
|
||||||
|
} else { // bottom half
|
||||||
|
if (k < model->cfg_rows/4 - 1)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_BOT_DN_L;
|
||||||
|
else if (k == model->cfg_rows/4 - 1)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_BOT_SPLIT_L;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 3].type = HCLK_IO_BOT_UP_L;
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + 4].type = HCLK_MCB;
|
||||||
|
}
|
||||||
|
|
||||||
|
model->tiles[(model->center_y-3)*tile_columns].type = IO_PCI_L;
|
||||||
|
model->tiles[(model->center_y-2)*tile_columns].type = IO_PCI_CONN_L;
|
||||||
|
model->tiles[(model->center_y-1)*tile_columns].type = IO_PCI_CONN_L;
|
||||||
|
model->tiles[model->center_y*tile_columns].type = REG_L;
|
||||||
|
model->tiles[(model->center_y+1)*tile_columns].type = IO_RDY_L;
|
||||||
|
|
||||||
|
model->tiles[model->center_y*tile_columns + 1].type = REGH_IO_TERM_L;
|
||||||
|
|
||||||
|
model->tiles[tile_columns + 2].type = CORNER_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + 2].type = CORNER_TERM_B;
|
||||||
|
model->tiles[model->center_y*tile_columns + 2].type = REGH_ROUTING_IO_L;
|
||||||
|
|
||||||
|
model->tiles[tile_columns + 3].type = ROUTING_IO_PCI_CE_L;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + 3].type = ROUTING_IO_PCI_CE_L;
|
||||||
|
model->tiles[model->center_y*tile_columns + 3].type = REGH_IO_L;
|
||||||
|
model->tiles[model->center_y*tile_columns + 4].type = REGH_MCB;
|
||||||
|
|
||||||
|
//
|
||||||
|
// right IO
|
||||||
|
//
|
||||||
|
|
||||||
|
for (k = model->cfg_rows-1; k >= 0; k--) {
|
||||||
|
row_top_y = 2 /* top IO tiles */ + (model->cfg_rows-1-k)*(8+1/*middle of row clock*/+8);
|
||||||
|
if (k<(model->cfg_rows/2)) row_top_y++; // middle system tiles
|
||||||
|
|
||||||
|
for (l = 0; l < 16; l++) {
|
||||||
|
//
|
||||||
|
// -1
|
||||||
|
//
|
||||||
|
if (model->cfg_right_wiring[(model->cfg_rows-1-k)*16+l] == 'W')
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 1].flags |= TF_WIRED;
|
||||||
|
|
||||||
|
if (k == model->cfg_rows/2 && l == 13)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 1].type = IO_RDY_R;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 14)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 1].type = IO_PCI_CONN_R;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 1].type = IO_PCI_CONN_R;
|
||||||
|
else if (k == model->cfg_rows/2-1 && !l)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + tile_columns - 1].type = IO_PCI_R;
|
||||||
|
else {
|
||||||
|
if (model->cfg_right_wiring[(model->cfg_rows-1-k)*16+l] == 'W')
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 1].type = IO_R;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// -2
|
||||||
|
//
|
||||||
|
if ((k == model->cfg_rows-1 && (!l || l == 1)) || (!k && (l==15 || l==14)))
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 2].type = CORNER_TERM_R;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 12)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 2].type = IO_TERM_R_UPPER_TOP;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 13)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 2].type = IO_TERM_R_UPPER_BOT;
|
||||||
|
else if (k == (model->cfg_rows/2)-1 && !l)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + tile_columns - 2].type = IO_TERM_R_LOWER_TOP;
|
||||||
|
else if (k == (model->cfg_rows/2)-1 && l == 1)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + tile_columns - 2].type = IO_TERM_R_LOWER_BOT;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 2].type = IO_TERM_R;
|
||||||
|
//
|
||||||
|
// -3
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -4
|
||||||
|
//
|
||||||
|
if (model->cfg_right_wiring[(model->cfg_rows-1-k)*16+l] == 'W')
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 4].type = ROUTING_IO_VIA_R;
|
||||||
|
else {
|
||||||
|
if (k == model->cfg_rows-1 && l == 0)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + tile_columns - 4].type = CORNER_TR_UPPER;
|
||||||
|
else if (k == model->cfg_rows-1 && l == 1)
|
||||||
|
model->tiles[(row_top_y+l)*tile_columns + tile_columns - 4].type = CORNER_TR_LOWER;
|
||||||
|
else if (k && k != model->cfg_rows/2 && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 4].type = ROUTING_VIA_CARRY;
|
||||||
|
else if (!k && l == 14)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 4].type = CORNER_BR_UPPER;
|
||||||
|
else if (!k && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 4].type = CORNER_BR_LOWER;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 4].type = ROUTING_VIA;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// -5
|
||||||
|
//
|
||||||
|
if (model->cfg_right_wiring[(model->cfg_rows-1-k)*16+l] == 'W')
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 5].type = IO_ROUTING;
|
||||||
|
else {
|
||||||
|
if (k && k != model->cfg_rows/2 && l == 15)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 5].type = ROUTING_BRK;
|
||||||
|
else if (k == model->cfg_rows/2 && l == 14)
|
||||||
|
model->tiles[(row_top_y+l+1)*tile_columns + tile_columns - 5].type = ROUTING_GCLK;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+(l<8?l:l+1))*tile_columns + tile_columns - 5].type = ROUTING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 2].type = HCLK_TERM_R;
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 3].type = HCLK_MCB;
|
||||||
|
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 5].type = HCLK_ROUTING_IO_R;
|
||||||
|
if (k >= model->cfg_rows/2) { // top half
|
||||||
|
if (k > (model->cfg_rows*3)/4)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_TOP_UP_R;
|
||||||
|
else if (k == (model->cfg_rows*3)/4)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_TOP_SPLIT_R;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_TOP_DN_R;
|
||||||
|
} else { // bottom half
|
||||||
|
if (k < model->cfg_rows/4 - 1)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_BOT_DN_R;
|
||||||
|
else if (k == model->cfg_rows/4 - 1)
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_BOT_SPLIT_R;
|
||||||
|
else
|
||||||
|
model->tiles[(row_top_y+8)*tile_columns + tile_columns - 4].type = HCLK_IO_BOT_UP_R;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model->tiles[tile_columns + tile_columns - 5].type = CORNER_TERM_T;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + tile_columns - 5].type = CORNER_TERM_B;
|
||||||
|
model->tiles[tile_columns + tile_columns - 4].type = ROUTING_IO_PCI_CE_R;
|
||||||
|
model->tiles[(tile_rows-2)*tile_columns + tile_columns - 4].type = ROUTING_IO_PCI_CE_R;
|
||||||
|
model->tiles[model->center_y*tile_columns + tile_columns - 1].type = REG_R;
|
||||||
|
model->tiles[model->center_y*tile_columns + tile_columns - 2].type = REGH_IO_TERM_R;
|
||||||
|
model->tiles[model->center_y*tile_columns + tile_columns - 3].type = REGH_MCB;
|
||||||
|
model->tiles[model->center_y*tile_columns + tile_columns - 4].type = REGH_IO_R;
|
||||||
|
model->tiles[model->center_y*tile_columns + tile_columns - 5].type = REGH_ROUTING_IO_R;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user