1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

Merge remote-tracking branch 'upstream/master' into lean

This commit is contained in:
Y.D.X.
2025-07-11 13:03:06 +08:00
14 changed files with 287 additions and 79 deletions

View File

@@ -0,0 +1,74 @@
-- This is a single-line comment
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity SyntaxTest is
 generic (
 DATA_WIDTH : integer := 8
 );
 port (
 clk : in std_logic;
 rst : in std_logic;
 a, b : in std_logic_vector(DATA_WIDTH - 1 downto 0);
 sel : in std_logic;
 result : out std_logic_vector(DATA_WIDTH - 1 downto 0);
 flag : out std_logic
 );
end SyntaxTest;
architecture Behavioral of SyntaxTest is
 signal tmp : std_logic_vector(DATA_WIDTH - 1 downto 0);
 signal done : std_logic := '0';
 type state_type is (IDLE, LOAD, EXECUTE, DONE);
 signal state : state_type := IDLE;
begin
 process(clk, rst)
 variable i : integer := 0;
 begin
 if rst = '1' then
 tmp <= (others => '0');
 flag <= '0';
 state <= IDLE;
 elsif rising_edge(clk) then
 case state is
 when IDLE =>
 if sel = '1' then
 tmp <= a and b;
 state <= EXECUTE;
 else
 tmp <= a or b;
 state <= LOAD;
 end if;
 when LOAD =>
 tmp <= a xor b;
 state <= EXECUTE;
 when EXECUTE =>
 if i < DATA_WIDTH then
 tmp(i) <= not tmp(i);
 i := i + 1;
 else
 state <= DONE;
 end if;
 when DONE =>
 flag <= '1';
 state <= IDLE;
 when others =>
 state <= IDLE;
 end case;
 end if;
 end process;
 result <= tmp;
end Behavioral;