Commit 73df8f12 authored by kazushi.kawamura's avatar kazushi.kawamura

upload basic router

parent f43fc911
TARGET = sim
OBJS = $(CPPS:.cpp=.o)
CPPS = $(wildcard *.cpp)
CXX = g++
CXXFLAGS = -O3 -DSOFTWARE
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) -o $@ $(OBJS)
clean:
rm *.o
rm $(TARGET)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "router.hpp"
int main(int argc, char *argv[]){
short int size_x = 10, size_y = 10;
short int line_num = 6;
short int board[10][10], board_str[100];
int x, y;
for(y = 0; y < size_y; y++) {
for(x = 0; x < size_x; x ++) {
board[y][x] = 0;
}
}
// Terminal cells (value > 0)
board[0][1] = 1;
board[7][1] = 1;
board[0][3] = 2;
board[8][4] = 2;
board[4][5] = 3;
board[6][5] = 3;
board[4][6] = 4;
board[7][2] = 4;
board[5][4] = 5;
board[6][6] = 5;
board[9][8] = 6;
board[9][9] = 6;
// Routing disenabled cells (value < 0)
board[0][0] = -1;
board[1][7] = -1;
board[1][8] = -1;
board[2][1] = -1;
board[2][7] = -1;
board[2][8] = -1;
board[3][1] = -1;
board[4][1] = -1;
board[5][1] = -1;
// Transform "board" to "board_str"
for(y = 0; y < size_y; y++) {
for(x = 0; x < size_x; x++) {
int idx = y * size_x + x;
board_str[idx] = board[y][x];
}
}
/** top function of router **/
// status = 1: OK
// status = 0: NG
int status = router(size_x, size_y, line_num, board_str);
/** top function of router (User can set "seed" value manually when calling this function.) **/
//int status = router(size_x, size_y, line_num, board_str, 1234567);
cout << "Router status: " << status << endl;
// Transform "board_str" to "board"
for(y = 0; y < size_y; y++) {
for(x = 0; x < size_x; x++) {
int idx = y * size_x + x;
board[y][x] = board_str[idx];
}
}
return 0;
}
This diff is collapsed.
#ifndef __ROUTER_HPP__
#define __ROUTER_HPP__
#include <iostream>
#ifdef SOFTWARE
#include "ap_int.h"
#else
#include <ap_int.h>
#endif
using namespace std;
#define ROUND_END 32768 // Max=65534(=2^16-2)
#define PRINT_BOARD
//#define PRINT_SEARCH // for router debug
#define MAX_LINES 256
#define MAX_PATH 128
#define MAX_CELLS 16384 // 128x128
#define PQ_BIT 12
#define MAX_PQ 4096
#define PRIO_BIT 16
#define DATA_BIT 16
#define ELEM_BIT 32 // ELEM_BIT = PRIO_BIT + DATA_BIT
#define DATA_MASK 65535 // 0000 FFFF
#define DATA_MAX 65535 // FFFF
#define PRIO_MAX 65535 // FFFF
/** top function (User can set "seed" value manually when calling this function.) **/
int router(short int size_x, short int size_y, short int line_num, short int board_str[], ap_uint<32> seed = 12345);
static ap_uint<32> lfsr;
void lfsr_random_init(ap_uint<32> seed);
ap_uint<32> lfsr_random();
ap_uint<PRIO_BIT> new_weight(ap_uint<16> x);
void search(short int size_x, short int size_y, short int *path_size, ap_uint<DATA_BIT> path[MAX_PATH], ap_uint<DATA_BIT> start, ap_uint<DATA_BIT> goal, ap_uint<PRIO_BIT> w[MAX_CELLS]);
void enqueue(ap_uint<ELEM_BIT> pq_nodes[MAX_PQ], ap_uint<PRIO_BIT> priority, ap_uint<DATA_BIT> data, ap_uint<PQ_BIT> *pq_len, bool *is_empty);
void dequeue(ap_uint<ELEM_BIT> pq_nodes[MAX_PQ], ap_uint<PRIO_BIT> *ret_priority, ap_uint<DATA_BIT> *ret_data, ap_uint<PQ_BIT> *pq_len, bool *is_empty);
#endif /* __ROUTER_HPP__ */
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