Commit 5164aff7 authored by kazushi.kawamura's avatar kazushi.kawamura

Update bitstream files, etc...

parent 54fff904
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
int main(void){ int main(void){
char q[STRLEN], command[STRLEN]; char q[STRLEN], command[STRLEN];
char dir[64] = "../router_01"; char dir[64] = "../router_02_boardstr";
FILE *fp; FILE *fp;
fp = fopen("q.txt", "r"); fp = fopen("q.txt", "r");
......
...@@ -12,6 +12,30 @@ ...@@ -12,6 +12,30 @@
#include "./router.hpp" #include "./router.hpp"
#ifdef USE_RANDOM_NUM
static ap_uint<32> lfsr;
void lfsr_random_init(ap_uint<32> seed) {
lfsr = seed;
}
ap_uint<32> lfsr_random() {
bool b_32 = lfsr.get_bit(32-32);
bool b_22 = lfsr.get_bit(32-22);
bool b_2 = lfsr.get_bit(32-2);
bool b_1 = lfsr.get_bit(32-1);
bool new_bit = b_32 ^ b_22 ^ b_2 ^ b_1;
lfsr = lfsr >> 1;
lfsr.set_bit(31, new_bit);
return lfsr.to_uint();
}
#endif
// Set weight // Set weight
ap_uint<8> new_weight(ap_uint<16> x) { ap_uint<8> new_weight(ap_uint<16> x) {
#pragma HLS INLINE #pragma HLS INLINE
...@@ -111,6 +135,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -111,6 +135,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
line_num++; line_num++;
} }
#ifdef USE_RANDOM_NUM
lfsr_random_init(seed);
#endif
// ================================ // ================================
// (Step.0) Initialization (END) // (Step.0) Initialization (END)
// ================================ // ================================
...@@ -167,6 +195,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -167,6 +195,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
ap_uint<LINE_BIT> target = line_num - 1, next_target; ap_uint<LINE_BIT> target = line_num - 1, next_target;
#ifdef USE_RANDOM_NUM
ap_uint<16> search_count = 0;
#endif
ROUTING: ROUTING:
for (ap_uint<16> round = 0; round < 32768 /* = (2048 * 16) */; round++) { for (ap_uint<16> round = 0; round < 32768 /* = (2048 * 16) */; round++) {
#pragma HLS LOOP_TRIPCOUNT min=1 max=32768 #pragma HLS LOOP_TRIPCOUNT min=1 max=32768
...@@ -190,6 +222,21 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -190,6 +222,21 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
s_idx[target] = pointer; continue; s_idx[target] = pointer; continue;
} }
#ifdef USE_RANDOM_NUM
// Skip routing (Constant probability)
if ((lfsr_random() % 4) < 1) {
ap_uint<BUFF_BIT> p = pointer;
TO_NEXT:
for (ap_uint<BUFF_BIT> j = s_idx[target]; j != s_idx[next_target]; j++) {
//#pragma HLS UNROLL factor=2
#pragma HLS LOOP_TRIPCOUNT min=1 max=256
paths[p] = paths[j];
p++;
}
s_idx[target] = pointer; pointer = p;
continue;
}
#endif
// (Step.2-1) Reset weights of target line // (Step.2-1) Reset weights of target line
WEIGHT_RESET: WEIGHT_RESET:
...@@ -200,7 +247,11 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -200,7 +247,11 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
} }
// (Step.2-2) Set weights of non-target lines and terminals // (Step.2-2) Set weights of non-target lines and terminals
#ifdef USE_RANDOM_NUM
ap_uint<8> current_round_weight = new_weight(search_count++);
#else
ap_uint<8> current_round_weight = new_weight(round); ap_uint<8> current_round_weight = new_weight(round);
#endif
WEIGHT_PATH: WEIGHT_PATH:
for (ap_uint<BUFF_BIT> j = s_idx[next_target]; j != pointer; j++) { for (ap_uint<BUFF_BIT> j = s_idx[next_target]; j != pointer; j++) {
#pragma HLS UNROLL factor=2 #pragma HLS UNROLL factor=2
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
//#define DEBUG_PRINT // for debug //#define DEBUG_PRINT // for debug
#define USE_RANDOM_NUM
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
using namespace std; using namespace std;
#endif #endif
...@@ -44,8 +46,14 @@ using namespace std; ...@@ -44,8 +46,14 @@ using namespace std;
#define MAX_WEIGHT 255 // Max weight #define MAX_WEIGHT 255 // Max weight
#define BOARDSTR_SIZE 41472 // Size of I/O #define BOARDSTR_SIZE 41472 // Size of I/O
#define PP 32 // Parameter for Parallel shifting in queue push #define PP 4 // Parameter for Parallel shifting in queue push
#define LOG_PP 5 // LOG_PP is log2(PP) #define LOG_PP 2 // LOG_PP is log2(PP)
#ifdef USE_RANDOM_NUM
// For random num generation
void lfsr_random_init(ap_uint<32> seed);
ap_uint<32> lfsr_random();
#endif
ap_uint<8> new_weight(ap_uint<16> x); ap_uint<8> new_weight(ap_uint<16> x);
bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status); bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status);
......
This diff is collapsed.
...@@ -12,6 +12,30 @@ ...@@ -12,6 +12,30 @@
#include "./router.hpp" #include "./router.hpp"
#ifdef USE_RANDOM_NUM
static ap_uint<32> lfsr;
void lfsr_random_init(ap_uint<32> seed) {
lfsr = seed;
}
ap_uint<32> lfsr_random() {
bool b_32 = lfsr.get_bit(32-32);
bool b_22 = lfsr.get_bit(32-22);
bool b_2 = lfsr.get_bit(32-2);
bool b_1 = lfsr.get_bit(32-1);
bool new_bit = b_32 ^ b_22 ^ b_2 ^ b_1;
lfsr = lfsr >> 1;
lfsr.set_bit(31, new_bit);
return lfsr.to_uint();
}
#endif
// Set weight // Set weight
ap_uint<8> new_weight(ap_uint<16> x) { ap_uint<8> new_weight(ap_uint<16> x) {
#pragma HLS INLINE #pragma HLS INLINE
...@@ -111,6 +135,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -111,6 +135,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
line_num++; line_num++;
} }
#ifdef USE_RANDOM_NUM
lfsr_random_init(seed);
#endif
// ================================ // ================================
// (Step.0) Initialization (END) // (Step.0) Initialization (END)
// ================================ // ================================
...@@ -166,6 +194,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -166,6 +194,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
ap_uint<LINE_BIT> target = line_num - 1, next_target; ap_uint<LINE_BIT> target = line_num - 1, next_target;
#ifdef USE_RANDOM_NUM
ap_uint<16> search_count = 0;
#endif
ROUTING: ROUTING:
for (ap_uint<16> round = 0; round < 32768 /* = (2048 * 16) */; round++) { for (ap_uint<16> round = 0; round < 32768 /* = (2048 * 16) */; round++) {
#pragma HLS LOOP_TRIPCOUNT min=1 max=32768 #pragma HLS LOOP_TRIPCOUNT min=1 max=32768
...@@ -189,6 +221,21 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -189,6 +221,21 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
s_idx[target] = pointer; continue; s_idx[target] = pointer; continue;
} }
#ifdef USE_RANDOM_NUM
// Skip routing (Constant probability)
if ((lfsr_random() % 4) < 1) {
ap_uint<BUFF_BIT> p = pointer;
TO_NEXT:
for (ap_uint<BUFF_BIT> j = s_idx[target]; j != s_idx[next_target]; j++) {
//#pragma HLS UNROLL factor=2
#pragma HLS LOOP_TRIPCOUNT min=1 max=256
paths[p] = paths[j];
p++;
}
s_idx[target] = pointer; pointer = p;
continue;
}
#endif
// (Step.2-1) Reset weights of target line // (Step.2-1) Reset weights of target line
WEIGHT_RESET: WEIGHT_RESET:
...@@ -199,7 +246,11 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ...@@ -199,7 +246,11 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE],
} }
// (Step.2-2) Set weights of non-target lines and terminals // (Step.2-2) Set weights of non-target lines and terminals
#ifdef USE_RANDOM_NUM
ap_uint<8> current_round_weight = new_weight(search_count++);
#else
ap_uint<8> current_round_weight = new_weight(round); ap_uint<8> current_round_weight = new_weight(round);
#endif
WEIGHT_PATH: WEIGHT_PATH:
for (ap_uint<BUFF_BIT> j = s_idx[next_target]; j != pointer; j++) { for (ap_uint<BUFF_BIT> j = s_idx[next_target]; j != pointer; j++) {
#pragma HLS UNROLL factor=2 #pragma HLS UNROLL factor=2
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
//#define DEBUG_PRINT // for debug //#define DEBUG_PRINT // for debug
#define USE_RANDOM_NUM
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
using namespace std; using namespace std;
#endif #endif
...@@ -44,6 +46,12 @@ using namespace std; ...@@ -44,6 +46,12 @@ using namespace std;
#define MAX_WEIGHT 255 // Max weight #define MAX_WEIGHT 255 // Max weight
#define BOARDSTR_SIZE 41472 // Size of I/O #define BOARDSTR_SIZE 41472 // Size of I/O
#ifdef USE_RANDOM_NUM
// For random num generation
void lfsr_random_init(ap_uint<32> seed);
ap_uint<32> lfsr_random();
#endif
ap_uint<8> new_weight(ap_uint<16> x); ap_uint<8> new_weight(ap_uint<16> x);
bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status); bool pynqrouter(char boardstr[BOARDSTR_SIZE], char boardstr_high[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment