diff --git a/demo/fpga/Artix-7-HDMI-processing.xpr b/demo/fpga/Artix-7-HDMI-processing.xpr
index c79fe0c..c880b4f 100644
--- a/demo/fpga/Artix-7-HDMI-processing.xpr
+++ b/demo/fpga/Artix-7-HDMI-processing.xpr
@@ -42,7 +42,7 @@
-
+
diff --git a/demo/fpga/src/window_matcher.v b/demo/fpga/src/window_matcher.v
index 9b85852..389485e 100644
--- a/demo/fpga/src/window_matcher.v
+++ b/demo/fpga/src/window_matcher.v
@@ -304,6 +304,33 @@ module window_matcher(
end
end
+ /* Border match locking process */
+ reg [11:0] border_w;
+ reg [11:0] border_h;
+ reg border_matched;
+
+ always @(posedge clk) begin
+ if (rst) begin
+ border_matched <= 0;
+ border_w <= 0;
+ border_h <= 0;
+
+ end else begin
+ if (in_vsync_reg == 0 && in_vsync == 1) begin
+ if (bstate == BSTATE_DONE) begin
+ border_matched <= 1;
+ border_w <= border_right - win_x - 1;
+ border_h <= border_bottom - win_y;
+
+ end else begin
+ border_matched <= 0;
+ border_w <= 0;
+ border_h <= 0;
+ end
+ end
+ end
+ end
+
/* Match locking process */
reg [11:0] win_x;
reg [11:0] win_y;
@@ -385,8 +412,6 @@ module window_matcher(
(in_pxd_unfucked & 24'hf0f0f0) == (FONT_FG_COLOR & 24'hf0f0f0);
reg [11:0] border_right;
reg [11:0] border_bottom;
- wire [11:0] border_w = border_right - win_x - 1;
- wire [11:0] border_h = border_bottom - win_y;
localparam BSTATE_WAITING = 15'b000000000000001, /* 0001 */
BSTATE_FIRST_LINE = 15'b000000000000010, /* 0002 */
diff --git a/demo/fpga/window_matcher_tb_behav.wcfg b/demo/fpga/window_matcher_tb_behav.wcfg
index 7913cef..5b3a7f3 100644
--- a/demo/fpga/window_matcher_tb_behav.wcfg
+++ b/demo/fpga/window_matcher_tb_behav.wcfg
@@ -1,247 +1,198 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- clk
- clk
-
-
- rst
- rst
-
-
- in_blank
- in_blank
-
-
- in_hsync
- in_hsync
-
-
- in_vsync
- in_vsync
-
-
- in_red[7:0]
- in_red[7:0]
-
-
- in_green[7:0]
- in_green[7:0]
-
-
- in_blue[7:0]
- in_blue[7:0]
-
-
- out_hsync
- out_hsync
-
-
- out_vsync
- out_vsync
-
-
- out_red[7:0]
- out_red[7:0]
-
-
- out_green[7:0]
- out_green[7:0]
-
-
- out_blue[7:0]
- out_blue[7:0]
-
-
- win_blank
- win_blank
-
-
- win_hactive
- win_hactive
-
-
- win_locked
- win_locked
-
-
- win_blank_exp
- win_blank_exp
-
-
- out_data_en
- out_data_en
- #FFA500
- true
-
-
- out_data_valid
- out_data_valid
- #FFA500
- true
-
-
- in_pxd[23:0]
- in_pxd[23:0]
-
-
- win_pxd[23:0]
- win_pxd[23:0]
-
-
- out_pxd[23:0]
- out_pxd[23:0]
-
-
- in_pxd_match[7:0]
- in_pxd_match[7:0]
-
-
- in_pxd_match_sr[6:0][7:0]
- in_pxd_match_sr[6:0][7:0]
-
-
- in_pxd_pattern_match
- in_pxd_pattern_match
-
-
- scan_x[11:0]
- scan_x[11:0]
- UNSIGNEDDECRADIX
-
-
- scan_y[11:0]
- scan_y[11:0]
- UNSIGNEDDECRADIX
-
-
- win_x[11:0]
- win_x[11:0]
- UNSIGNEDDECRADIX
-
-
- win_y[11:0]
- win_y[11:0]
- UNSIGNEDDECRADIX
-
-
- win_x_int[11:0]
- win_x_int[11:0]
- UNSIGNEDDECRADIX
-
-
- win_y_int[11:0]
- win_y_int[11:0]
- UNSIGNEDDECRADIX
-
-
- dval_x_reg[11:0]
- dval_x_reg[11:0]
- UNSIGNEDDECRADIX
-
-
- dval_y_reg[11:0]
- dval_y_reg[11:0]
- UNSIGNEDDECRADIX
-
-
- win_w_int[11:0]
- win_w_int[11:0]
- UNSIGNEDDECRADIX
-
-
- win_h_int[11:0]
- win_h_int[11:0]
- UNSIGNEDDECRADIX
-
-
- win_w[11:0]
- win_w[11:0]
- UNSIGNEDDECRADIX
-
-
- win_h[11:0]
- win_h[11:0]
- UNSIGNEDDECRADIX
-
-
- win_hsync_ctr[11:0]
- win_hsync_ctr[11:0]
- UNSIGNEDDECRADIX
-
-
- matcher_state[4:0]
- matcher_state[4:0]
-
-
- matched
- matched
-
-
- scan_x_reg[7:0][11:0]
- scan_x_reg[7:0][11:0]
-
-
- in_hsync_reg
- in_hsync_reg
-
-
- in_vsync_reg
- in_vsync_reg
-
-
- in_pxd_reg[23:0]
- in_pxd_reg[23:0]
-
-
- testcase_id[31:0]
- testcase_id[31:0]
- #FAAFBE
- true
- UNSIGNEDDECRADIX
-
-
- expected_data[23:0]
- expected_data[23:0]
- #FAAFBE
- true
-
-
- expected_data_last[23:0]
- expected_data_last[23:0]
- #FAAFBE
- true
-
-
- read_pos[31:0]
- read_pos[31:0]
- #FAAFBE
- true
-
-
- win_header
- win_header
- #FAAFBE
- true
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ clk
+ clk
+
+
+ rst
+ rst
+
+
+ in_blank
+ in_blank
+
+
+ in_hsync
+ in_hsync
+
+
+ in_vsync
+ in_vsync
+
+
+ in_hsync_reg
+ in_hsync_reg
+
+
+ in_vsync_reg
+ in_vsync_reg
+
+
+ win_blank
+ win_blank
+
+
+ win_hactive
+ win_hactive
+
+
+ win_locked
+ win_locked
+
+
+ out_data_en
+ out_data_en
+ #FFA500
+ true
+
+
+ out_data_valid
+ out_data_valid
+ #FFA500
+ true
+
+
+ in_pxd[23:0]
+ in_pxd[23:0]
+
+
+ out_pxd[23:0]
+ out_pxd[23:0]
+
+
+ in_pxd_unfucked[23:0]
+ in_pxd_unfucked[23:0]
+
+
+ in_pxd_pattern_match
+ in_pxd_pattern_match
+
+
+ scan_x[11:0]
+ scan_x[11:0]
+ UNSIGNEDDECRADIX
+
+
+ scan_y[11:0]
+ scan_y[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_x[11:0]
+ win_x[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_y[11:0]
+ win_y[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_w[11:0]
+ win_w[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_h[11:0]
+ win_h[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_x_int[11:0]
+ win_x_int[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_y_int[11:0]
+ win_y_int[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_w_int[11:0]
+ win_w_int[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_h_int[11:0]
+ win_h_int[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_right[11:0]
+ win_right[11:0]
+ UNSIGNEDDECRADIX
+
+
+ win_bottom[11:0]
+ win_bottom[11:0]
+ UNSIGNEDDECRADIX
+
+
+ matched
+ matched
+
+
+ testcase_id[31:0]
+ testcase_id[31:0]
+ #FAAFBE
+ true
+ UNSIGNEDDECRADIX
+
+
+ is_border_px
+ is_border_px
+
+
+ is_bg_px
+ is_bg_px
+
+
+ border_w[11:0]
+ border_w[11:0]
+ UNSIGNEDDECRADIX
+
+
+ border_h[11:0]
+ border_h[11:0]
+ UNSIGNEDDECRADIX
+
+
+ border_right[11:0]
+ border_right[11:0]
+ UNSIGNEDDECRADIX
+
+
+ border_bottom[11:0]
+ border_bottom[11:0]
+ UNSIGNEDDECRADIX
+
+
+ bstate[14:0]
+ bstate[14:0]
+
+
+ border_matched
+ border_matched
+
+