17 #define has_input_from_N(conn) (conn & 0b00000001)
18 #define has_input_from_E(conn) (conn & 0b00000010)
19 #define has_input_from_S(conn) (conn & 0b00000100)
20 #define has_input_from_W(conn) (conn & 0b00001000)
21 #define has_input_from_NW(conn) (conn & 0b00010000)
22 #define has_input_from_NE(conn) (conn & 0b00100000)
23 #define has_input_from_SE(conn) (conn & 0b01000000)
24 #define has_input_from_SW(conn) (conn & 0b10000000)
27 #define is_top_pe(r, c, rows, cols) (r == 0)
28 #define is_bot_pe(r, c, rows, cols) (r == rows-1)
29 #define is_leftmost_pe(r, c, rows, cols) (c == 0)
30 #define is_rightmost_pe(r, c, rows, cols) (c == cols-1)
33 #define mask_top_pe(conn) ((conn & 0b11001111) | 0b00000001) // Remove NE, NW connections, add N connection
34 #define mask_bot_pe(conn) ((conn & 0b00111111) | 0b00000100) // Remove SE, SW connections, add S connection
35 #define mask_leftmost_pe(conn) ((conn & 0b01101111) | 0b00001000) // Remove NW, SW connections, add W connection
36 #define mask_rightmost_pe(conn) ((conn & 0b10011111) | 0b00000010) // Remove NE, SE connections, add E connection
41 return (((val << 2) & 0x0f) | (val >> 2));
55 for(
int r = 0; r < rows; r++)
57 for(
int c = 0; c < cols; c++)
59 pcv[0][r][c] = pe_conn_orig;
65 lefthalf = (pe_conn_orig >> 4) & 0x0f;
66 righthalf = pe_conn_orig & 0x0f;
73 pe_conn_out = (lefthalf << 4) | righthalf;
76 for(
int r = 0; r < rows; r++)
78 for(
int c = 0; c < cols; c++)
80 pcv[1][r][c] = pe_conn_out;
85 for(
int r = 0; r < rows; r++)
87 for(
int c = 0; c < cols; c++)
132 const unsigned int cols = args.
getInt(
"cols");
133 const unsigned int rows = args.
getInt(
"rows");
134 const int contexts = args.
getInt(
"II");
135 const int fu_II = args.
getInt(
"fu_II");
136 const int pe_conn = args.
getInt(
"pe_conn");
137 const int fu_latency = args.
getInt(
"fu_latency");
138 const int eb_depth = args.
getInt(
"eb_depth");
139 const bool eb_enable = args.
getBool(
"eb_enable");
140 const int type = args.
getInt(
"type");
151 double moduleW = 1.0/(cols+2);
152 double moduleH = 1.0/(rows+2);
171 std::vector < std::vector < std::vector<int> > > pe_conn_vec(2, std::vector< std::vector<int> >(rows, std::vector<int>(cols)));
176 auto cgra_storage = std::make_unique<CGRA>();
177 Module* result = &cgra_storage->getTopLevelModule();
182 for (
unsigned int c = 0; c < cols; c++)
184 for(
unsigned int r = 0; r < rows; r++)
188 result->
addSubModule(
new RIKEN_PE_Elastic(
"pe_c" +
std::to_string(c) +
"_r" +
std::to_string(r), pe_conn_vec[0][r][c], pe_conn_vec[1][r][c], fu_II, fu_latency, loc, type, eb_depth, eb_enable, contexts), (c+1.0)*moduleW, (r+1.0)*moduleH, moduleW, moduleH);
193 for (
unsigned int c = 0; c < cols; c++)
195 Location loc_bot = {c + 1, rows + 1};
198 result->
addSubModule(
new IO(
"io_bottom_" +
std::to_string(c), loc_bot, SIZE, contexts, isElastic), c*moduleW, (rows+1.0)*moduleH, moduleW, moduleH);
202 for (
unsigned int r = 0; r < rows; r++)
206 result->
addSubModule(
new IO(
"io_left_" +
std::to_string(r), loc_l, SIZE, contexts, isElastic), (cols+1.0)*moduleW, (r+1.0)*moduleH, moduleW, moduleH);
207 result->
addSubModule(
new IO(
"io_right_" +
std::to_string(r), loc_r, SIZE, contexts, isElastic), (cols+1.0)*moduleW, (r+1.0)*moduleH, moduleW, moduleH);
211 for(
unsigned int c = 0; c < cols; c++)
213 for(
unsigned int r = 0; r < rows; r++)
218 std::string blk_n_c_r =
"pe_c" + currC +
"_r" + currR;
227 blk_n_c_r +
".in" + north, isElastic);
230 "io_top_" + currC +
".in", isElastic);
234 blk_n_c_r +
".in" + north, isElastic);
244 blk_n_c_r +
".in" + east, isElastic);
247 "io_right_" + currR +
".in", isElastic);
251 blk_n_c_r +
".in" + east, isElastic);
261 blk_n_c_r +
".in" + south, isElastic);
264 "io_bottom_" + currC +
".in", isElastic);
268 blk_n_c_r +
".in" + south, isElastic);
278 blk_n_c_r +
".in" + west, isElastic);
281 "io_left_" + currR +
".in", isElastic);
285 blk_n_c_r +
".in" + west, isElastic);
293 blk_n_c_r +
".in" + northWest, isElastic);
299 blk_n_c_r +
".in" + northEast, isElastic);
305 blk_n_c_r +
".in" + southEast, isElastic);
311 blk_n_c_r +
".in" + southWest, isElastic);