Beispiel #1
0
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);
	rc = get_xc6_routing_bitpos(&model->sw_bitpos, &model->num_bitpos);
	if (rc) FAIL(rc);

	// 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) FAIL(rc);

	rc = init_devices(model);
	if (rc) FAIL(rc);

	if (s_high_speed_replicate) {
		rc = replicate_routing_switches(model);
		if (rc) FAIL(rc);
	}

	// todo: compare.ports only works if other switches and conns
	//       are disabled, as long as not all connections are supported
	rc = init_ports(model, /*dup_warn*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);

	rc = init_conns(model);
	if (rc) FAIL(rc);

	rc = init_switches(model, /*routing_sw*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);
	return 0;
fail:
	return rc;
}
Beispiel #2
0
int main(int  argc, char **  argv)
{
    int addr_server_port;
    struct timeval timeout;
    int i;
    int nb;
    char *ipaddress = 0;

    if (argc > 1) {
	if ((addr_server_port = atoi(argv[1])) == 0) {
	    fprintf(stderr, "addr_server: malformed port number.\n");
	    exit(2);
	}
	if (argc > 2) {
	    if (inet_addr((ipaddress = argv[2])) == INADDR_NONE) {
		fprintf(stderr, "addr_server: malformed ip address.\n");
		exit(3);
	    }
	}
    } else {
	fprintf(stderr, "addr_server: first arg must be port number.\n");
	exit(1);
    }
#if defined(LATTICE) && defined(AMITCP)
    init_conns();
#endif
    init_conn_sock(addr_server_port, ipaddress);
    while (1) {
	/*
	 * use finite timeout for robustness.
	 */
	timeout.tv_sec = 2;
	timeout.tv_usec = 0;
	/*
	 * clear selectmasks.
	 */
	FD_ZERO(&readmask);
	/*
	 * set new connection accept fd in readmask.
	 */
	FD_SET(conn_fd, &readmask);
	/*
	 * set active fds in readmask.
	 */
	for (i = 0; i < MAX_CONNS; i++) {
	    if (all_conns[i].state == CONN_OPEN)
		FD_SET(all_conns[i].fd, &readmask);
	}
#ifndef hpux
	nb = select(FD_SETSIZE, &readmask, (fd_set *) 0, (fd_set *) 0, &timeout);
#else
	nb = select(FD_SETSIZE, (int *) &readmask, (int *) 0, (int *) 0, &timeout);
#endif
	if (nb != 0)
	    aserv_process_io(nb);
	process_queue();
    }
    /* the following is to shut lint up */
    /*NOTREACHED*/
    return 0;			/* never reached */
}