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 acc4658..5513cbc 100644 --- a/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd +++ b/generic_ip/pixel_buffer/0/src/pixel_buffer_0.vhd @@ -23,6 +23,7 @@ --! @li pixel_buf_rdy : Ready status output towards print streamer --! @li data : pixel data from print streamer --! @li last_word : Flag input indicating data is the last word of an image's stripes +--! @li all_on : ALL ON mode input --! @li wrreq : buffer write request from print streamer --! @li q : pixel read data to GL remapper --! @li rdreq : pixel read request from GL remapper @@ -42,6 +43,7 @@ --! @li sequencers_busy : Status output indicating sequences busy with respect to accepting a new fire pulse --! @li fp_holdoff_update : Strobe input to indicate valid holdoff data (wave sequence length) --! @li wave_seq_len : Wave sequence length input, in clock cycles for fire request holdoff +--! @li diag_peek_* : Diagnostic buffer read and write peek and poke interface (enabled on EN_PEEK generic --! @li ip_id_ip_number : Module's ID number --! @li ip_id_mfr_number : Module's manufacture number --! @li ip_ver_minor_number : Module's Minor version number @@ -67,146 +69,186 @@ use work.common_pkg.all; entity pixel_buffer_0 IS generic ( - 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; - EN_PEEK : boolean := false; - VECTORED_RDREQ : boolean := false + 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; + RSVD_DEPTH : integer range 0 to 1024 := 0; + FULL_MARGIN : integer range 2 to 1024 := 8; + EN_PEEK : boolean := false; + VECTORED_RDREQ : boolean := false ); port ( - clk : in std_logic; - rst_n : in std_logic; + clk : in std_logic; + rst_n : in std_logic; - pixel_buf_rdy : out std_logic; + pixel_buf_rdy : out std_logic; - last_word : in std_logic; - data : in std_logic_vector(31 downto 0); - wrreq : in std_logic; + last_word : in std_logic; + data : in std_logic_vector(31 downto 0); + wrreq : in std_logic; - rdreq : in std_logic; - rdreq_vec : in std_logic_vector(MAX_OP_WIDTH-1 downto 0) := (others => '0'); - q : out std_logic_vector(MAX_OP_WIDTH*33-1 downto 0); + rdreq : in std_logic; + rdreq_vec : in std_logic_vector(MAX_OP_WIDTH-1 downto 0) := (others => '0'); + q : out std_logic_vector(MAX_OP_WIDTH*33-1 downto 0); + rdreq_rdy : out std_logic; - empty : out std_logic; - full : out std_logic; - overrun : out std_logic; - underrun : out std_logic; - dbl_drop : out std_logic; - fp_drop : out std_logic; + empty : out std_logic; + full : out std_logic; + overrun : out std_logic; + underrun : out std_logic; + dbl_drop : out std_logic; + fp_drop : out std_logic; - print_data_width : in std_logic_vector( 5 downto 0); - clear_buffer : in std_logic; + print_data_width : in std_logic_vector( 5 downto 0); + clear_buffer : in std_logic; - start_req : in std_logic; - start_req_first : in std_logic; - start_req_last : in std_logic; + start_req : in std_logic; + start_req_first : in std_logic; + start_req_last : in std_logic; - is_last_wave : out std_logic; + is_last_wave : out std_logic; + + fire_req : in std_logic; + sequencers_busy : out std_logic; + fp_holdoff_update : in std_logic; + wave_seq_len : in std_logic_vector(15 downto 0); + + all_on : in std_logic := '0'; - fire_req : in std_logic; - 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); + 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); + diag_peek_wrptr : out std_logic_vector( 7 downto 0); + diag_peek_wdata : in std_logic_vector(31 downto 0) := (others => '1'); + diag_peek_wr : in std_logic := '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"04"; - ip_ver_major_number : out std_logic_vector( 7 downto 0) := 8x"00"; + ip_id_ip_number : out std_logic_vector( 7 downto 0) := 8x"1c"; -- @suppress "Unused port: ip_id_ip_number is not used in work.pixel_buffer_0(rtl)" + ip_id_mfr_number : out std_logic_vector( 7 downto 0) := 8x"00"; -- @suppress "Unused port: ip_id_mfr_number is not used in work.pixel_buffer_0(rtl)" + ip_ver_minor_number : out std_logic_vector( 7 downto 0) := 8x"05"; -- @suppress "Unused port: ip_ver_minor_number is not used in work.pixel_buffer_0(rtl)" + ip_ver_major_number : out std_logic_vector( 7 downto 0) := 8x"00"; -- @suppress "Unused port: ip_ver_major_number is not used in work.pixel_buffer_0(rtl)" - diag_word_count : out std_logic_vector(6 downto 0) + diag_word_count : out std_logic_vector(6 downto 0) ); end pixel_buffer_0; architecture rtl of pixel_buffer_0 is - constant PX_DEPTH_LOG2 : integer := log2(PX_DEPTH); - constant PX_WIDTH : integer := 33; - constant FULL_THRESHOLD : integer := PX_DEPTH-FULL_MARGIN; + constant PX_DEPTH_LOG2 : integer := log2(PX_DEPTH); + constant TOTAL_DEPTH_LOG2 : integer := log2(PX_DEPTH + RSVD_DEPTH); + constant PX_WIDTH : integer := 33; + 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; - type rd_ptr_t is array (0 to MAX_OP_WIDTH-1) of std_logic_vector(PX_DEPTH_LOG2 downto 0); + subtype OP_WIDTH_RANGE is natural range 1 to MAX_OP_WIDTH; - signal wr_ptr : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal rd_ptr : rd_ptr_t; - signal rd_ptr_int : rd_ptr_t; - 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); + type rd_ptr_t is array (natural range <> ) of std_logic_vector; - signal buf_word_count : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal pixel_buf_wr_shft : std_logic_vector(MAX_OP_WIDTH-1 downto 0); - signal wren : std_logic_vector(MAX_OP_WIDTH-1 downto 0); + signal wr_ptr : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal wr_ptr_int : std_logic_vector(TOTAL_DEPTH_LOG2 downto 0); + signal rd_ptr : rd_ptr_t(0 to MAX_OP_WIDTH-1)(PX_DEPTH_LOG2 downto 0); + signal rd_ptr_int : rd_ptr_t(0 to MAX_OP_WIDTH-1)(TOTAL_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); - signal word_count : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal buf_word_count : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal pixel_buf_wr_shft : std_logic_vector(MAX_OP_WIDTH-1 downto 0); + signal wren : std_logic_vector(MAX_OP_WIDTH-1 downto 0); + signal wren_int : std_logic_vector(MAX_OP_WIDTH-1 downto 0); - signal word_wrap : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal word_wrap_plus1 : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal word_count : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal error : std_logic; - signal pend_drop_detect : std_logic; - signal drop_adjust : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal next_drop_adjust : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal word_wrap : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal word_wrap_plus1 : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal holdoff_count : std_logic_vector(15 downto 0); - signal next_sequencers_busy : std_logic; - signal fire_drop_detect : std_logic; + signal error : std_logic; + signal pend_drop_detect : std_logic; + signal drop_adjust : std_logic_vector(PX_DEPTH_LOG2 downto 0); + signal next_drop_adjust : std_logic_vector(PX_DEPTH_LOG2 downto 0); - signal wr_req_int : std_logic; - signal data_int : std_logic_vector(32 downto 0); - signal writing_first_stripe : std_logic; + signal holdoff_count : std_logic_vector(15 downto 0); + signal next_sequencers_busy : std_logic; + signal fire_drop_detect : 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; + signal wr_req_int : std_logic; + signal data_int : std_logic_vector(32 downto 0); + signal writing_first_stripe : std_logic; + + signal diag_peek_wren : std_logic_vector(MAX_OP_WIDTH-1 downto 0); + signal is_en_peek : std_logic; + + signal rdreq_vec_int : std_logic_vector(MAX_OP_WIDTH-1 downto 0); + + signal all_on_active : std_logic; - signal rdreq_vec_int : std_logic_vector(MAX_OP_WIDTH-1 downto 0); - begin + -- ----------------------------------------------- + -- Simulation assertion checks + -- ----------------------------------------------- + -- pragma translate_off assert FULL_MARGIN < PX_DEPTH report "FULL_MARGIN must be < PX_DEPTH" severity failure; + + -- Assert that the pixel buffer is depth is a power of 2 + process(all) + variable vp : unsigned(31 downto 0); + variable vpm1 : unsigned(31 downto 0); + begin + vp := to_unsigned(PX_DEPTH, 32); + vpm1 := to_unsigned(PX_DEPTH-1, 32); + + assert (vp and vpm1) = 0 report "PX_DEPTH must be a power of 2" severity failure; + + end process; -- pragma translate_on - GEN_RDREQ_VEC : if VECTORED_RDREQ generate - rdreq_vec_int <= rdreq_vec; + -- ----------------------------------------------- + -- Vectored read request selection + -- ----------------------------------------------- + + GEN_RDREQ_VEC : if VECTORED_RDREQ generate + rdreq_vec_int <= rdreq_vec; end generate; - + GEN_NORDREQ_VEC : if not VECTORED_RDREQ generate - rdreq_vec_int <= (others => rdreq); + rdreq_vec_int <= (others => rdreq); end generate; + -- ----------------------------------------------- + -- Pixel Buffers + -- ----------------------------------------------- + GEN_PIXEL_BUFFERS : for i in 0 to MAX_OP_WIDTH-1 generate - wren(i) <= pixel_buf_wr_shft(i) when wr_req_int = '1' else '0'; + wren(i) <= pixel_buf_wr_shft(i) when wr_req_int = '1' else '0'; + wren_int(i) <= wren(i) or diag_peek_wren(i); pixel_ram_inst : entity work.pixel_ram_0 generic map ( - DEPTH => PX_DEPTH, - WIDTH => PX_WIDTH + DEPTH => PX_DEPTH + RSVD_DEPTH, + WIDTH => PX_WIDTH ) port map ( - clock => clk, - data => data_int, - rdaddress => rd_ptr_int(i)(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) + clock => clk, + data => data_int, + rdaddress => rd_ptr_int(i)(TOTAL_DEPTH_LOG2-1 downto 0), + wraddress => wr_ptr_int(TOTAL_DEPTH_LOG2-1 downto 0), + wren => wren_int(i), + q => q((i+1)*PX_WIDTH-1 downto i*PX_WIDTH) ); end generate GEN_PIXEL_BUFFERS; + -- ----------------------------------------------- + -- Combo logic + -- ----------------------------------------------- + word_wrap_plus1 <= std_logic_vector(unsigned(word_wrap)+1); empty <= '1' when unsigned(word_count) = 0 else '0'; @@ -216,8 +258,13 @@ begin empty = '1' else '0'; + -- Flag that data is ready for reading either when not empty, or if in all on mode and 'last' not active + rdreq_rdy <= not empty or (all_on_active and not is_last_wave); + + -- Combine the error statuses error <= underrun or overrun or dbl_drop; + -- Pixel buffer is ready for more write data if not full or not in an error state pixel_buf_rdy <= not full and not error; -- Single source of write pointer + 1, used in multiple places @@ -235,24 +282,41 @@ 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 + + -- ----------------------------------------------- + -- Diagnostic peek combo logic + -- ----------------------------------------------- + + -- 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'; GEN_RDPTR_INT : for i in 0 to MAX_OP_WIDTH-1 generate - rd_ptr_int(i) <= rd_ptr(i) when diag_peek_sel = '0' else "0" & diag_peek_addr(PX_DEPTH_LOG2-1 downto 0); + rd_ptr_int(i) <= "0" & all_on & rd_ptr(i)(PX_DEPTH_LOG2-1 downto 0) when diag_peek_sel = '0' else + "0" & diag_peek_addr(TOTAL_DEPTH_LOG2-1 downto 0); end generate; + + wr_ptr_int <= std_logic_vector(resize(unsigned(wr_ptr(PX_DEPTH_LOG2-1 downto 0)), TOTAL_DEPTH_LOG2+1)) when unsigned(diag_peek_wren) = 0 else + "0" & diag_peek_addr(TOTAL_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'; + is_en_peek <= '0'; GEN_RDPTR_INT : for i in 0 to MAX_OP_WIDTH-1 generate - rd_ptr_int(i) <= rd_ptr(i); + rd_ptr_int(i) <= std_logic_vector(resize(unsigned(rd_ptr(i)(PX_DEPTH_LOG2-1 downto 0)), TOTAL_DEPTH_LOG2+1)); + end generate; + + wr_ptr_int <= std_logic_vector(resize(unsigned(wr_ptr(PX_DEPTH_LOG2-1 downto 0)), TOTAL_DEPTH_LOG2+1)); + end generate; + -- ----------------------------------------------- + -- Synchronous process + -- ----------------------------------------------- + PX_BUF_CTRL : process(rst_n, clk) is variable op_width : OP_WIDTH_RANGE; begin @@ -276,11 +340,15 @@ begin holdoff_count <= (others => '0'); sequencers_busy <= '0'; wr_req_int <= '0'; + all_on_active <= '0'; + diag_peek_wren <= (others => '0'); elsif clk'event and clk = '1' then wr_req_int <= wrreq; + data_int <= last_word & data; + diag_peek_wren <= (others => '0'); if clear_buffer = '1' then for i in 0 to MAX_OP_WIDTH-1 loop @@ -299,6 +367,7 @@ begin pend_drop_detect <= '0'; dbl_drop <= '0'; fp_drop <= '0'; + all_on_active <= '0'; end if; if fp_holdoff_update = '1' then @@ -318,12 +387,32 @@ begin -- read pointer to the beginning of the stripe for the subsequent -- grey level mapping and waveform. if start_req = '1' and error = '0' then - if start_req_first = '1' then - rd_ptr_start <= rd_ptr(0); + + -- When in normal mode on first start request save off start position of read pointer + -- otherwise reset to last saved place. + if all_on = '0' then + if start_req_first = '1' and all_on_active = '0' then + rd_ptr_start <= rd_ptr(0); + else + for i in 0 TO MAX_OP_WIDTH-1 loop + rd_ptr(i) <= rd_ptr_start; + end loop; + end if; + all_on_active <= '0'; + + -- If in all on mode increment the saved start position by a stripe if last flag set, + -- else leave it untouched. Read pointers get reset. else + if start_req_last = '1' then + rd_ptr_start <= std_logic_vector(unsigned(rd_ptr_start) + unsigned(rd_ptr(0))); + end if; + for i in 0 TO MAX_OP_WIDTH-1 loop - rd_ptr(i) <= rd_ptr_start; + rd_ptr(i) <= (others => '0'); end loop; + + all_on_active <= '1'; + end if; -- When the start of the last wave (which could also be the first), latch @@ -335,12 +424,17 @@ begin end if; end if; - -- If pixel buffer peeking diags enabled, export the read pointer + -- If pixel buffer peeking diags enabled, export the read and write pointers, -- being careful as the diag port is fixed width but rd_ptr is defined by generic -- Note that this will zero-pad or truncate depending on which vector is longer. It's only for diagnostic purposes. diag_peek_rdptr <= (others => '0'); if is_en_peek then - diag_peek_rdptr <= std_logic_vector(resize(unsigned(rd_ptr(0)), diag_peek_rdptr'length)); + diag_peek_rdptr <= std_logic_vector(resize(unsigned(rd_ptr(0)), diag_peek_rdptr'length)); + end if; + + diag_peek_wrptr <= (others => '0'); + if is_en_peek then + diag_peek_wrptr <= std_logic_vector(resize(unsigned(wr_ptr), diag_peek_wrptr'length)); end if; -- Increment the read pointer for each read request @@ -349,10 +443,19 @@ begin rd_ptr(i) <= std_logic_vector(unsigned(rd_ptr(i)) + 1); end if; end loop; - + + -- Select the read data to peek, based on the address bits beyond the buffer space. + -- If writing, overwrite the RAM data an pulse the selected buffer's write enable. 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); + if is_en_peek = '1' and i = unsigned(diag_peek_addr(log2(MAX_OP_WIDTH) + TOTAL_DEPTH_LOG2 - 1 downto TOTAL_DEPTH_LOG2)) then + + diag_peek_data <= q((i+1)*PX_WIDTH-2 downto i*PX_WIDTH); + + if diag_peek_wr = '1' and diag_peek_sel = '1' then + data_int <= "0" & diag_peek_wdata; + diag_peek_wren(i) <= '1'; + end if; + end if; end loop; @@ -404,7 +507,7 @@ begin end if; if writing_first_stripe = '1' and rdreq_vec_int(0) = '1' then - underrun <= '1'; + underrun <= not all_on or is_last_wave; end if; -- If a drop of a fire pulse is detected, remember that here