-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecial_patch.v
76 lines (68 loc) · 1.71 KB
/
special_patch.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2021/12/05 01:12:59
// Design Name:
// Module Name: new_patch
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module special_patch (
input clk,
input en,
input [7:0] row_cnt,
input [8:0] col_cnt,
input [14:0] new_score,
input is_FAST,
input active,
input [14:0] worst_score,
input [6:0] worst_id,
input [239:0] ban_rows,
input [375:0] ban_cols,
output reg [6:0] renew_id
);
reg [7:0] center_y;
reg [8:0] center_x;
// 避开边界情况
wire not_border = row_cnt >= 8'd7 && row_cnt <= 8'd233 && col_cnt >= 9'd7 && col_cnt <= 9'd369;
reg active_reg; // 代表这个电路是否被启用了,被第一次active即为启用,通过上一个电路的wr_en信号传递即可
wire ban;
assign ban = ban_rows[row_cnt] == 1'b1 && ban_cols[col_cnt] == 1'b1 ? 1'b1 : 1'b0;
always @(posedge clk or negedge en) begin
if (!en) begin
active_reg <= 1'b0;
end
else begin
if (active) begin
active_reg <= 1'b1;
end
else begin
active_reg <= active_reg;
end
end
end
always @(*) begin
if((active_reg || active) && not_border) begin
if (is_FAST && new_score > worst_score) begin
renew_id = worst_id;
end
else begin
renew_id = 7'd100;
end
end
else begin
renew_id = 7'd100;
end
end
endmodule