minor lut work
This commit is contained in:
parent
581c8515a2
commit
650eccb454
|
@ -350,10 +350,10 @@ static int bitpos_is_set(struct extract_state* es, int y, int x,
|
|||
start_in_frame = row_pos*64;
|
||||
|
||||
if (swpos->minor == 20) {
|
||||
two_bits_val = (get_bit(es->bits, row_num, es->model->x_major[x],
|
||||
20, start_in_frame + swpos->two_bits_o) << 1)
|
||||
| (get_bit(es->bits, row_num, es->model->x_major[x],
|
||||
20, start_in_frame + swpos->two_bits_o+1) << 2);
|
||||
two_bits_val = ((get_bit(es->bits, row_num, es->model->x_major[x],
|
||||
20, start_in_frame + swpos->two_bits_o) != 0) << 0)
|
||||
| ((get_bit(es->bits, row_num, es->model->x_major[x],
|
||||
20, start_in_frame + swpos->two_bits_o+1) != 0) << 1);
|
||||
if (two_bits_val != swpos->two_bits_val)
|
||||
return 0;
|
||||
|
||||
|
@ -362,10 +362,10 @@ static int bitpos_is_set(struct extract_state* es, int y, int x,
|
|||
return 0;
|
||||
} else {
|
||||
two_bits_val =
|
||||
(get_bit(es->bits, row_num, es->model->x_major[x], swpos->minor,
|
||||
start_in_frame + swpos->two_bits_o/2) << 1)
|
||||
| (get_bit(es->bits, row_num, es->model->x_major[x], swpos->minor+1,
|
||||
start_in_frame + swpos->two_bits_o/2) << 2);
|
||||
((get_bit(es->bits, row_num, es->model->x_major[x], swpos->minor,
|
||||
start_in_frame + swpos->two_bits_o/2) != 0) << 1)
|
||||
| ((get_bit(es->bits, row_num, es->model->x_major[x], swpos->minor+1,
|
||||
start_in_frame + swpos->two_bits_o/2) != 0) << 0);
|
||||
if (two_bits_val != swpos->two_bits_val)
|
||||
return 0;
|
||||
|
||||
|
@ -646,17 +646,21 @@ fail:
|
|||
|
||||
static int write_logic(struct fpga_bits* bits, struct fpga_model* model)
|
||||
{
|
||||
int dev_idx, row, row_pos, rc;
|
||||
int dev_idx, row, row_pos, xm_col, rc;
|
||||
int x, y, byte_off;
|
||||
struct fpga_device* dev;
|
||||
uint64_t u64;
|
||||
uint8_t* u8_p;
|
||||
|
||||
for (x = LEFT_SIDE_WIDTH; x < model->x_width-RIGHT_SIDE_WIDTH; x++) {
|
||||
if (!is_atx(X_FABRIC_LOGIC_COL|X_CENTER_LOGIC_COL, model, x))
|
||||
xm_col = is_atx(X_FABRIC_LOGIC_XM_COL, model, x);
|
||||
if (!xm_col && !is_atx(X_FABRIC_LOGIC_XL_COL, model, x))
|
||||
continue;
|
||||
|
||||
for (y = TOP_IO_TILES; y < model->y_height - BOT_IO_TILES; y++) {
|
||||
if (!has_device_type(model, y, x, DEV_LOGIC, LOGIC_M))
|
||||
if (!has_device(model, y, x, DEV_LOGIC))
|
||||
continue;
|
||||
|
||||
row = which_row(y, model);
|
||||
row_pos = pos_in_row(y, model);
|
||||
if (row == -1 || row_pos == -1 || row_pos == 8) {
|
||||
|
@ -668,13 +672,59 @@ static int write_logic(struct fpga_bits* bits, struct fpga_model* model)
|
|||
byte_off = row_pos * 8;
|
||||
if (row_pos >= 8) byte_off += HCLK_BYTES;
|
||||
|
||||
// X device
|
||||
dev_idx = fpga_dev_idx(model, y, x, DEV_LOGIC, DEV_LOGX);
|
||||
if (dev_idx == NO_DEV) FAIL(EINVAL);
|
||||
dev = FPGA_DEV(model, y, x, dev_idx);
|
||||
if (!dev->instantiated)
|
||||
continue;
|
||||
printf("y%02i x%02i major %i byte_off %i\n", y, x, model->x_major[x], byte_off);
|
||||
if (xm_col) {
|
||||
// X device
|
||||
dev_idx = fpga_dev_idx(model, y, x, DEV_LOGIC, DEV_LOGX);
|
||||
if (dev_idx == NO_DEV) FAIL(EINVAL);
|
||||
dev = FPGA_DEV(model, y, x, dev_idx);
|
||||
if (dev->instantiated) {
|
||||
u64 = 0x000000B000600086ULL;
|
||||
frame_set_u64(u8_p + 26*FRAME_SIZE + byte_off, u64);
|
||||
|
||||
if (dev->u.logic.a2d[LUT_A].lut6
|
||||
&& dev->u.logic.a2d[LUT_A].lut6[0]) {
|
||||
HERE(); // not supported
|
||||
}
|
||||
if (dev->u.logic.a2d[LUT_B].lut6
|
||||
&& dev->u.logic.a2d[LUT_B].lut6[0]) {
|
||||
HERE(); // not supported
|
||||
}
|
||||
if (dev->u.logic.a2d[LUT_C].lut6
|
||||
&& dev->u.logic.a2d[LUT_C].lut6[0]) {
|
||||
HERE(); // not supported
|
||||
}
|
||||
if (dev->u.logic.a2d[LUT_D].lut6
|
||||
&& dev->u.logic.a2d[LUT_D].lut6[0]) {
|
||||
rc = parse_boolexpr(dev->u.logic.a2d[LUT_D].lut6, &u64);
|
||||
if (rc) FAIL(rc);
|
||||
write_lut64(u8_p + 29*FRAME_SIZE, byte_off*8, u64);
|
||||
}
|
||||
}
|
||||
|
||||
// M device
|
||||
dev_idx = fpga_dev_idx(model, y, x, DEV_LOGIC, DEV_LOGM);
|
||||
if (dev_idx == NO_DEV) FAIL(EINVAL);
|
||||
dev = FPGA_DEV(model, y, x, dev_idx);
|
||||
if (dev->instantiated) {
|
||||
HERE();
|
||||
}
|
||||
} else {
|
||||
// X device
|
||||
dev_idx = fpga_dev_idx(model, y, x, DEV_LOGIC, DEV_LOGX);
|
||||
if (dev_idx == NO_DEV) FAIL(EINVAL);
|
||||
dev = FPGA_DEV(model, y, x, dev_idx);
|
||||
if (dev->instantiated) {
|
||||
HERE();
|
||||
}
|
||||
|
||||
// L device
|
||||
dev_idx = fpga_dev_idx(model, y, x, DEV_LOGIC, DEV_LOGL);
|
||||
if (dev_idx == NO_DEV) FAIL(EINVAL);
|
||||
dev = FPGA_DEV(model, y, x, dev_idx);
|
||||
if (dev->instantiated) {
|
||||
HERE();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -177,7 +177,7 @@ fail:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int parse_boolexpr(const char* expr, uint64_t* lut)
|
||||
int parse_boolexpr(const char* expr, uint64_t* lut)
|
||||
{
|
||||
int i, j, result, vars[6];
|
||||
|
||||
|
@ -533,6 +533,40 @@ uint64_t frame_get_u64(uint8_t* frame_d)
|
|||
return (high_w << 32) | low_w;
|
||||
}
|
||||
|
||||
void frame_set_u8(uint8_t* frame_d, uint8_t v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 8; i++)
|
||||
if (v & (1<<(7-i))) (*frame_d) |= 1<<i;
|
||||
}
|
||||
|
||||
void frame_set_u16(uint8_t* frame_d, uint16_t v)
|
||||
{
|
||||
uint16_t high_b, low_b;
|
||||
high_b = v >> 8;
|
||||
low_b = v & 0xFF;
|
||||
frame_set_u8(frame_d, high_b);
|
||||
frame_set_u8(frame_d+1, low_b);
|
||||
}
|
||||
|
||||
void frame_set_u32(uint8_t* frame_d, uint32_t v)
|
||||
{
|
||||
uint32_t high_w, low_w;
|
||||
high_w = v >> 16;
|
||||
low_w = v & 0xFFFF;
|
||||
frame_set_u16(frame_d, low_w);
|
||||
frame_set_u16(frame_d+2, high_w);
|
||||
}
|
||||
|
||||
void frame_set_u64(uint8_t* frame_d, uint64_t v)
|
||||
{
|
||||
uint32_t high_w, low_w;
|
||||
low_w = v & 0xFFFFFFFF;
|
||||
high_w = v >> 32;
|
||||
frame_set_u32(frame_d, low_w);
|
||||
frame_set_u32(frame_d+4, high_w);
|
||||
}
|
||||
|
||||
int printf_frames(uint8_t* bits, int max_frames,
|
||||
int row, int major, int minor, int print_empty)
|
||||
{
|
||||
|
@ -639,6 +673,22 @@ uint64_t read_lut64(uint8_t* two_minors, int off_in_frame)
|
|||
return lut64;
|
||||
}
|
||||
|
||||
void write_lut64(uint8_t* two_minors, int off_in_frame, uint64_t u64)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (u64 & (1LL << (i*4)))
|
||||
frame_set_bit(two_minors, off_in_frame+i*2);
|
||||
if (u64 & (1LL << (i*4+1)))
|
||||
frame_set_bit(two_minors, off_in_frame+(i*2)+1);
|
||||
if (u64 & (1LL << (i*4+2)))
|
||||
frame_set_bit(two_minors + FRAME_SIZE, off_in_frame+i*2);
|
||||
if (u64 & (1LL << (i*4+3)))
|
||||
frame_set_bit(two_minors + FRAME_SIZE, off_in_frame+(i*2)+1);
|
||||
}
|
||||
}
|
||||
|
||||
int get_vm_mb(void)
|
||||
{
|
||||
FILE* statusf = fopen("/proc/self/status", "r");
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct _cfg_atom
|
|||
int atom_found(char* bits, const cfg_atom_t* atom);
|
||||
void atom_remove(char* bits, const cfg_atom_t* atom);
|
||||
|
||||
int parse_boolexpr(const char* expr, uint64_t* lut);
|
||||
void printf_lut6(const char* cfg);
|
||||
// bits is tested only for 32 and 64
|
||||
const char* lut2bool(const uint64_t lut, int bits,
|
||||
|
@ -77,6 +78,11 @@ uint16_t frame_get_u16(uint8_t* frame_d);
|
|||
uint32_t frame_get_u32(uint8_t* frame_d);
|
||||
uint64_t frame_get_u64(uint8_t* frame_d);
|
||||
|
||||
void frame_set_u8(uint8_t* frame_d, uint8_t v);
|
||||
void frame_set_u16(uint8_t* frame_d, uint16_t v);
|
||||
void frame_set_u32(uint8_t* frame_d, uint32_t v);
|
||||
void frame_set_u64(uint8_t* frame_d, uint64_t v);
|
||||
|
||||
// if row is negative, it's an absolute frame number and major and
|
||||
// minor are ignored
|
||||
int printf_frames(uint8_t* bits, int max_frames, int row, int major,
|
||||
|
@ -86,6 +92,7 @@ int clb_empty(uint8_t* maj_bits, int idx);
|
|||
void printf_extrabits(uint8_t* maj_bits, int start_minor, int num_minors,
|
||||
int start_bit, int num_bits, int row, int major);
|
||||
uint64_t read_lut64(uint8_t* two_minors, int off_in_frame);
|
||||
void write_lut64(uint8_t* two_minors, int off_in_frame, uint64_t u64);
|
||||
|
||||
int get_vm_mb(void);
|
||||
int get_random(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user