HMBSI1536-180. Add working zero gap pixel buffer to library
This commit is contained in:
parent
091847d151
commit
ed2330d93d
4 changed files with 1115 additions and 0 deletions
658
generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd
Normal file
658
generic_ip/pixel_buffer/2/src/pixel_buffer_2.vhd
Normal file
|
|
@ -0,0 +1,658 @@
|
|||
-------------------------------------------------------------------------------
|
||||
--! @file
|
||||
--! @brief SOM FPGA pixel buffer
|
||||
--!
|
||||
--! @details This block is the the data core pixel buffer for the Presto projects.
|
||||
--! it stores pixel strip data, with a write port from the print streamer, and
|
||||
--! a read port from the data core slicer. The memory is organised into 18
|
||||
--! (one for each data bit maximum) buffers of 32 bits x 64 deep, giving a
|
||||
--! maximum capacity of over 10 stripes in 3bpp mode. The write control logic
|
||||
--! will stripe received words into the buffers, from 0 to output width (6 or
|
||||
--! 18) minus 1, moving on to next buffer after 64 pixels worth of data. Read
|
||||
--! data is read from all buffers in parallel. Start requests without a 'first'
|
||||
--! status resets the read pointer to beginning of stripe, to allow multi-wave
|
||||
--! grey level operation. A start request with a 'first' status allows the
|
||||
--! read pointer to advance to next stripe. See
|
||||
--! https://confluence.gisapps.co.uk/pages/viewpage.action?spaceKey=GMAHMB&title=HMB-FD-GMA+Design+Documentation
|
||||
--!
|
||||
--! @b Clock/resets:
|
||||
--! @li clk : nominally 100MHz
|
||||
--! @li rst_n : active low reset for clk (asynchronous assert)
|
||||
--!
|
||||
--! @b Interfaces:
|
||||
--! @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
|
||||
--! @li empty : buffer empty status.
|
||||
--! @li full : buffer full (with look-ahead) status
|
||||
--! @li overrun : Pixel buffer overrun error status
|
||||
--! @li underrun : Pixel buffer underrun error status
|
||||
--! @li fp_drop : Fire pulse drop seen
|
||||
--! @li dbl_drop : Double fire pulse 'droppy' error status
|
||||
--! @li print_data_width : print output data width (6 or 18 for GMA)
|
||||
--! @li clear_buffer : Pixel buffer clear pulse input
|
||||
--! @li start_req : start request pulse from print data sequencer, via delay queue
|
||||
--! @li start_req_first : start request first wave/next stripe status from print data sequencer, via delay queue (used to re-read same stripe out multiple times)
|
||||
--! @li start_req_last : start request last wave status from print data sequencer, via delay queue (used to re-read same stripe out multiple times)
|
||||
--! @li is_last_wave : Status output flagging processing last wave
|
||||
--! @li fire_req : Fire pulse request input
|
||||
--! @li drop_stripe : Overdrive, fire pulse has been ignored by Print Sequencer so drop stripe in Pixel Buffer
|
||||
--! @li sequencers_busy : Status output indicating sequences busy with respect to accepting a new fire pulse
|
||||
--! @li last_stripe_dropped : Status output indicating that the last stripe of an image was the one dropped. Needed to flip the swing buffer in zero gap mode
|
||||
--! @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
|
||||
--! @li ip_ver_major_number : Module's Major version number
|
||||
--!
|
||||
--! @b Clock-crossing considerations:
|
||||
--! @li Module is a single clock domain synchronous block
|
||||
--!
|
||||
--! @b Language build standard requirements:
|
||||
--! @li VHDL 2008
|
||||
--!
|
||||
--! @author Simon Southwell
|
||||
--! @copyright (c) 2018 Global Inkjet Systems
|
||||
--! @date 2018-4-12
|
||||
-------------------------------------------------------------------------------
|
||||
-- altera vhdl_input_version vhdl_2008
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
use work.common_pkg.all;
|
||||
|
||||
entity pixel_buffer_2 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;
|
||||
RSVD_DEPTH : integer range 0 to 1024 := 0;
|
||||
FULL_MARGIN : integer range 2 to 1024 := 8;
|
||||
EN_PEEK : boolean := false;
|
||||
VECTORED_RDREQ : boolean := false;
|
||||
DEVICE_FAMILY : string := "Cyclone V"; -- "Cyclone 10 LP"
|
||||
ADD_PADDING : boolean := false -- set to true for SI1536 padding
|
||||
);
|
||||
port
|
||||
(
|
||||
clk : in std_logic;
|
||||
rst_n : in 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;
|
||||
|
||||
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*32-1 downto 0);
|
||||
last_word_op : out std_logic_vector(MAX_OP_WIDTH-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;
|
||||
|
||||
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;
|
||||
|
||||
is_last_wave : out std_logic;
|
||||
|
||||
fire_req : in std_logic;
|
||||
drop_stripe : in std_logic;
|
||||
sequencers_busy : out std_logic;
|
||||
last_stripe_dropped : 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';
|
||||
|
||||
-- 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_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"; -- @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"07"; -- @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)
|
||||
);
|
||||
end pixel_buffer_2;
|
||||
|
||||
|
||||
architecture rtl of pixel_buffer_2 is
|
||||
|
||||
constant PX_DEPTH_LOG2 : integer := log2(PX_DEPTH);
|
||||
constant TOTAL_DEPTH_LOG2 : integer := log2(PX_DEPTH + RSVD_DEPTH);
|
||||
constant PX_DATA_WIDTH : integer := 32;
|
||||
constant STRIPE_ID_WIDTH : integer := 4;
|
||||
constant FULL_THRESHOLD : integer := PX_DEPTH-FULL_MARGIN;
|
||||
|
||||
subtype OP_WIDTH_RANGE is natural range 1 to MAX_OP_WIDTH;
|
||||
|
||||
type rd_ptr_t is array (natural range <> ) of std_logic_vector;
|
||||
|
||||
signal wr_ptr : std_logic_vector(PX_DEPTH_LOG2 downto 0);
|
||||
signal wr_ptr_int : std_logic_vector(TOTAL_DEPTH_LOG2 downto 0);
|
||||
signal wr_ptr_start_plusgap : std_logic_vector(PX_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 rd_ptr_all_equal : std_logic;
|
||||
|
||||
signal stripe_is_last : std_logic_vector(2**STRIPE_ID_WIDTH downto 0);
|
||||
signal current_wr_stripe_id : std_logic_vector(STRIPE_ID_WIDTH-1 downto 0);
|
||||
signal wr_data_stripe_id : std_logic_vector(STRIPE_ID_WIDTH-1 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_count : 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 word_wrap_minus1 : 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 stripe_dropped : std_logic;
|
||||
|
||||
signal holdoff_count : std_logic_vector(15 downto 0);
|
||||
signal next_sequencers_busy : std_logic;
|
||||
|
||||
signal wr_req_int : std_logic;
|
||||
signal data_int : std_logic_vector(PX_DATA_WIDTH-1 downto 0);
|
||||
signal writing_first_stripe : std_logic;
|
||||
signal last_word_int : std_logic;
|
||||
signal last_valid_rd_stripe_id : std_logic_vector(STRIPE_ID_WIDTH-1 downto 0);
|
||||
|
||||
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 rd_data_stripe_id : std_logic_vector(MAX_OP_WIDTH*STRIPE_ID_WIDTH-1 downto 0);
|
||||
|
||||
signal all_on_active : std_logic;
|
||||
|
||||
signal diag_rd_cnt : rd_ptr_t(MAX_OP_WIDTH-1 downto 0)(15 downto 0) := (others => (others => '0'));
|
||||
|
||||
function next_stripe_id(id : std_logic_vector) return std_logic_vector is
|
||||
variable next_id : unsigned(id'high+1 downto 0);
|
||||
begin
|
||||
next_id := resize(unsigned(id), next_id'length) + 1;
|
||||
if next_id >= (2**STRIPE_ID_WIDTH) then
|
||||
next_id := to_unsigned(1, next_id'length) ; -- zero not valid
|
||||
end if;
|
||||
return std_logic_vector(next_id(id'range));
|
||||
end function next_stripe_id;
|
||||
|
||||
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" & integer'image(PX_DEPTH) severity failure;
|
||||
|
||||
end process;
|
||||
-- pragma translate_on
|
||||
|
||||
-- -----------------------------------------------
|
||||
-- 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);
|
||||
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_int(i) <= wren(i) or diag_peek_wren(i);
|
||||
|
||||
pixel_ram_inst : entity work.dp_ram_1
|
||||
generic map (
|
||||
DEPTH => PX_DEPTH + RSVD_DEPTH,
|
||||
DATA_WIDTH => PX_DATA_WIDTH+STRIPE_ID_WIDTH,
|
||||
REGISTER_OUTPUT => "UNREGISTERED",
|
||||
READ_WRITE_MODE => "DONT_CARE",
|
||||
DEVICE_FAMILY => DEVICE_FAMILY
|
||||
)
|
||||
port map
|
||||
(
|
||||
clk => clk,
|
||||
wrdata(31 downto 0) => data_int,
|
||||
wrdata(35 downto 32) => wr_data_stripe_id,
|
||||
rdaddr => rd_ptr_int(i)(TOTAL_DEPTH_LOG2-1 downto 0),
|
||||
wraddr => wr_ptr_int(TOTAL_DEPTH_LOG2-1 downto 0),
|
||||
wren => wren_int(i),
|
||||
rddata(31 downto 0) => q((i+1)*PX_DATA_WIDTH-1 downto i*PX_DATA_WIDTH),
|
||||
rddata(35 downto 32) => rd_data_stripe_id((i+1)*STRIPE_ID_WIDTH-1 downto i*STRIPE_ID_WIDTH)
|
||||
);
|
||||
end generate GEN_PIXEL_BUFFERS;
|
||||
|
||||
-- -----------------------------------------------
|
||||
-- Combo logic
|
||||
-- -----------------------------------------------
|
||||
|
||||
word_wrap_plus1 <= std_logic_vector(unsigned(word_wrap)+1);
|
||||
word_wrap_minus1 <= std_logic_vector(unsigned(word_wrap)-1);
|
||||
|
||||
empty <= '1' when unsigned(word_count) = 0 else '0';
|
||||
full <= '1' when unsigned(word_count) >= FULL_THRESHOLD else '0';
|
||||
writing_first_stripe <= '1' when ((unsigned(word_count) = unsigned(word_wrap_plus1)) and pixel_buf_wr_shft(0) = '0') or
|
||||
((unsigned(word_count) < unsigned(word_wrap_plus1)) and wren(0) = '1') or
|
||||
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
|
||||
wr_ptr_plus1 <= std_logic_vector(unsigned(wr_ptr) + 1);
|
||||
wr_ptr_start_plusgap <= std_logic_vector(unsigned(wr_ptr_start) + 16);
|
||||
|
||||
-- Word count wrap BPP3 (packed to 4) => 15 for depth of 128)
|
||||
word_wrap <= std_logic_vector(to_unsigned((4*SHIFT_DEPTH/32)-1,PX_DEPTH_LOG2+1)) when not ADD_PADDING or ((pixel_buf_wr_shft(0) or pixel_buf_wr_shft(2) or pixel_buf_wr_shft(4) or pixel_buf_wr_shft(6)) = '1') else
|
||||
std_logic_vector(to_unsigned((2*SHIFT_DEPTH/32)-1,PX_DEPTH_LOG2+1));
|
||||
|
||||
-- The pixel buffer droppy deletion count is a function of the number of words
|
||||
-- in the shift: e.g. 64 bits = 8, 96 bits = 12, 128 bits = 16 etc.
|
||||
next_drop_adjust <= std_logic_vector(to_unsigned((4*SHIFT_DEPTH/32),PX_DEPTH_LOG2+1));
|
||||
|
||||
next_sequencers_busy <= '1' when unsigned(holdoff_count) /= 0 else '0';
|
||||
|
||||
diag_word_count <= word_count(diag_word_count'left downto 0);
|
||||
|
||||
-- Need to indicate that the last stripe of the image was dropped so that can be marked complete
|
||||
last_stripe_dropped <= stripe_dropped and stripe_is_last(to_integer(unsigned(next_stripe_id(last_valid_rd_stripe_id)))); -- use stripe id to look up if the next read stripe is the last
|
||||
|
||||
-- -----------------------------------------------
|
||||
-- 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) <= "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 calculated read address
|
||||
GENNOPL : if not EN_PEEK generate
|
||||
is_en_peek <= '0';
|
||||
GEN_RDPTR_INT : for i in 0 to MAX_OP_WIDTH-1 generate
|
||||
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;
|
||||
variable rd_stripe_id : integer range 0 to 2**STRIPE_ID_WIDTH;
|
||||
begin
|
||||
if rst_n = '0' then
|
||||
for i in 0 to MAX_OP_WIDTH-1 loop
|
||||
rd_ptr(i) <= (others => '0');
|
||||
end loop;
|
||||
rd_ptr_all_equal <= '1';
|
||||
rd_ptr_start <= (others => '0');
|
||||
wr_ptr_start <= (others => '0');
|
||||
wr_ptr <= (others => '0');
|
||||
buf_word_count <= (others => '0');
|
||||
pixel_buf_wr_shft(pixel_buf_wr_shft'length-1 downto 1) <= (others => '0');
|
||||
pixel_buf_wr_shft(0) <= '1';
|
||||
word_count <= (others => '0');
|
||||
is_last_wave <= '0';
|
||||
overrun <= '0';
|
||||
underrun <= '0';
|
||||
pend_drop_detect <= '0';
|
||||
stripe_dropped <= '0';
|
||||
dbl_drop <= '0';
|
||||
fp_drop <= '0';
|
||||
holdoff_count <= (others => '0');
|
||||
sequencers_busy <= '0';
|
||||
wr_req_int <= '0';
|
||||
all_on_active <= '0';
|
||||
diag_peek_wren <= (others => '0');
|
||||
|
||||
stripe_is_last <= (others => '0');
|
||||
current_wr_stripe_id <= (others => '0');
|
||||
current_wr_stripe_id(0) <= '1';
|
||||
last_word_op <= (others => '0');
|
||||
wr_data_stripe_id <= (others => '0');
|
||||
rd_stripe_id := 0;
|
||||
last_valid_rd_stripe_id <= (others => '0');
|
||||
|
||||
elsif clk'event and clk = '1' then
|
||||
|
||||
wr_req_int <= wrreq;
|
||||
|
||||
data_int <= data;
|
||||
last_word_int <= last_word;
|
||||
diag_peek_wren <= (others => '0');
|
||||
|
||||
if clear_buffer = '1' then
|
||||
for i in 0 to MAX_OP_WIDTH-1 loop
|
||||
rd_ptr(i) <= (others => '0');
|
||||
end loop;
|
||||
rd_ptr_all_equal <= '1';
|
||||
rd_ptr_start <= (others => '0');
|
||||
wr_ptr_start <= (others => '0');
|
||||
wr_ptr <= (others => '0');
|
||||
buf_word_count <= (others => '0');
|
||||
pixel_buf_wr_shft(pixel_buf_wr_shft'length-1 downto 1) <= (others => '0');
|
||||
pixel_buf_wr_shft(0) <= '1';
|
||||
word_count <= (others => '0');
|
||||
is_last_wave <= '0';
|
||||
overrun <= '0';
|
||||
underrun <= '0';
|
||||
pend_drop_detect <= '0';
|
||||
stripe_dropped <= '0';
|
||||
dbl_drop <= '0';
|
||||
fp_drop <= '0';
|
||||
all_on_active <= '0';
|
||||
|
||||
stripe_is_last <= (others => '0');
|
||||
current_wr_stripe_id <= (others => '0');
|
||||
current_wr_stripe_id(0) <= '1';
|
||||
last_word_op <= (others => '0');
|
||||
wr_data_stripe_id <= (others => '0');
|
||||
last_valid_rd_stripe_id <= (others => '0');
|
||||
|
||||
end if;
|
||||
|
||||
if fp_holdoff_update = '1' then
|
||||
holdoff_count <= wave_seq_len;
|
||||
elsif unsigned(holdoff_count) /= 0 then
|
||||
holdoff_count <= std_logic_vector(unsigned(holdoff_count) - 1);
|
||||
end if;
|
||||
|
||||
sequencers_busy <= next_sequencers_busy;
|
||||
|
||||
-- Register the droppy adjust count to relieve timing
|
||||
drop_adjust <= next_drop_adjust;
|
||||
|
||||
-- On the start request from the print data sequencer, when first
|
||||
-- (i.e. first in multi-wave grey level, or just a single binary)
|
||||
-- store the start of the next stripe data. If not first, reset the
|
||||
-- read pointer to the beginning of the stripe for the subsequent
|
||||
-- grey level mapping and waveform.
|
||||
if start_req = '1' and error = '0' then
|
||||
|
||||
-- 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;
|
||||
|
||||
if start_req_first = '1' then
|
||||
for i in 0 TO MAX_OP_WIDTH-1 loop
|
||||
rd_ptr(i) <= (others => '0');
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
all_on_active <= '1';
|
||||
|
||||
end if;
|
||||
|
||||
-- When the start of the last wave (which could also be the first), latch
|
||||
-- state to indicate this for the whole transfer.
|
||||
if start_req_last = '1' then
|
||||
is_last_wave <= '1';
|
||||
else
|
||||
is_last_wave <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- 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));
|
||||
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
|
||||
for i in 0 TO MAX_OP_WIDTH-1 loop
|
||||
if rdreq_vec_int(i) = '1' and error = '0' then
|
||||
rd_ptr(i) <= std_logic_vector(unsigned(rd_ptr(i)) + 1);
|
||||
end if;
|
||||
|
||||
rd_stripe_id := to_integer(unsigned(rd_data_stripe_id((i+1)*STRIPE_ID_WIDTH-1 downto i*STRIPE_ID_WIDTH)));
|
||||
|
||||
if rd_stripe_id /= 0 then
|
||||
last_valid_rd_stripe_id <= rd_data_stripe_id((i+1)*STRIPE_ID_WIDTH-1 downto i*STRIPE_ID_WIDTH);
|
||||
end if;
|
||||
|
||||
last_word_op(i) <= '0';
|
||||
if rd_stripe_id /= 0 then -- last word marker
|
||||
if stripe_is_last(rd_stripe_id) then -- use stripe id to look up if this is the last word of the last stripe
|
||||
last_word_op(i) <= '1';
|
||||
end if;
|
||||
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) + TOTAL_DEPTH_LOG2 - 1 downto TOTAL_DEPTH_LOG2)) then
|
||||
|
||||
diag_peek_data <= q((i+1)*PX_DATA_WIDTH-1 downto i*PX_DATA_WIDTH);
|
||||
|
||||
if diag_peek_wr = '1' and diag_peek_sel = '1' then
|
||||
data_int <= diag_peek_wdata;
|
||||
wr_data_stripe_id <= (others => '0');
|
||||
diag_peek_wren(i) <= '1';
|
||||
end if;
|
||||
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
-- Update buffer input state when ever we get a strobe
|
||||
if wr_req_int = '1' and error = '0' then
|
||||
|
||||
wr_data_stripe_id <= (others => '0'); -- default to not last word
|
||||
|
||||
-- If the buffer 32 bit word count reached 4*SHIFT_DEPTH/32-1, then rollover to 0
|
||||
if buf_word_count = word_wrap then
|
||||
|
||||
buf_word_count <= (others => '0');
|
||||
|
||||
-- At rollover, move writes on to the next buffer. The shift register
|
||||
-- feedback is from the top bit for the configured output width
|
||||
op_width := to_integer(unsigned(print_data_width));
|
||||
pixel_buf_wr_shft <= pixel_buf_wr_shft(pixel_buf_wr_shft'length-2 downto 0) & pixel_buf_wr_shft(op_width - 1);
|
||||
|
||||
-- if moving on to the next buffer, reset the write pointer to the last start address
|
||||
if pixel_buf_wr_shft(op_width - 1) /= '1' then
|
||||
if ADD_PADDING and ((pixel_buf_wr_shft(0) or pixel_buf_wr_shft(2) or pixel_buf_wr_shft(4) or pixel_buf_wr_shft(6)) = '1') then
|
||||
wr_ptr <= wr_ptr_start_plusgap;
|
||||
else
|
||||
wr_ptr <= wr_ptr_start;
|
||||
end if;
|
||||
else
|
||||
-- If about to wrap to the next stripe, update the saved wr_ptr to
|
||||
-- the next word, and allow the wr_ptr to advance
|
||||
wr_ptr_start <= wr_ptr_plus1;
|
||||
wr_ptr <= wr_ptr_plus1;
|
||||
|
||||
-- last word of stripe, now check last word flag and set last stripe marker
|
||||
if last_word_int = '1' then
|
||||
stripe_is_last(to_integer(unsigned(current_wr_stripe_id))) <= '1'; -- set bit pos for this stripe
|
||||
end if;
|
||||
current_wr_stripe_id <= next_stripe_id(current_wr_stripe_id);
|
||||
end if;
|
||||
--
|
||||
else
|
||||
-- Whilst writing data to the active buffer, increment the word count and write pointer
|
||||
buf_word_count <= std_logic_vector(unsigned(buf_word_count) + 1);
|
||||
wr_ptr <= wr_ptr_plus1;
|
||||
end if;
|
||||
|
||||
if buf_word_count = word_wrap_minus1 then
|
||||
wr_data_stripe_id <= current_wr_stripe_id; -- put stripe id in the last word of each op buffer (per stripe)
|
||||
end if;
|
||||
|
||||
if to_integer(unsigned(buf_word_count)) = 0 and pixel_buf_wr_shft(0) = '1' then
|
||||
-- first word of stripe so reset last stripe marker
|
||||
stripe_is_last(to_integer(unsigned(current_wr_stripe_id))) <= '0'; -- clear bit pos for this stripe
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- Keep a count, for buffer 0, of the number of words in the buffer.
|
||||
-- Increment count when written, and decrement when read during the
|
||||
-- the last wave pulse, but leave static if reading (last pulse) and
|
||||
-- writing, or neither reading during last pulse nor writing.
|
||||
if error = '0' then
|
||||
if wren(0) = '1' and (rdreq_vec_int(0) = '0' or is_last_wave = '0') then
|
||||
word_count <= std_logic_vector(unsigned(word_count) + 1);
|
||||
elsif wren(0) = '0' and rdreq_vec_int(0) = '1' and is_last_wave = '1' then
|
||||
word_count <= std_logic_vector(unsigned(word_count) - 1);
|
||||
end if;
|
||||
end if;
|
||||
|
||||
--
|
||||
if unsigned(word_count) = PX_DEPTH and wr_req_int = '1' then
|
||||
overrun <= '1';
|
||||
end if;
|
||||
|
||||
if writing_first_stripe = '1' and rdreq_vec_int(0) = '1' then
|
||||
underrun <= not all_on or is_last_wave;
|
||||
end if;
|
||||
|
||||
-- If a drop of a fire pulse is detected, remember that here
|
||||
if drop_stripe = '1' then
|
||||
fp_drop <= '1';
|
||||
if pend_drop_detect = '1' then
|
||||
dbl_drop <= '1';
|
||||
end if;
|
||||
pend_drop_detect <= '1';
|
||||
end if;
|
||||
|
||||
-- If a 'droppy' situation is outstanding, wait for the data path to go idle
|
||||
-- and clear the contents of the next stripe
|
||||
-- sequencers_busy = '0' covers the case where rd_req_vec reads at different times
|
||||
-- is_last_wave and rd_ptr_all_equal ensures that we complete the stripe before completely before deleting this one
|
||||
stripe_dropped <= '0';
|
||||
if pend_drop_detect = '1' and sequencers_busy = '0' and unsigned(wren) = 0 and word_count >= drop_adjust and unsigned(rdreq_vec_int) = 0 and is_last_wave = '1' and rd_ptr_all_equal = '1' then
|
||||
pend_drop_detect <= '0';
|
||||
for i in 0 to MAX_OP_WIDTH-1 loop
|
||||
rd_ptr(i) <= std_logic_vector(unsigned(rd_ptr(i)) + unsigned(drop_adjust));
|
||||
end loop;
|
||||
word_count <= std_logic_vector(unsigned(word_count) - unsigned(drop_adjust));
|
||||
-- forget 1 stripe
|
||||
stripe_dropped <= '1';
|
||||
end if;
|
||||
|
||||
rd_ptr_all_equal <= '1';
|
||||
for i in 1 to MAX_OP_WIDTH-1 loop
|
||||
if rd_ptr(0) /= rd_ptr(i) then
|
||||
rd_ptr_all_equal <= '0';
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
end if;
|
||||
end process;
|
||||
|
||||
p_diag : process
|
||||
begin
|
||||
wait until clk'event and clk = '1';
|
||||
|
||||
for i in 0 TO MAX_OP_WIDTH-1 loop
|
||||
if rdreq_vec_int(i) = '1' then
|
||||
diag_rd_cnt(i) <= std_logic_vector(unsigned(diag_rd_cnt(i)) + "1");
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture;
|
||||
10
generic_ip/pixel_buffer/2/src/pixel_buffer_2_pkg.vhd
Normal file
10
generic_ip/pixel_buffer/2/src/pixel_buffer_2_pkg.vhd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
package pixel_buffer_2_pkg is
|
||||
|
||||
type data_array_t is array (natural range <>) of std_logic_vector;
|
||||
|
||||
end package;
|
||||
445
generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd
Normal file
445
generic_ip/pixel_buffer/2/src/pixel_buffer_zero_gap_2.vhd
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
-------------------------------------------------------------------------------
|
||||
--! @file
|
||||
--! @brief SOM FPGA pixel buffer zero gap
|
||||
--!
|
||||
--! @details This block is the data core dual channel pixel buffer wrapper for
|
||||
--! PD inline merging support.
|
||||
--!
|
||||
--! @b Clock/resets:
|
||||
--! @li clk : nominally 100MHz
|
||||
--! @li rst_n : active low reset for clk (asynchronous assert)
|
||||
--!
|
||||
--! @b Interfaces:
|
||||
--! @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
|
||||
--! @li empty : buffer empty status.
|
||||
--! @li full : buffer full (with look-ahead) status
|
||||
--! @li overrun : Pixel buffer overrun error status
|
||||
--! @li underrun : Pixel buffer underrun error status
|
||||
--! @li fp_drop : Fire pulse drop seen
|
||||
--! @li dbl_drop : Double fire pulse 'droppy' error status
|
||||
--! @li overlap_error : Merge overlap error status
|
||||
--! @li en_dual_data_path : Enable dual data path for zero gap
|
||||
--! @li print_data_width : print output data width (6 or 18 for GMA)
|
||||
--! @li clear_buffer : Pixel buffer clear pulse input
|
||||
--! @li start_req : start request pulse from print data sequencer, via delay queue
|
||||
--! @li start_req_first : start request first wave/next stripe status from print data sequencer, via delay queue
|
||||
--! @li start_req_last : start request last wave status from print data sequencer, via delay queue
|
||||
--! @li seq_1st_start_req : always goes when the first of start_req(3..0) goes so get early warning in bidir mode
|
||||
--! @li fire_req : Fire pulse request input
|
||||
--! @li drop_stripe : Overdrive, fire pulse has been ignored by Print Sequencer so drop stripe in Pixel Buffer
|
||||
--! @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)
|
||||
--!
|
||||
--! @b Clock-crossing considerations:
|
||||
--! @li Module is a single clock domain synchronous block
|
||||
--!
|
||||
--! @b Language build standard requirements:
|
||||
--! @li VHDL 2008
|
||||
--!
|
||||
--! @author Dave Steele
|
||||
--! @copyright (c) 2021 Global Inkjet Systems
|
||||
--! @date 2021-6-1
|
||||
-------------------------------------------------------------------------------
|
||||
-- altera vhdl_input_version vhdl_2008
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
use work.common_pkg.all;
|
||||
use work.pixel_buffer_2_pkg.all;
|
||||
|
||||
entity pixel_buffer_zero_gap_2 IS
|
||||
generic (
|
||||
MAX_OP_WIDTH : natural range 1 to 48 := 4;
|
||||
SHIFT_DEPTH : integer range 1 to 1024 := 324;
|
||||
SUB_HEADS : natural range 1 to 4 := 1; -- set to 1 if no sub heads
|
||||
PX_DEPTH : integer range 1 to 1024 := 128;
|
||||
RSVD_DEPTH : integer range 0 to 1024 := 0;
|
||||
FULL_MARGIN : integer range 2 to 1024 := 8;
|
||||
NUM_CHANS : integer range 1 to 4 := 2;
|
||||
NO_ZERO_GAP : boolean := false;
|
||||
EN_PEEK : boolean := false;
|
||||
VECTORED_RDREQ : boolean := false;
|
||||
DEVICE_FAMILY : string := "Cyclone V"; -- "Cyclone 10 LP"
|
||||
ADD_PADDING : boolean := false -- set to true for SI1536 padding
|
||||
);
|
||||
port
|
||||
(
|
||||
clk : in std_logic;
|
||||
rst_n : in std_logic;
|
||||
|
||||
pixel_buf_rdy : out std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
last_word : in std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
data : in data_array_t(NUM_CHANS-1 downto 0)(31 downto 0);
|
||||
wrreq : in std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
rdreq : in std_logic;
|
||||
rdreq_vec : in std_logic_vector(MAX_OP_WIDTH-1 downto 0) := (others => '0');
|
||||
rdreq_rdy : out std_logic;
|
||||
q : out data_array_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH*32-1 downto 0);
|
||||
|
||||
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;
|
||||
overlap_error : out std_logic;
|
||||
|
||||
en_dual_data_path : in std_logic;
|
||||
print_data_width : in std_logic_vector( 5 downto 0);
|
||||
clear_buffer : in std_logic;
|
||||
|
||||
start_req : in std_logic_vector(SUB_HEADS-1 downto 0);
|
||||
start_req_first : in std_logic;
|
||||
start_req_last : in std_logic;
|
||||
|
||||
seq_1st_start_req : in std_logic;
|
||||
fire_req : in std_logic; -- Must be the first fire_req if there are multiple phases (e.g. fire_req(0) that starts Print Sequencer)
|
||||
fire_req_start_merge : in std_logic; -- must be aligned with fire_req
|
||||
drop_stripe : in std_logic;
|
||||
sequencers_busy : out std_logic;
|
||||
px_buf_ch_nactive : out std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
fp_holdoff_update : in std_logic;
|
||||
wave_seq_len : in std_logic_vector(15 downto 0);
|
||||
|
||||
all_on : in std_logic;
|
||||
|
||||
diag_peek_sel : in std_logic;
|
||||
diag_peek_addr : in std_logic_vector(31 downto 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);
|
||||
diag_peek_wr : in std_logic;
|
||||
|
||||
diag_fire_req_count : out data_array_t(NUM_CHANS-1 downto 0)(31 downto 0);
|
||||
diag_fire_simg_count : out data_array_t(NUM_CHANS-1 downto 0)(31 downto 0);
|
||||
diag_last_stripe_count : out data_array_t(NUM_CHANS-1 downto 0)(31 downto 0);
|
||||
|
||||
diag_word_count : out std_logic_vector(6 downto 0)
|
||||
);
|
||||
end pixel_buffer_zero_gap_2;
|
||||
|
||||
|
||||
architecture rtl of pixel_buffer_zero_gap_2 is
|
||||
|
||||
constant TOTAL_DEPTH_LOG2 : integer := log2(PX_DEPTH + RSVD_DEPTH);
|
||||
constant NUM_CHANS_LOG2 : integer := log2(NUM_CHANS);
|
||||
|
||||
signal rd_req_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
type rdreq_vec_t is array (natural range <> ) of std_logic_vector;
|
||||
signal rdreq_vec_int : rdreq_vec_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH-1 downto 0);
|
||||
signal rd_req_rdy_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
signal empty_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal full_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal overrun_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal underrun_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal dbl_drop_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal fp_drop_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
signal sequencers_busy_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
signal last_stripe_dropped : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
signal start_req_int : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
type buf_vec_t is array (natural range <> ) of std_logic_vector;
|
||||
signal buf_active : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal buf_active_int : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal buf_active_late : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal buf_active_late_int : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal master_buf : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
signal clr_buf_active : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal clr_buf_active_rdreq : std_logic_vector(SUB_HEADS-1 downto 0);
|
||||
signal clr_buf_active_rdvec : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
signal is_last_wave : std_logic_vector(NUM_CHANS-1 downto 0);
|
||||
|
||||
signal rd_data : data_array_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH*32-1 downto 0);
|
||||
signal last_stripe : data_array_t(NUM_CHANS-1 downto 0)(MAX_OP_WIDTH-1 downto 0);
|
||||
signal diag_word_count_int : data_array_t(NUM_CHANS-1 downto 0)(6 downto 0);
|
||||
signal diag_peek_data_int : data_array_t(NUM_CHANS-1 downto 0)(31 downto 0);
|
||||
signal diag_peek_rdptr_int : data_array_t(NUM_CHANS-1 downto 0)( 7 downto 0);
|
||||
|
||||
signal fire_req_dly : std_logic;
|
||||
signal drop_stripe_d : std_logic;
|
||||
|
||||
signal is_zero_gap : std_logic;
|
||||
|
||||
signal buf_active_dly : buf_vec_t(SUB_HEADS-1 downto 0)(NUM_CHANS-1 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
-- Select source of diagnostic peek interfaces returned data
|
||||
diag_peek_data <= diag_peek_data_int(to_integer(unsigned(diag_peek_addr(MAX_OP_WIDTH+NUM_CHANS_LOG2 + TOTAL_DEPTH_LOG2 -1 downto MAX_OP_WIDTH+TOTAL_DEPTH_LOG2))));
|
||||
diag_peek_rdptr <= diag_peek_rdptr_int(to_integer(unsigned(diag_peek_addr(MAX_OP_WIDTH+NUM_CHANS_LOG2 + TOTAL_DEPTH_LOG2 -1 downto MAX_OP_WIDTH+TOTAL_DEPTH_LOG2))));
|
||||
diag_peek_wrptr <= diag_peek_wrptr_int(to_integer(unsigned(diag_peek_addr(MAX_OP_WIDTH+NUM_CHANS_LOG2 + TOTAL_DEPTH_LOG2 -1 downto MAX_OP_WIDTH+TOTAL_DEPTH_LOG2))));
|
||||
|
||||
|
||||
p_rdreq : process (all)
|
||||
begin
|
||||
rd_req_int <= (others => '0');
|
||||
rdreq_vec_int <= (others => (others => '0'));
|
||||
|
||||
for i in 0 to NUM_CHANS-1 loop
|
||||
if buf_active_late_int(0)(i) = '1' then
|
||||
rd_req_int(i) <= rdreq;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
for j in 0 to SUB_HEADS-1 loop
|
||||
for i in 0 to NUM_CHANS-1 loop
|
||||
if buf_active_late_int(j)(i) = '1' then
|
||||
rdreq_vec_int(i)(2*j+0) <= rdreq_vec(2*j+0);
|
||||
rdreq_vec_int(i)(2*j+1) <= rdreq_vec(2*j+1);
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
end process;
|
||||
|
||||
px_buf_ch_nactive <= not buf_active_int(0);
|
||||
|
||||
-- Amalgamate the status signals
|
||||
empty <= '1' when unsigned(not empty_int) = 0 else '0';
|
||||
full <= '1' when unsigned(full_int) /= 0 else '0';
|
||||
overrun <= '1' when unsigned(overrun_int) /= 0 else '0';
|
||||
underrun <= '1' when unsigned(underrun_int) /= 0 else '0';
|
||||
dbl_drop <= '1' when unsigned(dbl_drop_int) /= 0 else '0';
|
||||
fp_drop <= '1' when unsigned(fp_drop_int) /= 0 else '0';
|
||||
sequencers_busy <= '1' when unsigned(sequencers_busy_int) /= 0 else '0';
|
||||
|
||||
|
||||
buf_active_int <= buf_active when en_dual_data_path = '1' else (others => std_logic_vector(to_unsigned(1, NUM_CHANS)));
|
||||
buf_active_late_int <= buf_active_late when en_dual_data_path = '1' else (others => std_logic_vector(to_unsigned(1, NUM_CHANS)));
|
||||
|
||||
-- Tie off unused signals when no zero gap enabled
|
||||
GEN_IS_NOT_ZG : if NO_ZERO_GAP = true generate
|
||||
|
||||
is_zero_gap <= '0';
|
||||
empty_int(NUM_CHANS-1 downto 1) <= (others => '1');
|
||||
full_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
overrun_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
underrun_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
dbl_drop_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
fp_drop_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
sequencers_busy_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
pixel_buf_rdy(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
diag_peek_rdptr_int(NUM_CHANS-1 downto 1) <= (others => (others => '0'));
|
||||
diag_peek_wrptr_int(NUM_CHANS-1 downto 1) <= (others => (others => '0'));
|
||||
rd_req_rdy_int(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
clr_buf_active(NUM_CHANS-1 downto 1) <= (others => '0');
|
||||
|
||||
GEN_TIE_OFF_Q : for i in 1 to NUM_CHANS-1 generate
|
||||
q(i) <= (others => '0');
|
||||
end generate;
|
||||
|
||||
end generate;
|
||||
|
||||
-- Flag when zero gap is enabled
|
||||
GEN_IS_ZG : if NO_ZERO_GAP = false generate
|
||||
is_zero_gap <= '1';
|
||||
end generate;
|
||||
|
||||
-- -----------------------------------------------
|
||||
-- Instantiate the pixel buffers, both normal and
|
||||
-- (if enabled) auxiliary
|
||||
-- -----------------------------------------------
|
||||
|
||||
GEN_PX_BUF : for i in 0 to NUM_CHANS-1 generate
|
||||
|
||||
GEN_NO_ZG : if i = 0 or NO_ZERO_GAP = false generate
|
||||
|
||||
start_req_int(i) <= buf_active_int(0)(i) and seq_1st_start_req;
|
||||
|
||||
GEN_Q : for j in 0 to MAX_OP_WIDTH-1 generate
|
||||
q(i)(j*32+31 downto j*32) <= rd_data(i)(j*32+31 downto j*32) when buf_active_late_int(j/2)(i) else (others => '0');
|
||||
end generate;
|
||||
|
||||
clr_buf_active_rdreq(i) <= (last_stripe(i)(MAX_OP_WIDTH-1) and is_last_wave(i) and rd_req_int(i))
|
||||
or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens
|
||||
|
||||
GEN_SH: for j in 0 to SUB_HEADS-1 generate
|
||||
clr_buf_active_rdvec(j)(i) <= (last_stripe(i)(j*2) and is_last_wave(i) and rdreq_vec_int(i)(j*2))
|
||||
or last_stripe_dropped(i); -- if the last stripe of the image is dropped, the above case never happens
|
||||
|
||||
clr_buf_active(j)(i) <= clr_buf_active_rdvec(j)(i) when VECTORED_RDREQ else clr_buf_active_rdreq(i);
|
||||
end generate;
|
||||
pixel_buf_inst : entity work.pixel_buffer_2
|
||||
generic map (
|
||||
MAX_OP_WIDTH => MAX_OP_WIDTH,
|
||||
SHIFT_DEPTH => SHIFT_DEPTH,
|
||||
PX_DEPTH => PX_DEPTH,
|
||||
RSVD_DEPTH => RSVD_DEPTH,
|
||||
FULL_MARGIN => FULL_MARGIN,
|
||||
EN_PEEK => EN_PEEK,
|
||||
VECTORED_RDREQ => VECTORED_RDREQ,
|
||||
DEVICE_FAMILY => DEVICE_FAMILY,
|
||||
ADD_PADDING => ADD_PADDING
|
||||
)
|
||||
port map
|
||||
(
|
||||
clk => clk,
|
||||
rst_n => rst_n,
|
||||
|
||||
pixel_buf_rdy => pixel_buf_rdy(i),
|
||||
|
||||
last_word => last_word(i),
|
||||
data => data(i),
|
||||
wrreq => wrreq(i),
|
||||
|
||||
rdreq => rd_req_int(i),
|
||||
rdreq_vec => rdreq_vec_int(i),
|
||||
rdreq_rdy => rd_req_rdy_int(i),
|
||||
q => rd_data(i),
|
||||
last_word_op => last_stripe(i),
|
||||
|
||||
empty => empty_int(i),
|
||||
full => full_int(i),
|
||||
overrun => overrun_int(i),
|
||||
underrun => underrun_int(i),
|
||||
dbl_drop => dbl_drop_int(i),
|
||||
fp_drop => fp_drop_int(i),
|
||||
|
||||
print_data_width => print_data_width,
|
||||
clear_buffer => clear_buffer,
|
||||
|
||||
start_req => start_req_int(i),
|
||||
start_req_first => start_req_first,
|
||||
start_req_last => start_req_last,
|
||||
is_last_wave => is_last_wave(i),
|
||||
|
||||
all_on => all_on,
|
||||
|
||||
diag_peek_sel => diag_peek_sel,
|
||||
diag_peek_addr => diag_peek_addr,
|
||||
diag_peek_data => diag_peek_data_int(i),
|
||||
diag_peek_rdptr => diag_peek_rdptr_int(i),
|
||||
diag_peek_wrptr => diag_peek_wrptr_int(i),
|
||||
diag_peek_wdata => diag_peek_wdata,
|
||||
diag_peek_wr => diag_peek_wr,
|
||||
|
||||
fire_req => fire_req, -- Was used for drop detect, but drop now signalled explicitly
|
||||
drop_stripe => buf_active_int(0)(i) and drop_stripe_d, -- 1 clock delayed so that buf_active is already valid when pulsed
|
||||
sequencers_busy => sequencers_busy_int(i),
|
||||
last_stripe_dropped => last_stripe_dropped(i),
|
||||
fp_holdoff_update => fp_holdoff_update,
|
||||
wave_seq_len => wave_seq_len,
|
||||
|
||||
diag_word_count => diag_word_count_int(i)
|
||||
);
|
||||
end generate;
|
||||
|
||||
end generate;
|
||||
|
||||
diag_word_count <= diag_word_count_int(0);
|
||||
|
||||
-- -----------------------------------------------
|
||||
-- synchronous process to swing between buffers
|
||||
-- in zero gap mode
|
||||
-- -----------------------------------------------
|
||||
|
||||
P_SWING : process(rst_n, clk) is
|
||||
begin
|
||||
if rst_n = '0' then
|
||||
|
||||
master_buf <= std_logic_vector(to_unsigned(1, NUM_CHANS));
|
||||
buf_active <= (others => (others => '0'));
|
||||
buf_active_late <= (others => (others => '0'));
|
||||
overlap_error <= '0';
|
||||
fire_req_dly <= '0';
|
||||
buf_active_dly <= (others => (others => '0'));
|
||||
drop_stripe_d <= '0';
|
||||
|
||||
elsif clk'event and clk = '1' then
|
||||
for j in 0 to SUB_HEADS-1 loop
|
||||
for i in 0 to NUM_CHANS-1 loop
|
||||
buf_active(j)(i) <= buf_active(j)(i) and not clr_buf_active(j)(i);
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
fire_req_dly <= fire_req;
|
||||
buf_active_dly <= buf_active;
|
||||
|
||||
if clear_buffer = '1' or overlap_error = '1' then
|
||||
master_buf <= std_logic_vector(to_unsigned(1, NUM_CHANS));
|
||||
buf_active <= (others => (others => '0'));
|
||||
buf_active_late <= (others => (others => '0'));
|
||||
overlap_error <= overlap_error and not clear_buffer;
|
||||
end if;
|
||||
|
||||
if fire_req = '1' and fire_req_start_merge = '1' and en_dual_data_path = '1' then -- start new image (so start new pixel buffer)
|
||||
for j in 0 to SUB_HEADS-1 loop
|
||||
buf_active(j) <= buf_active(j) or master_buf; -- enable buffer to gate rd reqs in
|
||||
|
||||
if (master_buf and buf_active(j)) /= std_logic_vector(to_unsigned(0, NUM_CHANS)) then
|
||||
overlap_error <= en_dual_data_path;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
if is_zero_gap then
|
||||
master_buf <= master_buf(NUM_CHANS-2 downto 0) & master_buf(NUM_CHANS-1);
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- read requests may be active to pixel Buffer A after pixel Buffer B is started (fire_req and fire_req_start_merge)
|
||||
-- buf_active_late is used to gate read_req to pixel buffer and occurs a little after the main buf_active has changed
|
||||
-- and occurs per row (start req)
|
||||
for i in 0 to SUB_HEADS-1 loop
|
||||
if start_req(i) = '1' and start_req_first = '1' then
|
||||
buf_active_late(i) <= buf_active(i);
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
drop_stripe_d <= drop_stripe;
|
||||
end if;
|
||||
|
||||
end process;
|
||||
|
||||
P_DIAG : process(rst_n, clk) is
|
||||
begin
|
||||
if rst_n = '0' then
|
||||
|
||||
diag_fire_req_count <= (others => (others => '0'));
|
||||
diag_fire_simg_count <= (others => (others => '0'));
|
||||
diag_last_stripe_count <= (others => (others => '0'));
|
||||
|
||||
elsif clk'event and clk = '1' then
|
||||
|
||||
if clear_buffer = '1' then
|
||||
diag_fire_req_count <= (others => (others => '0'));
|
||||
diag_fire_simg_count <= (others => (others => '0'));
|
||||
diag_last_stripe_count <= (others => (others => '0'));
|
||||
elsif fire_req_dly = '1' then
|
||||
for i in 0 to NUM_CHANS-1 loop
|
||||
if buf_active_int(0)(i) = '1' then
|
||||
diag_fire_req_count(i) <= std_logic_vector(unsigned(diag_fire_req_count(i)) + 1);
|
||||
end if;
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
for i in 0 to NUM_CHANS-1 loop
|
||||
if buf_active(0)(i) = '1' and buf_active_dly(0)(i) = '0' then
|
||||
diag_fire_simg_count(i) <= std_logic_vector(unsigned(diag_fire_simg_count(i)) + 1);
|
||||
diag_fire_req_count(i) <= std_logic_vector(unsigned(diag_fire_req_count(i)) + 1); -- preincrement or we lose 1 because buf_active_int runs from start_req
|
||||
elsif buf_active(0)(i) = '0' and buf_active_dly(0)(i) = '1' then
|
||||
diag_last_stripe_count(i) <= std_logic_vector(unsigned(diag_last_stripe_count(i)) + 1);
|
||||
end if;
|
||||
|
||||
end loop;
|
||||
|
||||
end if;
|
||||
|
||||
end process;
|
||||
|
||||
end architecture;
|
||||
2
generic_ip/pixel_buffer/versions.txt
Normal file
2
generic_ip/pixel_buffer/versions.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
v1 fpga vendor independent
|
||||
v2 fully working zero gap/inline merge
|
||||
Loading…
Add table
Add a link
Reference in a new issue