CORE-798 Make EL GIP Library FPGA Vendor Independent.
data_streamer_8 V8 - FPGA Vendor Independent. Uses Generic FIFOs from common/1
This commit is contained in:
parent
368cb565ea
commit
6e3d0fb467
2 changed files with 871 additions and 0 deletions
870
generic_ip/data_streamer/8/src/data_streamer_8.vhd
Normal file
870
generic_ip/data_streamer/8/src/data_streamer_8.vhd
Normal file
|
|
@ -0,0 +1,870 @@
|
|||
-------------------------------------------------------------------------------
|
||||
--! @file
|
||||
--! @brief generic data streamer
|
||||
--!
|
||||
--! @details 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 Avalon MM master avm_rx_* : Avalon bus interface to memory system
|
||||
--! @li control_clear_cmd : Clear command (and TLB) buffer
|
||||
--! @li control_clear_errors : Clear error statuses
|
||||
--! @li control_msb : Set MSB order
|
||||
--! @li control_watermark : Watermark on command queue for interrupt generation
|
||||
--! @li *_err : Various error statues
|
||||
--! @li auto_cmd_active : Auto load commands active status_queue_space
|
||||
--! @li status_queue_space : Command queue space status
|
||||
--! @li dest_port_* : Interface to pixel buffers of each head
|
||||
--! @li irq : Interrupt output
|
||||
--!
|
||||
--! @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-7-13
|
||||
-------------------------------------------------------------------------------
|
||||
-- altera vhdl_input_version vhdl_2008
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.std_logic_misc.all;
|
||||
|
||||
use work.pkg_functions.all;
|
||||
|
||||
entity data_streamer_8 is
|
||||
generic(
|
||||
NUM_EXT_DSTS : natural range 1 to 16 := 5;
|
||||
CMD_QUEUE_DEPTH : natural range 1 to 1024 := 32;
|
||||
EXCLUDE_VIRTUAL_MAPPING_LOGIC : boolean := false;
|
||||
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
|
||||
);
|
||||
port(
|
||||
|
||||
clk : in std_logic;
|
||||
rst_n : in std_logic;
|
||||
|
||||
control_clear_cmd : in std_logic;
|
||||
control_clear_errors : in std_logic;
|
||||
control_msb : in std_logic;
|
||||
control_watermark : in std_logic_vector(7 downto 0);
|
||||
control_disable : in std_logic;
|
||||
control_clr_dst0_count : in std_logic;
|
||||
|
||||
cmd_port_wr : in std_logic;
|
||||
cmd_port : in std_logic_vector(31 downto 0);
|
||||
|
||||
tlb_mismatch_err : out std_logic;
|
||||
tlb_empty_err : out std_logic;
|
||||
auto_load_err : out std_logic;
|
||||
bad_cmd_err : out std_logic;
|
||||
cpu_race_err : out std_logic;
|
||||
overrun_err : out std_logic;
|
||||
auto_cmd_active : out std_logic;
|
||||
status_queue_space : out std_logic_vector(5 downto 0);
|
||||
|
||||
avm_rx_waitrequest : in std_logic;
|
||||
avm_rx_burstcount : out std_logic_vector(11 downto 0);
|
||||
avm_rx_address : out std_logic_vector(31 downto 0);
|
||||
avm_rx_read : out std_logic;
|
||||
avm_rx_readdata : in std_logic_vector(31 downto 0);
|
||||
avm_rx_readdatavalid : in std_logic;
|
||||
|
||||
dest_port_wr : out std_logic_vector(NUM_EXT_DSTS - 1 downto 0);
|
||||
dest_port_wr_data : out std_logic_vector(31 downto 0);
|
||||
dest_port_rdy : in std_logic_vector(NUM_EXT_DSTS - 1 downto 0);
|
||||
dest_port_last_word : out std_logic;
|
||||
|
||||
ld_q_redirect_addr : in std_logic_vector(31 downto 0);
|
||||
|
||||
transfer_active : out std_logic;
|
||||
|
||||
irq : out std_logic;
|
||||
|
||||
handle : out std_logic_vector(11 downto 0);
|
||||
|
||||
ip_id_ip_number : out std_logic_vector(7 downto 0);
|
||||
ip_id_mfr_number : out std_logic_vector(7 downto 0);
|
||||
ip_ver_minor_number : out std_logic_vector(7 downto 0);
|
||||
ip_ver_major_number : out std_logic_vector(7 downto 0);
|
||||
|
||||
diag_step_mode : in std_logic := '0';
|
||||
diag_step : in std_logic := '0';
|
||||
|
||||
diag_dst0_count : out std_logic_vector(31 downto 0);
|
||||
debug_out : out std_logic_vector(19 downto 0);
|
||||
diag_1 : out std_logic_vector(31 downto 0);
|
||||
diag_2 : out std_logic_vector(31 downto 0);
|
||||
|
||||
diag_cmd_q_write : out std_logic;
|
||||
diag_cmd_q_write_data : out std_logic_vector(31 downto 0)
|
||||
|
||||
);
|
||||
|
||||
end entity data_streamer_8;
|
||||
|
||||
architecture rtl of data_streamer_8 is
|
||||
|
||||
constant CONST_IP_ID_NUMBER : std_logic_vector(7 downto 0) := 8x"0d";
|
||||
constant CONST_IP_ID_MFR_NUMBER : std_logic_vector(7 downto 0) := 8x"04";
|
||||
constant CONST_IP_VER_MINOR : std_logic_vector(7 downto 0) := 8x"00";
|
||||
constant CONST_IP_VER_MAJOR : std_logic_vector(7 downto 0) := 8x"08";
|
||||
|
||||
subtype CMD_BITS is natural range 3 downto 0;
|
||||
subtype CMD_COMMON_BITS is natural range 3 downto 1;
|
||||
subtype NUM_PARAMS is natural range 7 downto 4;
|
||||
subtype CMD_DEST_BITS is natural range 11 downto 8;
|
||||
subtype CMD_PARAM_0 is natural range 31 downto 12;
|
||||
subtype CMD_PARAM0_WORDLEN is natural range 31 downto 20;
|
||||
subtype CMD_PARAM0_HDL is natural range 27 downto 16;
|
||||
subtype CMD_PARAM1_IDX_BITS is natural range 11 downto 0;
|
||||
|
||||
subtype CMD_PARAM0_LOOP_CNT is natural range 19 downto 12;
|
||||
|
||||
constant CMD_REDIRECT_BIT : integer := 7;
|
||||
constant CMD_LAST_BIT : integer := 7;
|
||||
|
||||
constant CMD_RD_DATA_PADDR : std_logic_vector := 4x"0";
|
||||
constant CMD_RD_DATA_VADDR : std_logic_vector := 4x"1";
|
||||
constant CMD_RD_DATA : std_logic_vector := 3x"0";
|
||||
constant CMD_LD_ADDR_MAP : std_logic_vector := 4x"2";
|
||||
constant CMD_LD_CMD_Q : std_logic_vector := 4x"3";
|
||||
constant CMD_LD_CMD_Q_PHY : std_logic_vector := 4x"4";
|
||||
constant CMD_NOP : std_logic_vector := 4x"f";
|
||||
|
||||
constant CMD_QUEUE_DEPTH_LOG2 : integer := log2(CMD_QUEUE_DEPTH) - 1;
|
||||
|
||||
constant PAGE_WORD_LEN : integer := 1024;
|
||||
|
||||
signal tlb_write : std_logic;
|
||||
signal tlb_write_last : std_logic;
|
||||
signal tlb_wr_data : std_logic_vector(39 downto 0);
|
||||
signal tlb_read : std_logic;
|
||||
signal tlb_read_last : std_logic;
|
||||
signal tlb_rd_data : std_logic_vector(39 downto 0);
|
||||
signal tlb_empty : std_logic;
|
||||
|
||||
signal usedw : std_logic_vector(CMD_QUEUE_DEPTH_LOG2 - 1 downto 0);
|
||||
|
||||
signal cmd_data : std_logic_vector(31 downto 0);
|
||||
signal cmd_data_q : std_logic_vector(31 downto 0);
|
||||
signal cmd_read : std_logic;
|
||||
signal cmd_error : std_logic;
|
||||
signal cmd_gobble : std_logic;
|
||||
signal cmd_empty : std_logic;
|
||||
signal cmd_full : std_logic;
|
||||
|
||||
signal cmd_q_write : std_logic;
|
||||
signal cmd_q_write_data : std_logic_vector(31 downto 0);
|
||||
|
||||
|
||||
signal cmd_dest_rdy : std_logic;
|
||||
|
||||
signal data_cmd_active : std_logic;
|
||||
signal cmd_available : std_logic;
|
||||
signal cmd_pending : std_logic;
|
||||
signal cmd_q_write_int : std_logic;
|
||||
|
||||
signal dst_sel : std_logic_vector(3 downto 0);
|
||||
|
||||
signal paddr : std_logic_vector(19 downto 0);
|
||||
|
||||
signal remaining_burst : std_logic_vector(11 downto 0);
|
||||
signal remaining_burst_is_zero : std_logic;
|
||||
signal addr_offset_is_zero : std_logic;
|
||||
signal fetch_vaddr : std_logic;
|
||||
signal curr_vaddr : std_logic_vector(31 downto 0);
|
||||
signal checked_tlb : std_logic;
|
||||
signal vaddr_match : std_logic;
|
||||
signal pop_parameter : std_logic;
|
||||
signal dst_port_rdy : std_logic;
|
||||
|
||||
signal count_to_page_bdry : unsigned(9 downto 0);
|
||||
signal use_latched_addr : std_logic;
|
||||
signal page_num : std_logic_vector(19 downto 0);
|
||||
|
||||
signal dest_port_wr_int : std_logic_vector(NUM_EXT_DSTS downto 0);
|
||||
signal dest_port_wr_data_int : std_logic_vector(31 downto 0);
|
||||
signal dest_port_rdy_int : std_logic_vector(NUM_EXT_DSTS downto 0);
|
||||
|
||||
signal okay_to_transfer : std_logic;
|
||||
signal multi_burst_last : std_logic;
|
||||
|
||||
signal avm_active_read : std_logic;
|
||||
signal read_committed : std_logic;
|
||||
signal tlb_cmd_active : std_logic;
|
||||
|
||||
signal cmd_is_nop : std_logic;
|
||||
|
||||
signal loop_count : std_logic_vector(7 downto 0);
|
||||
signal loop_count_is_zero : std_logic;
|
||||
signal loop_is_first : std_logic;
|
||||
|
||||
signal update_addr : std_logic;
|
||||
|
||||
signal use_redirect_addr : std_logic;
|
||||
signal last_rd_block : std_logic;
|
||||
|
||||
signal cmd_port_wr_int : std_logic;
|
||||
signal cmd_port_int : std_logic_vector(31 downto 0);
|
||||
|
||||
signal is_slim : std_logic;
|
||||
|
||||
signal cmd_available_step : std_logic;
|
||||
|
||||
signal cmd_queue_rst_sreg : std_logic_vector(2 downto 0);
|
||||
signal cmd_queue_rst : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
ip_id_ip_number <= CONST_IP_ID_NUMBER;
|
||||
ip_id_mfr_number <= CONST_IP_ID_MFR_NUMBER;
|
||||
ip_ver_minor_number <= CONST_IP_VER_MINOR;
|
||||
ip_ver_major_number <= CONST_IP_VER_MAJOR;
|
||||
|
||||
debug_out <= dst_port_rdy & dst_sel & cmd_available & data_cmd_active & cmd_pending & remaining_burst;
|
||||
diag_1 <= cmd_data;
|
||||
|
||||
-- ---------------------------------------
|
||||
-- COMMAND QUEUE
|
||||
-- ---------------------------------------
|
||||
|
||||
-- This process initialises a reset shift register for the command queue whenever the FPGA is reset
|
||||
-- to an all ones pattern. When the FPGA reset goes away the shift register starts filling up with '0's.
|
||||
CMD_Q_RST : process(clk, rst_n)
|
||||
begin
|
||||
if rst_n = '0' then
|
||||
cmd_queue_rst_sreg <= (others => '1');
|
||||
elsif (clk'event and clk = '1') then
|
||||
-- Shift in '0' on every rising edge of the clock when there is no FPGA reset active
|
||||
cmd_queue_rst_sreg <= cmd_queue_rst_sreg(cmd_queue_rst_sreg'LENGTH - 2 downto 0) & '0';
|
||||
end if;
|
||||
end process CMD_Q_RST;
|
||||
|
||||
-- The final reset driving the command queue is the logic OR of control_clear_cmd comming from
|
||||
-- the register block and the MSB of the reset shift register. This results on the command queue
|
||||
-- receiving a clear whenever the FPGA itself is reset.
|
||||
cmd_queue_rst <= control_clear_cmd or cmd_queue_rst_sreg(cmd_queue_rst_sreg'LENGTH - 1);
|
||||
|
||||
-- Instantiate the command queue
|
||||
cmd_queue_inst : entity work.sync_fifo
|
||||
generic map(
|
||||
DATA_WIDTH => 32,
|
||||
DEPTH => CMD_QUEUE_DEPTH,
|
||||
REGISTER_OUTPUT => "OFF",
|
||||
NEARLY_FULL => 31,
|
||||
NEARLY_EMPTY => 2,
|
||||
DEVICE_FAMILY => DEVICE_FAMILY,
|
||||
SHOWAHEAD => "ON",
|
||||
CHECKING => "OFF"
|
||||
)
|
||||
port map
|
||||
(
|
||||
clk => clk,
|
||||
sclr => cmd_queue_rst,
|
||||
|
||||
wrreq => cmd_q_write,
|
||||
wrdata => cmd_q_write_data,
|
||||
|
||||
rdreq => cmd_read,
|
||||
rddata => cmd_data_q,
|
||||
|
||||
empty => cmd_empty,
|
||||
full => cmd_full,
|
||||
usedw => usedw
|
||||
);
|
||||
|
||||
-- ---------------------------------------
|
||||
-- Address translation queue
|
||||
-- ---------------------------------------
|
||||
|
||||
GEN_TLB : if not EXCLUDE_VIRTUAL_MAPPING_LOGIC generate
|
||||
tlb_queue_inst : entity work.sync_fifo
|
||||
generic map(
|
||||
DATA_WIDTH => 40,
|
||||
DEPTH => CMD_QUEUE_DEPTH,
|
||||
REGISTER_OUTPUT => "OFF",
|
||||
NEARLY_FULL => 39,
|
||||
NEARLY_EMPTY => 2,
|
||||
DEVICE_FAMILY => DEVICE_FAMILY,
|
||||
SHOWAHEAD => "ON",
|
||||
CHECKING => "OFF"
|
||||
)
|
||||
port map
|
||||
(
|
||||
clk => clk,
|
||||
sclr => cmd_queue_rst,
|
||||
|
||||
wrreq => tlb_write,
|
||||
wrdata => tlb_wr_data,
|
||||
|
||||
rdreq => tlb_read,
|
||||
rddata => tlb_rd_data,
|
||||
|
||||
empty => tlb_empty
|
||||
);
|
||||
|
||||
end generate;
|
||||
|
||||
|
||||
-- ---------------------------------------
|
||||
-- COMBINATORIAL SIGNALS
|
||||
-- ---------------------------------------
|
||||
|
||||
GEN_SLIM : if EXCLUDE_VIRTUAL_MAPPING_LOGIC generate
|
||||
is_slim <= '1';
|
||||
end generate;
|
||||
|
||||
GEN_NOT_SLIM : if not EXCLUDE_VIRTUAL_MAPPING_LOGIC generate
|
||||
is_slim <= '0';
|
||||
|
||||
-- Flag when the address low bits (page offset) are 0
|
||||
addr_offset_is_zero <= '1' when curr_vaddr(11 downto 2) = 10x"0" else '0';
|
||||
|
||||
-- Flag when remaining_burst count is 0
|
||||
remaining_burst_is_zero <= '1' when remaining_burst = 12x"0" else '0';
|
||||
|
||||
-- Calculate the number of words from the address page offset to the end of the page
|
||||
count_to_page_bdry <= PAGE_WORD_LEN - unsigned(curr_vaddr(11 downto 2));
|
||||
|
||||
page_num <= curr_vaddr(31 downto 12) when use_latched_addr = '1' else cmd_data_q(31 downto 12);
|
||||
|
||||
-- Flag when the command queue output (paramter 0 bits) match the TLB virtual address
|
||||
vaddr_match <= '1' when page_num = tlb_rd_data(19 downto 0) else '0';
|
||||
end generate;
|
||||
|
||||
cmd_q_write_int <= cmd_port_wr_int or dest_port_wr_int(NUM_EXT_DSTS);
|
||||
cmd_q_write <= cmd_q_write_int and not cmd_full;
|
||||
cmd_q_write_data <= cmd_port_int when dest_port_wr_int(NUM_EXT_DSTS) = '0' else dest_port_wr_data;
|
||||
|
||||
-- extract the remaining space for the command queue
|
||||
status_queue_space <= (others => '0') when cmd_full = '1' else std_logic_vector(to_unsigned((CMD_QUEUE_DEPTH - to_integer(unsigned(usedw))), 6));
|
||||
|
||||
-- Pop the command word from the queue if able to process.
|
||||
-- Pop parameters if pop_parameter asserted. Pop error values when cmd_gobble asserted.
|
||||
cmd_read <= (cmd_available_step and not cmd_pending and not data_cmd_active and not tlb_cmd_active and loop_count_is_zero) or
|
||||
cmd_gobble or pop_parameter;
|
||||
|
||||
-- Flag when there is enough space in the command queue for a LD_CMD_Q transfer
|
||||
cmd_dest_rdy <= '1' when status_queue_space >= remaining_burst else '0';
|
||||
|
||||
dest_port_wr <= dest_port_wr_int(NUM_EXT_DSTS - 1 downto 0);
|
||||
dest_port_wr_data <= dest_port_wr_data_int;
|
||||
dest_port_rdy_int <= cmd_dest_rdy & dest_port_rdy;
|
||||
|
||||
-- Flag when the selected destination port is ready to receive
|
||||
dst_port_rdy <= dest_port_rdy_int(to_integer(unsigned(dst_sel)));
|
||||
|
||||
-- Flag when its okay to transfer, as source and destination are ready
|
||||
okay_to_transfer <= avm_active_read and dst_port_rdy;
|
||||
|
||||
-- Combined errors signal
|
||||
cmd_error <= (not is_slim and (tlb_mismatch_err or tlb_empty_err)) or auto_load_err or
|
||||
bad_cmd_err or cpu_race_err or overrun_err;
|
||||
|
||||
-- An AVM read is active when read asserted and no wait request
|
||||
avm_active_read <= avm_rx_read and not avm_rx_waitrequest;
|
||||
|
||||
cmd_is_nop <= '1' when cmd_data_q(3 downto 0) = CMD_NOP else '0';
|
||||
|
||||
transfer_active <= data_cmd_active;
|
||||
|
||||
loop_count_is_zero <= '1' when loop_count = 8x"0" else '0';
|
||||
|
||||
-- ---------------------------------------
|
||||
-- MAIN COMMAND PROCESS
|
||||
-- ---------------------------------------
|
||||
|
||||
-- Process to update internal state
|
||||
CMD_PROC : process(clk, rst_n)
|
||||
variable var_multi_burst : std_logic;
|
||||
variable var_remaining_burst : std_logic_vector(11 downto 0);
|
||||
begin
|
||||
if rst_n = '0' then
|
||||
data_cmd_active <= '0';
|
||||
cmd_pending <= '0';
|
||||
avm_rx_burstcount <= (others => '0');
|
||||
avm_rx_read <= '0';
|
||||
tlb_mismatch_err <= '0';
|
||||
tlb_empty_err <= '0';
|
||||
auto_load_err <= '0';
|
||||
bad_cmd_err <= '0';
|
||||
cpu_race_err <= '0';
|
||||
overrun_err <= '0';
|
||||
cmd_gobble <= '0';
|
||||
cmd_available <= '0';
|
||||
cmd_available_step <= '0';
|
||||
cmd_data <= (others => '0');
|
||||
fetch_vaddr <= '0';
|
||||
tlb_write <= '0';
|
||||
tlb_write_last <= '0';
|
||||
tlb_read <= '0';
|
||||
tlb_read_last <= '0';
|
||||
checked_tlb <= '0';
|
||||
pop_parameter <= '0';
|
||||
use_latched_addr <= '0';
|
||||
irq <= '0';
|
||||
dest_port_wr_int <= (others => '0');
|
||||
dest_port_last_word <= '0';
|
||||
read_committed <= '0';
|
||||
multi_burst_last <= '0';
|
||||
tlb_cmd_active <= '0';
|
||||
auto_cmd_active <= '0';
|
||||
handle <= (others => '0');
|
||||
diag_dst0_count <= (others => '0');
|
||||
loop_count <= (others => '0');
|
||||
loop_is_first <= '0';
|
||||
update_addr <= '0';
|
||||
use_redirect_addr <= '0';
|
||||
last_rd_block <= '0';
|
||||
cmd_port_wr_int <= '0';
|
||||
cmd_port_int <= (others => '0');
|
||||
dest_port_wr_data_int <= (others => '0');
|
||||
remaining_burst <= (others => '0');
|
||||
dst_sel <= (others => '0');
|
||||
diag_2 <= (others => '0');
|
||||
avm_rx_address <= (others => '0');
|
||||
curr_vaddr <= (others => '0');
|
||||
paddr <= (others => '0');
|
||||
diag_cmd_q_write <= '0';
|
||||
diag_cmd_q_write_data <= (others => '0');
|
||||
elsif (clk'event and clk = '1') then
|
||||
|
||||
diag_cmd_q_write_data <= cmd_q_write_data;
|
||||
diag_cmd_q_write <= cmd_q_write;
|
||||
|
||||
-- Default pulse signals
|
||||
avm_rx_read <= '0';
|
||||
cmd_gobble <= '0';
|
||||
pop_parameter <= '0';
|
||||
tlb_write <= '0';
|
||||
tlb_read <= '0';
|
||||
tlb_read_last <= tlb_read;
|
||||
tlb_write_last <= tlb_write;
|
||||
dest_port_last_word <= '0';
|
||||
var_remaining_burst := remaining_burst;
|
||||
|
||||
cmd_port_wr_int <= cmd_port_wr;
|
||||
cmd_port_int <= cmd_port;
|
||||
|
||||
-- Start by assuming this is a multi-burst command (i.e. will traverse one or more page boundaries)
|
||||
var_multi_burst := '1';
|
||||
|
||||
-- A command is available if at least two words in the queue, or in middle of a loop
|
||||
if to_integer(unsigned(usedw(CMD_QUEUE_DEPTH_LOG2 - 1 downto 1))) /= 0 or
|
||||
cmd_full = '1' or loop_count_is_zero = '0' or (cmd_pending = '0' and cmd_is_nop = '1' and cmd_empty = '0') then
|
||||
cmd_available <= not control_disable;
|
||||
cmd_available_step <= not control_disable and not (diag_step_mode and not diag_step);
|
||||
else
|
||||
cmd_available <= '0';
|
||||
cmd_available_step <= '0';
|
||||
end if;
|
||||
|
||||
-- Latch the command value when not pending for use in processing any subsequent parameters
|
||||
if (cmd_pending = '0' and loop_count_is_zero = '1') or (is_slim = '0' and tlb_write = '1' and cmd_available = '1') then
|
||||
cmd_data <= cmd_data_q;
|
||||
end if;
|
||||
|
||||
-- If idle, and there's a command ready to process...
|
||||
if (cmd_available_step = '1' or cmd_pending = '1') and data_cmd_active = '0' and tlb_cmd_active = '0' and cmd_error = '0' then
|
||||
|
||||
case cmd_data(CMD_BITS) is
|
||||
|
||||
-- When the command is a read data with physical address, get the parameters and
|
||||
-- send out the burst command
|
||||
when CMD_RD_DATA_PADDR | CMD_LD_CMD_Q_PHY =>
|
||||
|
||||
var_remaining_burst := (others => '0'); -- Physical accesses always a single burst
|
||||
if cmd_pending = '0' then
|
||||
avm_rx_burstcount <= cmd_data(CMD_PARAM0_WORDLEN);
|
||||
remaining_burst <= cmd_data(CMD_PARAM0_WORDLEN);
|
||||
update_addr <= '1';
|
||||
|
||||
if cmd_data(CMD_BITS) = CMD_LD_CMD_Q_PHY then
|
||||
-- Destination index for command queue is one above the defined number of external destinations.
|
||||
dst_sel <= std_logic_vector(to_unsigned(NUM_EXT_DSTS, 4));
|
||||
use_redirect_addr <= cmd_data(CMD_REDIRECT_BIT);
|
||||
last_rd_block <= '0';
|
||||
update_addr <= not cmd_data(CMD_REDIRECT_BIT);
|
||||
|
||||
-- Flag that auto-loading commands are now active whenever a LD_CMD_Q is written.
|
||||
-- This will not be cleared until the command queue is empty and no outstanding
|
||||
-- data transfers
|
||||
auto_cmd_active <= '1';
|
||||
|
||||
else
|
||||
use_redirect_addr <= '0';
|
||||
last_rd_block <= cmd_data(CMD_LAST_BIT);
|
||||
-- Latch the destination index
|
||||
dst_sel <= cmd_data(CMD_DEST_BITS);
|
||||
|
||||
end if;
|
||||
|
||||
if loop_count = 8x"0" then
|
||||
loop_count <= std_logic_vector(cmd_data_q(CMD_PARAM0_LOOP_CNT));
|
||||
loop_is_first <= '1';
|
||||
else
|
||||
loop_count <= std_logic_vector(unsigned(loop_count) - 1);
|
||||
loop_is_first <= '0';
|
||||
end if;
|
||||
|
||||
cmd_pending <= '1';
|
||||
|
||||
else
|
||||
if cmd_data(CMD_BITS) = CMD_LD_CMD_Q_PHY then
|
||||
|
||||
-- It is an error to have insufficient space left when executing LD_CMD_Q, as
|
||||
-- it is a lock condition.
|
||||
if not dst_port_rdy then
|
||||
auto_load_err <= '1';
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
diag_2 <= cmd_data_q;
|
||||
|
||||
if loop_is_first = '1' then
|
||||
if use_redirect_addr = '0' then
|
||||
avm_rx_address <= cmd_data_q(31 downto 2) & "00";
|
||||
else
|
||||
avm_rx_address <= ld_q_redirect_addr(31 downto 2) & "00";
|
||||
end if;
|
||||
else
|
||||
if update_addr then
|
||||
avm_rx_address(31 downto 2) <= std_logic_vector(unsigned(avm_rx_address(31 downto 2)) + unsigned(avm_rx_burstcount));
|
||||
update_addr <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
avm_rx_read <= dst_port_rdy and not avm_active_read;
|
||||
data_cmd_active <= okay_to_transfer;
|
||||
cmd_pending <= not okay_to_transfer;
|
||||
|
||||
if avm_active_read = '1' then
|
||||
remaining_burst <= var_remaining_burst;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- When the command is a read data with virtual address, get the parameters and send
|
||||
-- out the burst command(s), translating virtual to physical address at each page.
|
||||
-- Reading data into the command queue (CMD_LD_CMD_Q) is almost identical, but for a
|
||||
-- different destination.
|
||||
when CMD_RD_DATA_VADDR | CMD_LD_CMD_Q =>
|
||||
if is_slim = '0' then
|
||||
if cmd_pending = '0' then
|
||||
-- Latch the word length into the remaining burst counter
|
||||
remaining_burst <= cmd_data(CMD_PARAM0_WORDLEN);
|
||||
|
||||
loop_is_first <= '1';
|
||||
|
||||
if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then
|
||||
-- Destination index for command queue is one above the defined number of external desitinations.
|
||||
dst_sel <= std_logic_vector(to_unsigned(NUM_EXT_DSTS, 4));
|
||||
|
||||
-- Flag that auto-loading commands are now active whenever a LD_CMD_Q is written.
|
||||
-- This will not be cleared until the command queue is empty and no outstanding
|
||||
-- data transfers
|
||||
auto_cmd_active <= '1';
|
||||
else
|
||||
-- Latch the destination index
|
||||
dst_sel <= cmd_data(CMD_DEST_BITS);
|
||||
end if;
|
||||
|
||||
-- Command is now pending until parameters (if any processed) and command completed.
|
||||
cmd_pending <= '1';
|
||||
|
||||
-- For virtual commands, flag to pop the virtual address parameter
|
||||
fetch_vaddr <= '1';
|
||||
|
||||
-- Won't commit to the read until cmd_pending phase and destination is ready
|
||||
read_committed <= '0';
|
||||
|
||||
-- Clear the state that inidicates that the correct TLB map is found.
|
||||
checked_tlb <= '0';
|
||||
|
||||
elsif dst_port_rdy = '1' or read_committed = '1' then
|
||||
|
||||
-- As the destination has been seen as ready, commit to the reads, including the multi-burst page crossing accesses
|
||||
read_committed <= '1';
|
||||
|
||||
-- If a new TLB entry was extracted, check it matches otherwise it's an error
|
||||
if tlb_read_last = '1' and vaddr_match = '0' then
|
||||
tlb_mismatch_err <= '1';
|
||||
end if;
|
||||
|
||||
-- If the virtual address does not match that at the o/p of the TLB queue,
|
||||
-- pop the value from the queue to get the next one. Only check this if not validated
|
||||
-- before, since the parameter may have been popped from the queue.
|
||||
if checked_tlb = '0' then
|
||||
-- Pop the entry
|
||||
tlb_read <= not vaddr_match and not tlb_read and not tlb_empty;
|
||||
|
||||
-- It is an error if the queue is empty
|
||||
tlb_empty_err <= tlb_empty;
|
||||
|
||||
-- Flag that we checked the TLB output already
|
||||
checked_tlb <= '1';
|
||||
|
||||
else
|
||||
|
||||
-- If first cycle with virtual address parameter from queue, latch the
|
||||
-- low bits this cycle to relieve timing on processing in the following cycles.
|
||||
if fetch_vaddr = '1' then
|
||||
if use_latched_addr = '0' then
|
||||
curr_vaddr <= cmd_data_q;
|
||||
diag_2 <= cmd_data_q;
|
||||
end if;
|
||||
fetch_vaddr <= '0';
|
||||
|
||||
elsif data_cmd_active = '0' then
|
||||
-- If address low bits are not page aligned...
|
||||
if not addr_offset_is_zero then
|
||||
|
||||
-- If burst does not cross a page boundary then set burst length to remaining
|
||||
-- words, set remaining count to 0 and clear multi-burst flag as this is the last
|
||||
-- transfer.
|
||||
if count_to_page_bdry >= unsigned(remaining_burst) then
|
||||
var_multi_burst := '0';
|
||||
|
||||
avm_rx_burstcount <= remaining_burst;
|
||||
var_remaining_burst := (others => '0');
|
||||
-- If burst crosses a page boundary, set the burst count to take us up to
|
||||
-- the next page boundary, and subtract that length from remaining count.
|
||||
-- Subsequent bursts should all be page aligned.
|
||||
else
|
||||
avm_rx_burstcount <= "00" & std_logic_vector(count_to_page_bdry);
|
||||
var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - count_to_page_bdry);
|
||||
end if;
|
||||
|
||||
-- Address low bits are page aligned...
|
||||
else
|
||||
-- If remaining burst is equal or less than a page, set burst to be remaining
|
||||
-- count, set the count to 0 and clear the multi-burst variable as this is the last
|
||||
-- transfer.
|
||||
if unsigned(remaining_burst) <= PAGE_WORD_LEN then
|
||||
var_multi_burst := '0';
|
||||
|
||||
avm_rx_burstcount <= remaining_burst;
|
||||
var_remaining_burst := (others => '0');
|
||||
|
||||
-- If the remaining count is greater than a page, set the burst length to a page
|
||||
-- and subtract the length from the remaining count.
|
||||
else
|
||||
avm_rx_burstcount <= std_logic_vector(to_unsigned(PAGE_WORD_LEN, 12));
|
||||
var_remaining_burst := std_logic_vector(unsigned(remaining_burst) - PAGE_WORD_LEN);
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- When transfer initiated, update the remaining burst count to take in to account
|
||||
-- the words requested.
|
||||
if avm_active_read = '1' then
|
||||
remaining_burst <= var_remaining_burst;
|
||||
end if;
|
||||
|
||||
-- The address to use is the TLB physical address bits, and the addr lower bits.
|
||||
avm_rx_address <= tlb_rd_data(39 downto 20) & curr_vaddr(11 downto 0);
|
||||
|
||||
-- Issue the read command. Hold until active (no wait request).
|
||||
avm_rx_read <= not avm_active_read;
|
||||
|
||||
-- Flag as data transfer active only if source and destination are ready
|
||||
data_cmd_active <= avm_active_read;
|
||||
|
||||
-- Complete command (clear pending) when source and destination ready
|
||||
-- and not a multi-burst command
|
||||
cmd_pending <= not avm_active_read or var_multi_burst;
|
||||
|
||||
-- Flag when a LD_CMD_Q command popped from the queue and has started running (i.e. when cmd_pending cleared)
|
||||
if cmd_data(CMD_BITS) = CMD_LD_CMD_Q then
|
||||
-- It is an error to have insufficient space left when executing LD_CMD_Q, as
|
||||
-- it is a lock condition.
|
||||
if not dst_port_rdy then
|
||||
auto_load_err <= '1';
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- When a TLB load command, grab the parameters, and push to the queue
|
||||
when CMD_LD_ADDR_MAP =>
|
||||
if is_slim = '0' then
|
||||
if cmd_pending = '0' then
|
||||
cmd_pending <= '1';
|
||||
pop_parameter <= '1';
|
||||
paddr <= cmd_data(CMD_PARAM_0);
|
||||
else
|
||||
cmd_pending <= '0';
|
||||
tlb_cmd_active <= '1';
|
||||
tlb_write <= '1';
|
||||
tlb_wr_data <= paddr & cmd_data_q(31 downto 12);
|
||||
diag_2 <= cmd_data_q;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- A NOP command
|
||||
when CMD_NOP =>
|
||||
cmd_pending <= not cmd_pending;
|
||||
cmd_data <= cmd_data_q;
|
||||
handle <= cmd_data(CMD_PARAM0_HDL);
|
||||
null;
|
||||
|
||||
-- For unrecognised commands, consume the words in the queue and flag an error
|
||||
when others =>
|
||||
if cmd_pending = '0' then
|
||||
cmd_gobble <= '1';
|
||||
bad_cmd_err <= '1';
|
||||
end if;
|
||||
|
||||
end case;
|
||||
end if;
|
||||
|
||||
-- It is an error for the CPU to attempt to write to the command queue
|
||||
-- if there are active/outstanding auto-load commands (LD_CMD_Q).
|
||||
if cmd_port_wr_int and auto_cmd_active then
|
||||
cpu_race_err <= '1';
|
||||
end if;
|
||||
|
||||
-- If the queue is full (wired to to bit of usedw) and a new command
|
||||
-- arrives, then this is an error.
|
||||
if cmd_full = '1' and cmd_q_write_int = '1' then
|
||||
overrun_err <= '1';
|
||||
end if;
|
||||
|
||||
-- Clear the error state when commanded from the CPU
|
||||
if control_clear_errors = '1' then
|
||||
tlb_mismatch_err <= '0';
|
||||
tlb_empty_err <= '0';
|
||||
auto_load_err <= '0';
|
||||
bad_cmd_err <= '0';
|
||||
cpu_race_err <= '0';
|
||||
overrun_err <= '0';
|
||||
end if;
|
||||
|
||||
-- When a data command is active and receiving a word from memory...
|
||||
if data_cmd_active = '1' and avm_rx_readdatavalid = '1' then
|
||||
|
||||
-- Last transfer of burst
|
||||
if avm_rx_burstcount = 12x"1" then
|
||||
|
||||
-- Flag the last word of this block if block flagged as the last and also the last transfer of a looped command
|
||||
dest_port_last_word <= last_rd_block and loop_count_is_zero;
|
||||
|
||||
-- Clear the strip active flag
|
||||
data_cmd_active <= '0';
|
||||
|
||||
if is_slim = '0' then
|
||||
|
||||
-- Increment the latched virtual address's page number, and set the offset
|
||||
-- bits to zero, as next burst starts from thebegiinng of the next virtual
|
||||
-- page.
|
||||
curr_vaddr <= std_logic_vector(unsigned(curr_vaddr(31 downto 12)) + 1) & 12x"0";
|
||||
|
||||
|
||||
-- If more bursts to come, flag to use the latched virtual address, and clear
|
||||
-- set the fetch_vaddr flag to indicate re-checking of TLB mapping required
|
||||
if remaining_burst_is_zero = '0' then
|
||||
use_latched_addr <= '1';
|
||||
fetch_vaddr <= '1';
|
||||
-- If at the end of the last burst, clear the use_latched_addr and fetch_vaddr state
|
||||
else
|
||||
use_latched_addr <= '0';
|
||||
fetch_vaddr <= '0';
|
||||
end if;
|
||||
|
||||
checked_tlb <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- Decrement the burst count
|
||||
avm_rx_burstcount <= std_logic_vector(unsigned(avm_rx_burstcount) - 1);
|
||||
|
||||
end if;
|
||||
|
||||
-- Clear any auto_cmd_active only when there is no data transfer in place, and
|
||||
-- there are no commands to process. I.e. truely idle.
|
||||
if data_cmd_active = '0' and cmd_available = '0' and cmd_pending = '0' then
|
||||
auto_cmd_active <= '0';
|
||||
end if;
|
||||
|
||||
-- A TLB load command is cmpeted in the cycle after the TLB queue was written, to ensure
|
||||
-- that the new translatin is available for the next command.
|
||||
if is_slim = '0' and tlb_write_last = '1' then
|
||||
tlb_cmd_active <= '0';
|
||||
end if;
|
||||
|
||||
-- Pop the parameter when the read command is sent out, and there will be no more
|
||||
-- reads for this command (remaining count is 0).
|
||||
if avm_active_read = '1' and var_remaining_burst = 12x"0" then
|
||||
pop_parameter <= loop_is_first;
|
||||
end if;
|
||||
|
||||
-- Set the selected buffer's pixel write strobe when read data is available
|
||||
for i in 0 to dest_port_wr_int'length - 1 loop
|
||||
if to_integer(unsigned(dst_sel)) = i then
|
||||
dest_port_wr_int(i) <= avm_rx_readdatavalid and data_cmd_active;
|
||||
else
|
||||
dest_port_wr_int(i) <= '0';
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
-- Latch the read data for the pixel buffer when data arrives from memory
|
||||
if avm_rx_readdatavalid = '1' then
|
||||
if is_slim = '0' and control_msb = '1' then
|
||||
dest_port_wr_data_int <= avm_rx_readdata(7 downto 0) & avm_rx_readdata(15 downto 8) &
|
||||
avm_rx_readdata(23 downto 16) & avm_rx_readdata(31 downto 24);
|
||||
else
|
||||
dest_port_wr_data_int <= avm_rx_readdata;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
if is_slim = '0' then
|
||||
-- Assert IRQ if number of used command queue spaces falls below watermark
|
||||
if unsigned(usedw) < unsigned(control_watermark) and cmd_full = '0' then
|
||||
irq <= '1';
|
||||
else
|
||||
-- Assert the interrupt if there's an error
|
||||
irq <= cmd_error;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- reset control signals when commanded
|
||||
if control_clear_cmd = '1' then
|
||||
cmd_pending <= '0';
|
||||
cmd_available <= '0';
|
||||
cmd_available_step <= '0';
|
||||
data_cmd_active <= '0';
|
||||
remaining_burst <= (others => '0');
|
||||
dst_sel <= (others => '0');
|
||||
if is_slim = '0' then
|
||||
read_committed <= '0';
|
||||
fetch_vaddr <= '0';
|
||||
checked_tlb <= '0';
|
||||
use_latched_addr <= '0';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- This is a debug signal to expose the variable if needed
|
||||
multi_burst_last <= not is_slim and var_multi_burst;
|
||||
|
||||
if control_clr_dst0_count = '1' then
|
||||
diag_dst0_count <= (others => '0');
|
||||
else
|
||||
if dest_port_wr(0) = '1' then -- and dest_port_rdy(0) = '1' then
|
||||
diag_dst0_count <= std_logic_vector(unsigned(diag_dst0_count) + 1);
|
||||
end if;
|
||||
end if;
|
||||
|
||||
end if;
|
||||
end process;
|
||||
|
||||
end architecture;
|
||||
1
generic_ip/data_streamer/versions.txt
Normal file
1
generic_ip/data_streamer/versions.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
V8 - FPGA Vendor Independent. Uses Generic FIFOs from common/1
|
||||
Loading…
Add table
Add a link
Reference in a new issue