Skip to content

Commit

Permalink
flit: Add some helper functions for XY routing
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti committed Nov 15, 2023
1 parent 3a1dfb3 commit 8bc026f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions util/floo_flit_pkg.sv.mako
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,30 @@ package floo_${name}_pkg;
localparam int unsigned YAddrOffset = ${routing['addr_offset_bits'] + routing['num_x_bits']};
typedef struct packed {
logic [NumXBits-1:0] x;
logic [NumYBits-1:0] y;
logic [NumXBits-1:0] x;
logic [NumYBits-1:0] y;
} xy_id_t;
function logic [NumXBits-1:0] get_x_coord(logic [${protocols[0].addr_width-1}:0] addr);
return addr[XAddrOffset +: NumXBits];
endfunction
function logic [NumYBits-1:0] get_y_coord(logic [${protocols[0].addr_width-1}:0] addr);
return addr[YAddrOffset +: NumYBits];
endfunction
function xy_id_t get_xy_id(logic [${protocols[0].addr_width-1}:0] addr);
xy_id_t id;
id.x = get_x_coord(addr);
id.y = get_y_coord(addr);
return id;
endfunction
function logic [${protocols[0].addr_width-1}:0] get_base_addr(xy_id_t id);
logic [${protocols[0].addr_width-1}:0] addr;
addr = id.x << XAddrOffset + id.y << YAddrOffset;
return addr;
endfunction
% elif routing['route_algo'] == 'IdTable':
typedef logic [${routing['num_id_bits']-1}:0] id_t;
% endif
Expand Down

0 comments on commit 8bc026f

Please sign in to comment.