Skip to content

Instantly share code, notes, and snippets.

@smirnovich
Created March 14, 2023 07:24
Show Gist options
  • Save smirnovich/89334ea65f0a68b0b3866abc05245a7f to your computer and use it in GitHub Desktop.
Save smirnovich/89334ea65f0a68b0b3866abc05245a7f to your computer and use it in GitHub Desktop.
VHDL simple arithmetic with sequential logic example
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity flag_example is
port(
data : in std_logic_vector(3 downto 0);
flag : in std_logic;
o2 : out std_logic_vector(3 downto 0)
);
end entity;
architecture rtl of flag_example is
signal my_sig : std_logic_vector(3 downto 0);
begin
process(clk)
begin
if ( rising_edge(clk)) then
o2 <= my_sig;
if (flag = '1') then
my_sig <= std_logic_vector(unsigned(data) + unsigned(my_sig));
end if;
end if;
end process;
end rtl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment