diff --git a/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd b/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd index fa164e4..3d8d821 100644 --- a/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd +++ b/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd @@ -70,7 +70,8 @@ entity pixel_buffer_0 IS MAX_OP_WIDTH : natural range 1 to 48 := 48; SHIFT_DEPTH : integer range 1 to 1024 := 128; PX_DEPTH : integer range 2 to 1024 := 64; - FULL_MARGIN : integer range 2 to 1024 := 8 + FULL_MARGIN : integer range 2 to 1024 := 8; + EN_PEEK : boolean := false ); port ( @@ -106,10 +107,18 @@ entity pixel_buffer_0 IS sequencers_busy : out std_logic; fp_holdoff_update : in std_logic; wave_seq_len : in std_logic_vector(15 downto 0); + + -- Diagnostic port to peek into pixel buffers, available when EN_PEEK is true. + -- Must only be used when buffer idle (i.e. no fire_req pulses) else output data + -- could be corrupted, although internal state and buffer values remain correct. + diag_peek_sel : in std_logic := '0'; + diag_peek_addr : in std_logic_vector(31 downto 0) := (others => '0'); + diag_peek_data : out std_logic_vector(31 downto 0); + diag_peek_rdptr : out std_logic_vector( 7 downto 0); ip_id_ip_number : out std_logic_vector( 7 downto 0) := 8x"1c"; ip_id_mfr_number : out std_logic_vector( 7 downto 0) := 8x"00"; - ip_ver_minor_number : out std_logic_vector( 7 downto 0) := 8x"01"; + ip_ver_minor_number : out std_logic_vector( 7 downto 0) := 8x"02"; ip_ver_major_number : out std_logic_vector( 7 downto 0) := 8x"00"; diag_word_count : out std_logic_vector(6 downto 0) @@ -124,9 +133,12 @@ architecture rtl of pixel_buffer_0 is constant FULL_THRESHOLD : integer := PX_DEPTH-FULL_MARGIN; subtype OP_WIDTH_RANGE is natural range 1 to MAX_OP_WIDTH; + + type diag_array_t is array (natural range <> ) of std_logic_vector; signal wr_ptr : std_logic_vector(PX_DEPTH_LOG2 downto 0); signal rd_ptr : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal rd_ptr_int : std_logic_vector(PX_DEPTH_LOG2 downto 0); signal rd_ptr_start : std_logic_vector(PX_DEPTH_LOG2 downto 0); signal wr_ptr_start : std_logic_vector(PX_DEPTH_LOG2 downto 0); signal wr_ptr_plus1 : std_logic_vector(PX_DEPTH_LOG2 downto 0); @@ -153,6 +165,9 @@ architecture rtl of pixel_buffer_0 is signal data_int : std_logic_vector(32 downto 0); signal writing_first_stripe : std_logic; + signal diag_peek_data_int : diag_array_t(0 to MAX_OP_WIDTH-1)(PX_WIDTH-1 downto 0); + signal is_en_peek : std_logic; + begin -- pragma translate_off @@ -172,7 +187,7 @@ begin ( clock => clk, data => data_int, - rdaddress => rd_ptr(PX_DEPTH_LOG2-1 downto 0), + rdaddress => rd_ptr_int(PX_DEPTH_LOG2-1 downto 0), wraddress => wr_ptr(PX_DEPTH_LOG2-1 downto 0), wren => wren(i), q => q((i+1)*PX_WIDTH-1 downto i*PX_WIDTH) @@ -207,6 +222,19 @@ begin fire_drop_detect <= '1' when fire_req = '1' and sequencers_busy = '1' else '0'; diag_word_count <= word_count(diag_word_count'left downto 0); + + -- If pixel buffer peeking enabled, then mux the read pointer + -- to the buffers with diag address + GENPK : if EN_PEEK generate + is_en_peek <= '1'; + rd_ptr_int <= rd_ptr when diag_peek_sel = '0' else "0" & diag_peek_addr(PX_DEPTH_LOG2-1 downto 0); + end generate; + + -- When no buffer peeking, use only the calculatrated read address + GENNOPL : if not EN_PEEK generate + is_en_peek <= '0'; + rd_ptr_int <= rd_ptr; + end generate; PX_BUF_CTRL : process(rst_n, clk) is variable op_width : OP_WIDTH_RANGE; @@ -284,11 +312,24 @@ begin end if; end if; + -- If pixel buffer peeking diags enabled, export the read pointer + if is_en_peek then + diag_peek_rdptr <= rd_ptr(7 downto 0); + else + diag_peek_rdptr <= (others => '0'); + end if; + -- Increment the read pointer for each read request if rdreq = '1' and error = '0' then rd_ptr <= std_logic_vector(unsigned(rd_ptr) + 1); end if; + for i in 0 to MAX_OP_WIDTH-1 loop + if is_en_peek = '1' and i = unsigned(diag_peek_addr(log2(MAX_OP_WIDTH)-1+PX_DEPTH_LOG2 downto PX_DEPTH_LOG2)) then + diag_peek_data <= q((i+1)*PX_WIDTH-2 downto i*PX_WIDTH); + end if; + end loop; + -- Update buffer input state when ever we get a strobe if wr_req_int = '1' and error = '0' then