Created
March 14, 2023 07:24
-
-
Save smirnovich/89334ea65f0a68b0b3866abc05245a7f to your computer and use it in GitHub Desktop.
VHDL simple arithmetic with sequential logic example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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