1
1
`timescale 1ns / 1ps
2
2
3
+ // Module to control comunication with adjacent nodes
4
+
3
5
module dir_manager (
6
+ // synchronize with posedge of clk
4
7
input clk,
8
+ // active high reset
5
9
input reset,
10
+ // source port for current operation
6
11
input [2 :0 ] src,
12
+ // destination port for current operation
7
13
input [2 :0 ] dst,
14
+ // data incoming from node to the left
8
15
input signed [10 :0 ] left_in_data,
16
+ // is that incoming data valid
9
17
input left_in_valid,
18
+ // will this node be able to read the data this cycle
10
19
output left_in_ready,
11
20
input signed [10 :0 ] right_in_data,
12
21
input right_in_valid,
@@ -17,8 +26,11 @@ module dir_manager(
17
26
input signed [10 :0 ] down_in_data,
18
27
input down_in_valid,
19
28
output down_in_ready,
29
+ // data to send from this node to the node to the left
20
30
output signed [10 :0 ] left_out_data,
31
+ // is the output data valid this cycle
21
32
output left_out_valid,
33
+ // will the other node read the data this cycle
22
34
input left_out_ready,
23
35
output signed [10 :0 ] right_out_data,
24
36
output right_out_valid,
@@ -29,15 +41,23 @@ module dir_manager(
29
41
output signed [10 :0 ] down_out_data,
30
42
output down_out_valid,
31
43
input down_out_ready,
44
+ // clk_en goes low if this node needs to stall to wait for another node
45
+ // to read or write data
32
46
output clk_en,
47
+ // data read from another node as a source for an operation
33
48
output signed [10 :0 ] dir_src_data,
49
+ // data to write to another as the destination of an operation
34
50
input signed [10 :0 ] dir_dst_data
35
51
);
36
52
`include "my_params.vh"
37
53
54
+ // idle, or waiting to source data from another node
38
55
localparam STATE_SRC = 1'd0 ;
56
+ // waiting to write data to another node
39
57
localparam STATE_DST = 1'd1 ;
40
58
59
+ // does the targert source or destination port require communicating with
60
+ // another node?
41
61
function is_dir_target;
42
62
input [2 :0 ] target;
43
63
begin
@@ -46,19 +66,28 @@ module dir_manager(
46
66
end
47
67
endfunction
48
68
69
+ // the state of internode communication
49
70
reg state;
50
71
72
+ // does the current operation require input from another node
51
73
wire perform_in;
74
+ // does the current operation require output to another node
52
75
wire perform_out;
76
+ // register source data in case it needs to be buffered for a move operation
77
+ // between direction ports (ie. MOV UP DOWN)
53
78
reg signed [10 :0 ] dir_src_data_reg;
79
+ // use dir_src_data_reg instead of input dir_dst_data if performing move
80
+ // between direction ports (ie. MOV UP DOWN)
54
81
wire signed [10 :0 ] dir_dst_data_internal;
82
+ // the result choosing the source input from the different directions
55
83
wire signed [10 :0 ] dir_src_data_internal;
56
-
84
+ // when reading from another node, which direction should be selected
57
85
wire [2 :0 ] src_sel;
86
+ // is this module looking for an input from another node this cycle
58
87
wire src_waiting;
59
-
88
+ // does the current read operation need to wait for another node
60
89
wire stall_read;
61
-
90
+ // is the correct adjacent node ready to receive this node's write data
62
91
wire dst_available;
63
92
64
93
assign clk_en = (! stall_read && state == STATE_SRC && ! perform_out) || (state == STATE_DST && dst_available);
0 commit comments