This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
genvar n; | |
generate | |
for (n=0; n<NumNodes; n=n+1) | |
begin: GEN_NODES | |
Node #( | |
.NodeID ( n ), | |
.NumNodes ( NumNodes ), | |
.L2NumNodes ( L2NumNodes ), | |
.DistVecWidth ( DistVecWidth ), | |
.DistMatrixPkdWidth ( DistMatrixPkdWidth ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
always@(*) | |
begin : REPORT_DIST_VECTOR | |
integer r,c; | |
dist_vec_o = {DistVecWidth{1'b1}}; | |
for (c=0; c<NumNodes; c=c+1) begin | |
for (r=0; r<NumNodes; r=r+1) begin | |
if (dist_matrix_lcl[r][`NODE_SEL(c)] < dist_vec_o[`NODE_SEL(c)]) begin | |
dist_vec_o[`NODE_SEL(c)] = dist_matrix_lcl[r][`NODE_SEL(c)]; | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// macro to select a node's distance in a packed distance vector | |
`define NODE_SEL(node_num) (node_num)*L2NumNodes +: L2NumNodes | |
module Node #( | |
parameter NodeID = 0, // identifier for this node | |
parameter NumNodes = 10, // total number of nodes in graph | |
parameter L2NumNodes = Log2(NumNodes), // number of bits we need to store a node id | |
parameter DistVecWidth = NumNodes * L2NumNodes, // number of bits we need to store a dist vec | |
parameter DistMatrixPkdWidth = NumNodes * DistVecWidth // number of bits we need to store a dist matrix | |
)( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (r=0; r<NumNodes; r=r+1) begin | |
for (c=0; c<NumNodes; c=c+1) begin | |
if (r == NodeID) begin | |
// this is our row in the distance matrix. | |
// we use the adjacency vector to update the matrix. | |
if (c == NodeID) begin | |
// the distance from a node to itself is 0 | |
dist_matrix_lcl[r][`NODE_SEL(c)] <= 0; | |
end else if (adj_vec[c]) begin | |
// the distance from a node to its neighbor is 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GraphRadius #( | |
parameter NumNodes = 10, | |
parameter L2NumNodes = Log2(NumNodes), | |
parameter DistVecWidth = NumNodes * L2NumNodes, | |
parameter DistMatrixPkdWidth = NumNodes * DistVecWidth, | |
parameter CHARS_PER_LINE = 16, | |
parameter CYCLES_PER_IDLE = 375000, | |
parameter CYCLES_PER_CMD = 25000, | |
parameter CYCLE_ENA_ASSERT = 25, | |
parameter CYCLE_ENA_DEASSERT = 50 |