-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeed.sv
74 lines (67 loc) · 1.69 KB
/
feed.sv
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
module feed(
input clock,
input reset,
input wire [143:0] input_data,
input wire input_valid,
output wire input_ready,
output wire [39:0] output_data,
output wire output_valid,
input wire output_ready,
output wire [4:0] count
);
logic [143:0] input_buffer;
logic input_buffer_valid;
logic solved;
logic [39:0] output_buffer;
logic output_buffer_valid;
logic [4:0] fifo_count;
logic [63:0] i_player;
logic [63:0] i_opponent;
logic [15:0] i_taskid;
logic [7:0] o_result;
logic [15:0] o_taskid;
logic [15:0] o_nodes;
logic fifo_ren;
logic fifo_wen;
assign {i_player, i_opponent, i_taskid} = input_buffer;
assign output_buffer = {o_result, o_taskid, o_nodes};
assign input_ready = !input_buffer_valid && fifo_count <= 8;
assign count = fifo_count;
always_ff@(posedge clock or posedge reset) begin
if (reset) begin
input_buffer_valid <= 1'b0;
input_buffer <= 144'hffffffffffffffffffffffffffffffffffff;
end else begin
if (input_ready && input_valid) begin
input_buffer_valid <= 1'b1;
input_buffer <= input_data;
end else if (solved) begin
input_buffer_valid <= 1'b0;
end
end
end
pipeline pipeline(
.iCLOCK(clock),
.valid(input_buffer_valid),
.enable(~reset),
.iPlayer(i_player),
.iOpponent(i_opponent),
.iTaskid(i_taskid),
.solved(solved),
.oTaskid(o_taskid),
.res(o_result),
.oNodes(o_nodes)
);
assign fifo_ren = output_ready && output_valid;
assign output_valid = fifo_count != 0;
assign fifo_wen = solved && o_taskid != 16'hffff;
fifo #(.width(40), .addr_bits(4)) o_fifo(
.clock(clock),
.reset(reset),
.ren(fifo_ren),
.rdata(output_data),
.wen(fifo_wen),
.wdata(output_buffer),
.count(fifo_count)
);
endmodule