diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-02-24 13:20:02 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-02-24 13:20:02 +0100 |
commit | f3a47bde9bfaaa716de835c0c1499a685b4ac4f7 (patch) | |
tree | 90abe28726ea7484184179129256022472eb2e24 /basys3/basys3.srcs/ppu_comp.vhd | |
parent | 7da7908989686daa2ac9fd2f3f79cad2f03c0828 (diff) | |
parent | 14a1c464c27206bff847fd46d3d5594b30f53af9 (diff) |
Merge branch 'dev' into ppu-interface
Diffstat (limited to 'basys3/basys3.srcs/ppu_comp.vhd')
-rw-r--r-- | basys3/basys3.srcs/ppu_comp.vhd | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/basys3/basys3.srcs/ppu_comp.vhd b/basys3/basys3.srcs/ppu_comp.vhd new file mode 100644 index 0000000..e79738f --- /dev/null +++ b/basys3/basys3.srcs/ppu_comp.vhd @@ -0,0 +1,36 @@ +library ieee; +use ieee.std_logic_1164.all; +use work.ppu_consts.all; + +entity ppu_comp is port ( + FG_HIT : in std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0); + BG_EN : out std_logic; + FG_EN : out std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0)); +end ppu_comp; + +architecture Behavioral of ppu_comp is + signal FG_HIT_EMPTY : std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0) := (others => '0'); +begin + process (FG_HIT) + variable HIT : boolean := false; + begin + -- check if FG_HIT is not empty + if FG_HIT /= FG_HIT_EMPTY then + BG_EN <= '0'; + for i in 0 to PPU_FG_SPRITE_COUNT-1 loop + -- if FG_HIT is the first one then enable it + if(FG_HIT(i) = '1' and HIT = false) then + FG_EN(i) <= '1'; + HIT := true; + else + -- make rest low + FG_EN(i) <= '0'; + end if; + end loop; + HIT := false; + else + BG_EN <= '1'; + FG_EN <= (others => '0'); + end if; + end process; +end Behavioral; |