ttl-fpga/sw/kousaten/src/fpga_cell_wire.c

49 lines
1.0 KiB
C
Raw Normal View History

2019-06-18 20:15:35 +02:00
#include "fpga_cell_wire.h"
#include <stdlib.h>
#include "fpga_global.h"
struct fpga_cell *fpga_cell_wire_new()
{
struct fpga_cell_wire *fpga_cell_wire;
fpga_cell_wire = malloc(sizeof(struct fpga_cell_wire));
return FPGA_TO_CELL(fpga_cell_wire);
}
struct fpga_cell *fpga_cell_wire_get_next_isp(struct fpga_cell *cell,
enum fpga_isp_channel *isp_channel)
{
switch (*isp_channel) {
case FPGA_ISP_CHANNEL_NORMAL:
switch (cell->type->identifier) {
case 'P':
return cell->cell_connections[RIGHT];
case ']':
*isp_channel = FPGA_ISP_CHANNEL_BACK;
return cell->cell_connections[LEFT];
default:
goto fail;
}
case FPGA_ISP_CHANNEL_BACK:
switch (cell->type->identifier) {
case 'P':
case '[':
*isp_channel = FPGA_ISP_CHANNEL_LFDN;
return cell->cell_connections[RIGHT];
}
2019-06-19 18:25:21 +02:00
default:
goto fail;
2019-06-18 20:15:35 +02:00
}
fail:
report(LL_ERROR,
"Entered wiring cell %c on invalid ISP channel %d.",
cell->type->identifier, *isp_channel);
*isp_channel = FPGA_ISP_CHANNEL_ERROR;
return NULL;
return NULL;
}