-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNW_route.v
executable file
·130 lines (100 loc) · 2.85 KB
/
NW_route.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* -------------------------------------------------------------------------------
* (C)2007 Robert Mullins
* Computer Architecture Group, Computer Laboratory
* University of Cambridge, UK.
* -------------------------------------------------------------------------------
*
* XY routing
*
* Routing Function
* ================
*
* Simple XY routing
* - Function updates flit with the output port required at next router
* and modifies displacement fields as head flit gets closer to
* destination.
*
* More complex routing algorithms may be implemented by making edits here
* and to the flit's control field defn.
*
* Valid Turn?
* ===========
*
* NW_route_valid_turn(from, to)
*
* This function is associated with the routing algorithm and is used to
* optimize the synthesis of the implementation by indicating impossible
* turns - hence superfluous logic.
*
* Valid Input VC
* ==============
*
* Does a particular input VC exist. e.g. Tile input port may only contain
* one VC buffer.
*
*/
function automatic bit NW_route_valid_input_vc;
input integer port;
input integer vc;
`include "parameters.v"
bit valid;
begin
valid=1'b1;
// if ((port==`TILE)&&(vc!=0)) valid=1'b0;
if (port==`TILE) begin
if (vc>=router_num_vcs_on_entry) valid=1'b0;
end
NW_route_valid_input_vc=valid;
end
endfunction // automatic
function automatic bit NW_route_valid_turn;
input output_port_t from;
input output_port_t to;
bit valid;
begin
valid=1'b1;
// flits don't leave on the same port as they entered
if (from==to) valid=1'b0;
`ifdef OPT_MESHXYTURNS
// Optimise turns for XY routing in a mesh
if (((from==`NORTH)||(from==`SOUTH))&&((to==`EAST)||(to==`WEST))) valid=1'b0;
`endif
NW_route_valid_turn=valid;
end
endfunction // bit
module NW_route (flit_in, flit_out, clk, rst_n);
input flit_t flit_in;
output flit_t flit_out;
input clk, rst_n;
function flit_t next_route;
input flit_t flit_in;
logic [4:0] route;
flit_t new_flit;
begin
new_flit=flit_in;
// Simple XY Routing
if (flit_in.control.x_disp!=0) begin
if (flit_in.control.x_disp>0) begin
route = `port5id_east;
new_flit.control.x_disp--;
end else begin
route = `port5id_west;
new_flit.control.x_disp++;
end
end else begin
if (flit_in.control.y_disp==0) begin
route=`port5id_tile;
end else if (flit_in.control.y_disp>0) begin
route=`port5id_south;
new_flit.control.y_disp--;
end else begin
route=`port5id_north;
new_flit.control.y_disp++;
end
end
new_flit.control.output_port = route;
next_route = new_flit;
end
endfunction // flit_t
assign flit_out=next_route(flit_in);
endmodule // route