38 enum e_side from_side, to_side;
40 struct s_ivec ***switch_block_conn = NULL;
46 (nodes_per_chan - 1),
sizeof(
struct s_ivec));
48 for (from_side = (
enum e_side)0; from_side < 4; from_side = (
enum e_side)(from_side + 1)) {
49 for (to_side = (
enum e_side)0; to_side < 4; to_side = (
enum e_side)(to_side + 1)) {
50 for (from_track = 0; from_track < nodes_per_chan; from_track++) {
51 if (from_side != to_side) {
52 switch_block_conn[from_side][to_side][from_track].
nelem = 1;
53 switch_block_conn[from_side][to_side][from_track].
list =
56 switch_block_conn[from_side][to_side][from_track].
list[0] =
58 from_track, switch_block_type,
61 switch_block_conn[from_side][to_side][from_track].
nelem = 0;
62 switch_block_conn[from_side][to_side][from_track].
list =
73 out =
my_fopen(
"switch_block_conn.echo",
"w", 0);
74 for (l = 0; l < 4; ++l) {
75 for (k = 0; k < 4; ++k) {
76 fprintf(out,
"Side %d to %d\n", l, k);
77 for (j = 0; j < nodes_per_chan; ++j) {
78 fprintf(out,
"%d: ", j);
79 for (i = 0; i < switch_block_conn[l][k][j].
nelem; ++i) {
80 fprintf(out,
"%d ", switch_block_conn[l][k][j].
list[i]);
89 return switch_block_conn;
116 if (switch_block_type ==
SUBSET) {
117 to_track = from_track;
122 else if (switch_block_type ==
WILTON) {
124 if (from_side ==
LEFT) {
126 if (to_side ==
RIGHT) {
127 to_track = from_track;
128 }
else if (to_side ==
TOP) {
129 to_track = (nodes_per_chan - from_track) % nodes_per_chan;
130 }
else if (to_side ==
BOTTOM) {
131 to_track = (nodes_per_chan + from_track - 1) % nodes_per_chan;
135 else if (from_side ==
RIGHT) {
136 if (to_side ==
LEFT) {
137 to_track = from_track;
138 }
else if (to_side ==
TOP) {
139 to_track = (nodes_per_chan + from_track - 1) % nodes_per_chan;
140 }
else if (to_side ==
BOTTOM) {
141 to_track = (2 * nodes_per_chan - 2 - from_track)
146 else if (from_side ==
BOTTOM) {
147 if (to_side ==
TOP) {
148 to_track = from_track;
149 }
else if (to_side ==
LEFT) {
150 to_track = (from_track + 1) % nodes_per_chan;
151 }
else if (to_side ==
RIGHT) {
152 to_track = (2 * nodes_per_chan - 2 - from_track)
157 else if (from_side ==
TOP) {
159 to_track = from_track;
160 }
else if (to_side ==
LEFT) {
161 to_track = (nodes_per_chan - from_track) % nodes_per_chan;
162 }
else if (to_side ==
RIGHT) {
163 to_track = (from_track + 1) % nodes_per_chan;
169 else if (switch_block_type ==
UNIVERSAL) {
171 if (from_side ==
LEFT) {
173 if (to_side ==
RIGHT) {
174 to_track = from_track;
175 }
else if (to_side ==
TOP) {
176 to_track = nodes_per_chan - 1 - from_track;
177 }
else if (to_side ==
BOTTOM) {
178 to_track = from_track;
182 else if (from_side ==
RIGHT) {
183 if (to_side ==
LEFT) {
184 to_track = from_track;
185 }
else if (to_side ==
TOP) {
186 to_track = from_track;
187 }
else if (to_side ==
BOTTOM) {
188 to_track = nodes_per_chan - 1 - from_track;
192 else if (from_side ==
BOTTOM) {
193 if (to_side ==
TOP) {
194 to_track = from_track;
195 }
else if (to_side ==
LEFT) {
196 to_track = from_track;
197 }
else if (to_side ==
RIGHT) {
198 to_track = nodes_per_chan - 1 - from_track;
202 else if (from_side ==
TOP) {
204 to_track = from_track;
205 }
else if (to_side ==
LEFT) {
206 to_track = nodes_per_chan - 1 - from_track;
207 }
else if (to_side ==
RIGHT) {
208 to_track = from_track;
215 if (switch_block_type ==
FULL) {
216 to_track = from_track;
221 vpr_printf(TIO_MESSAGE_ERROR,
"in get_simple_switch_block_track.\n");
222 vpr_printf(TIO_MESSAGE_ERROR,
"\tUnexpected connection from_side: %d to_side: %d switch_block_type: %d.\n",
223 from_side, to_side, switch_block_type);
FILE * my_fopen(const char *fname, const char *flag, int prompt)
int get_simple_switch_block_track(INP enum e_side from_side, INP enum e_side to_side, INP int from_track, INP enum e_switch_block_type switch_block_type, INP int nodes_per_chan)
boolean getEchoEnabled(void)
struct s_ivec *** alloc_and_load_switch_block_conn(INP int nodes_per_chan, INP enum e_switch_block_type switch_block_type, INP int Fs)
static void * my_malloc(int ibytes)
void free_switch_block_conn(struct s_ivec ***switch_block_conn, int nodes_per_chan)
void *** alloc_matrix3(int nrmin, int nrmax, int ncmin, int ncmax, int ndmin, int ndmax, size_t elsize)
void free_ivec_matrix3(struct s_ivec ***ivec_matrix3, int nrmin, int nrmax, int ncmin, int ncmax, int ndmin, int ndmax)