window matcher WIP

* It looks like data output from host to device is not quite
pixel-perfect. I tried to select 444 RGB only and disable YCbCr 444/422,
but I'm not certain that worked since my laptop AMD GPU does not provide
adequate debugging facilities.

pattern sync depends on the x/y position of the pattern.

* Also, the windowing logic seems to be kind of bugged. It paints the
window only in the vsync interval *above* the window.
This commit is contained in:
jaseg 2021-06-24 19:23:00 +02:00
parent 7d47e2495b
commit 40301df014
7 changed files with 122 additions and 72 deletions

View file

@ -99,7 +99,6 @@
<FileInfo>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PPRDIR/src/window_matcher.v">

View file

@ -71,8 +71,8 @@ architecture Behavioral of edid_rom is
-- EISA ID -Serial
x"01",x"00",x"00",x"00",
-- Model/year
x"FF", x"11",
-- EDID Version
x"FF", x"1f",
-- EDID Versiondif
x"01", x"04",
------------------------------------
------------------------------------
@ -86,7 +86,7 @@ architecture Behavioral of edid_rom is
x"4f", x"00", x"78",
------------------------------------
-- Features
x"3E",
x"26",
-- Display x,y Chromaticity V Breaks here!
x"EE", x"91", x"a3", x"54", x"4c", x"99", x"26", x"0f", x"50", x"54",
-- Established timings
@ -154,21 +154,29 @@ architecture Behavioral of edid_rom is
-- Monitor name ASCII descriptor
x"00", x"00", x"00", x"FC", x"00",
-- ASCII name - "ABC LCD47w[lf] "
x"48", x"61", x"6D", x"73", x"74", x"65", x"72", x"6B",
x"73", x"0A", x"20", x"20", x"20",
x"74", x"61", x"63", x"68", x"69", x"62", x"61", x"6e",
x"61", x"0A", x"20", x"20", x"20",
----- End of EDID block
-- Extension flag & checksum
x"01", x"74",
x"01", x"95",
x"02", x"03", x"18", x"72", x"47", x"90", x"85", x"04", x"03", x"02", x"07", x"06", x"23", x"09", x"07", x"07",
x"83", x"01", x"00", x"00", x"65", x"03", x"0C", x"00", x"10", x"00", x"8E", x"0A", x"D0", x"8A", x"20", x"E0",
x"2d", x"10", x"10", x"3E", x"96", x"00", x"1F", x"09", x"00", x"00", x"00", x"18", x"8E", x"0A", x"D0", x"8A",
x"20", x"E0", x"2D", x"10", x"10", x"3E", x"96", x"00", x"04", x"03", x"00", x"00", x"00", x"18", x"8E", x"0A",
x"A0", x"14", x"51", x"F0", x"16", x"00", x"26", x"7C", x"43", x"00", x"1F", x"09", x"00", x"00", x"00", x"98",
x"8E", x"0A", x"A0", x"14", x"51", x"F0", x"16", x"00", x"26", x"7C", x"43", x"00", x"04", x"03", x"00", x"00",
x"00", x"98", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"C9"
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00"
-- x"02", x"03", x"18", x"72", x"47", x"90", x"85", x"04", x"03", x"02", x"07", x"06", x"23", x"09", x"07", x"07",
-- x"83", x"01", x"00", x"00", x"65", x"03", x"0C", x"00", x"10", x"00", x"8E", x"0A", x"D0", x"8A", x"20", x"E0",
-- x"2d", x"10", x"10", x"3E", x"96", x"00", x"1F", x"09", x"00", x"00", x"00", x"18", x"8E", x"0A", x"D0", x"8A",
-- x"20", x"E0", x"2D", x"10", x"10", x"3E", x"96", x"00", x"04", x"03", x"00", x"00", x"00", x"18", x"8E", x"0A",
-- x"A0", x"14", x"51", x"F0", x"16", x"00", x"26", x"7C", x"43", x"00", x"1F", x"09", x"00", x"00", x"00", x"98",
-- x"8E", x"0A", x"A0", x"14", x"51", x"F0", x"16", x"00", x"26", x"7C", x"43", x"00", x"04", x"03", x"00", x"00",
-- x"00", x"98", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00",
-- x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"00", x"C9"
);

View file

@ -164,7 +164,7 @@ architecture Behavioral of hdmi_design is
signal symbol_ch1 : std_logic_vector(9 downto 0);
signal symbol_ch2 : std_logic_vector(9 downto 0);
component pixel_processing is
component proc_top is
Port ( clk : in STD_LOGIC;
switches : in std_logic_vector(7 downto 0);
------------------
@ -188,13 +188,8 @@ architecture Behavioral of hdmi_design is
out_red : out std_logic_vector(7 downto 0);
out_green : out std_logic_vector(7 downto 0);
out_blue : out std_logic_vector(7 downto 0);
-------------------------------------
-- Audio samples for metering
-------------------------------------
audio_channel : in std_logic_vector(2 downto 0);
audio_de : in std_logic;
audio_sample : in std_logic_vector(23 downto 0)
debug : out std_logic_vector(5 downto 0)
);
end component;
@ -230,10 +225,15 @@ architecture Behavioral of hdmi_design is
signal audio_sample : std_logic_vector(23 downto 0);
signal debug : std_logic_vector(7 downto 0);
signal io_debug : std_logic_vector(7 downto 0);
signal proc_debug : std_logic_vector(5 downto 0);
begin
debug_pmod <= debug;
led <= debug;
debug(7 downto 6) <= io_debug(7 downto 6);
debug(5 downto 0) <= proc_debug;
i_hdmi_io: hdmi_io port map (
clk100 => clk100,
---------------------
@ -241,7 +241,7 @@ i_hdmi_io: hdmi_io port map (
---------------------
clock_locked => open,
data_synced => open,
debug => debug,
debug => io_debug,
---------------------
-- HDMI input signals
---------------------
@ -326,7 +326,9 @@ i_processing: proc_top Port map (
out_vsync => out_vsync,
out_red => out_red,
out_green => out_green,
out_blue => out_blue
out_blue => out_blue,
debug => proc_debug
);
-- Swap to this if you want to capture the HDMI symbols

View file

@ -342,7 +342,7 @@ architecture Behavioral of hdmi_io is
signal tmds_out_ch0 : std_logic;
signal tmds_out_ch1 : std_logic;
signal tmds_out_ch2 : std_logic;
signal detect_sr : std_logic_vector(7 downto 0) := (others => '0');
begin
pixel_clk <= pixel_clk_i;

View file

@ -16,6 +16,8 @@ module proc_top(
output [7:0] out_green,
output [7:0] out_blue,
output [5:0] debug,
input [7:0] switches
);
@ -24,7 +26,7 @@ module proc_top(
/* ================= */
/* Color bar generator */
/*
parameter CB_HRES = 1280;
parameter CB_VRES = 720;
parameter CB_H_FP = 68;
@ -50,13 +52,13 @@ assign out_green = cb_green;
assign out_blue = cb_blue;
always @(posedge clk) begin
cb_hsync <= in_hsync;
cb_vsync <= in_vsync;
cb_blank <= in_blank;
cb_red <= in_red;
cb_green <= in_green;
cb_blue <= in_blue;
/*
//cb_hsync <= in_hsync;
//cb_vsync <= in_vsync;
//cb_blank <= in_blank;
//cb_red <= in_red;
//cb_green <= in_green;
//cb_blue <= in_blue;
cb_x <= cb_x + 1;
cb_hsync <= cb_x >= 8 && cb_x <= 15;
@ -113,8 +115,8 @@ always @(posedge clk) begin
cb_green <= in_green;
cb_blue <= in_blue;
end
*/
end
*/
/* ================= */
/* END DEBUG END */
@ -183,6 +185,9 @@ wire [11:0] win_h;
wire out_data_en;
wire out_data_valid;
wire [23:0] out_data;
wire [7:0] matcher_debug;
assign debug = {matcher_debug[3:2], win_blank, win_locked, out_data_en, out_data_valid}; // win_hsync, win_vsync, win_blank, win_locked
/* term renderer */
wire [7:0] win_red;
@ -303,6 +308,7 @@ window_matcher window_matcher_i (
.rst(rst),
.bypass(bypass),
.debug(matcher_debug),
.in_blank(in_blank),
.in_hsync(in_hsync),
@ -326,12 +332,12 @@ window_matcher window_matcher_i (
.win_green(win_green),
.win_blue(win_blue),
.out_blank(), // out_blank),
.out_hsync(), //out_hsync),
.out_vsync(), //out_vsync),
.out_red(), //out_red),
.out_green(), //out_green),
.out_blue() //out_blue)
.out_blank(out_blank),
.out_hsync(out_hsync),
.out_vsync(out_vsync),
.out_red(out_red),
.out_green(out_green),
.out_blue(out_blue)
);
endmodule

View file

@ -46,10 +46,11 @@ module window_matcher(
/* Extracted data output */
output out_data_en,
output reg out_data_valid,
output [23:0] out_data
output [23:0] out_data,
output [7:0] debug
);
assign out_blank = ~out_hsync;
assign win_blank = ~win_hsync;
wire [23:0] in_pxd = {in_red, in_green, in_blue};
@ -69,11 +70,24 @@ module window_matcher(
in_pxd == MARKER_1,
in_pxd == MARKER_0
};
reg [3:0] in_pxd_match_dbg;
always @(posedge clk) begin
if (rst) begin
in_pxd_match_dbg <= 0;
end else begin
if (!in_blank) begin
in_pxd_match_dbg <= in_pxd_match_dbg | in_pxd_match;
end else begin
in_pxd_match_dbg <= 0;
end
end
end
assign debug = {in_pxd_match_dbg, win_hsync_int, win_vsync_int, 2'b00};
reg [3:0] in_pxd_match_sr [2:0];
wire in_pxd_pattern_match =
in_pxd_match[3] == 1
in_pxd_match[3] == 1
&& in_pxd_match_sr[2][0] == 1
&& in_pxd_match_sr[1][1] == 1
&& in_pxd_match_sr[0][2] == 1
@ -123,7 +137,7 @@ module window_matcher(
end
if (rst == 1 || !in_vsync) begin
if (rst || in_vsync) begin
matcher_state <= ST_MAT_WAITING;
win_w_int <= 0;
win_h_int <= 0;
@ -131,7 +145,13 @@ module window_matcher(
end
if (!rst) begin
if (in_vsync) begin
if (in_blank) begin
/* Reset state if the header is only partially contained in this frame */
if (matcher_state != ST_MAT_DATA) begin
matcher_state <= ST_MAT_WAITING;
end
end else begin
case (matcher_state)
ST_MAT_WAITING: begin
if (in_pxd_pattern_match) begin
@ -177,7 +197,7 @@ module window_matcher(
win_hsync_ctr_int <= win_hsync_ctr_int + 1;
end
if (win_hsync_ctr_int == win_w_int || in_hsync_reg == 0) begin
if (win_hsync_ctr_int == win_w_int || in_blank_reg == 0) begin
win_hsync_int <= 0;
out_data_valid <= 0;
win_hsync_ctr_int <= 0;
@ -207,10 +227,12 @@ module window_matcher(
reg [11:0] scan_x_reg [3:0];
reg in_hsync_reg;
reg in_vsync_reg;
reg in_blank_reg;
reg [23:0] in_pxd_reg;
assign out_hsync = in_hsync_reg;
assign out_vsync = in_vsync_reg;
assign out_blank = in_blank_reg;
always @(posedge clk) begin
if (rst == 1) begin
@ -222,11 +244,13 @@ module window_matcher(
scan_y <= 0;
in_hsync_reg <= 0;
in_vsync_reg <= 0;
in_blank_reg <= 0;
in_pxd_reg <= 0;
end else begin
in_hsync_reg <= in_hsync;
in_vsync_reg <= in_vsync;
in_blank_reg <= in_blank;
in_pxd_reg <= in_pxd;
scan_x_reg[0] <= scan_x;
scan_x_reg[1] <= scan_x_reg[0];

File diff suppressed because one or more lines are too long