Sure! Below is a VHDL model of an 8-bit adder with AXI-Stream (AXIS) handshake signals. The AXI-Stream interface uses the following signals:
- TDATA: Data signal (8 bits in this case)
- TVALID: Indicates that the data is valid
- TREADY: Indicates that the receiver is ready to accept data
This example assumes two input AXI-Stream interfaces (S_AXIS_A and S_AXIS_B) and one output AXI-Stream interface (M_AXIS). The adder waits for both inputs to be valid and ready before performing the addition and sending the result.
📘 VHDL Code: 8-bit AXI-Stream Adder
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity axi_stream_adder is
Port (
-- Global signals
ACLK : in std_logic;
ARESETN : in std_logic;
-- AXI-Stream input A
S_AXIS_A_TVALID : in std_logic;
S_AXIS_A_TREADY : out std_logic;
S_AXIS_A_TDATA : in std_logic_vector(7 downto 0);
-- AXI-Stream input B
S_AXIS_B_TVALID : in std_logic;
S_AXIS_B_TREADY : out std_logic;
S_AXIS_B_TDATA : in std_logic_vector(7 downto 0);
-- AXI-Stream output
M_AXIS_TVALID : out std_logic;
M_AXIS_TREADY : in std_logic;
M_AXIS_TDATA : out std_logic_vector(7 downto 0)
);
end axi_stream_adder;
architecture Behavioral of axi_stream_adder is
signal a_data_reg : std_logic_vector(7 downto 0);
signal b_data_reg : std_logic_vector(7 downto 0);
signal result_reg : std_logic_vector(7 downto 0);
signal valid_reg : std_logic := '0';
signal a_ready : std_logic := '0';
signal b_ready : std_logic := '0';
begin
-- Assign ready signals
S_AXIS_A_TREADY <= a_ready;
S_AXIS_B_TREADY <= b_ready;
-- Output assignments
M_AXIS_TDATA <= result_reg;
M_AXIS_TVALID <= valid_reg;
process(ACLK)
begin
if rising_edge(ACLK) then
if ARESETN = '0' then
a_ready <= '1';
b_ready <= '1';
valid_reg <= '0';
result_reg <= (others => '0');
else
-- Wait for both inputs to be valid and ready
if (S_AXIS_A_TVALID = '1' and a_ready = '1') and
(S_AXIS_B_TVALID = '1' and b_ready = '1') then
-- Latch input data
a_data_reg <= S_AXIS_A_TDATA;
b_data_reg <= S_AXIS_B_TDATA;
-- Perform addition
result_reg <= std_logic_vector(
unsigned(S_AXIS_A_TDATA) + unsigned(S_AXIS_B_TDATA)
);
-- Set output valid
valid_reg <= '1';
-- Deassert ready to inputs until output is accepted
a_ready <= '0';
b_ready <= '0';
elsif (valid_reg = '1' and M_AXIS_TREADY = '1') then
-- Output accepted, ready for next input
valid_reg <= '0';
a_ready <= '1';
b_ready <= '1';
end if;
end if;
end if;
end process;
end Behavioral;
📝 Notes:
- The adder waits for both input streams to be valid and ready before performing the addition.
- The result is sent out when the output interface is ready (M_AXIS_TREADY = '1').
- The design uses a simple handshake mechanism and does not include TKEEP, TLAST, or TUSER signals. You can extend the interface if needed.
Let me know if you need a testbench or a version with more features!