aboutsummaryrefslogtreecommitdiff
path: root/basys3/basys3.srcs/ppu_comp.vhd
diff options
context:
space:
mode:
Diffstat (limited to 'basys3/basys3.srcs/ppu_comp.vhd')
-rw-r--r--basys3/basys3.srcs/ppu_comp.vhd24
1 files changed, 15 insertions, 9 deletions
diff --git a/basys3/basys3.srcs/ppu_comp.vhd b/basys3/basys3.srcs/ppu_comp.vhd
index e79738f..30b161c 100644
--- a/basys3/basys3.srcs/ppu_comp.vhd
+++ b/basys3/basys3.srcs/ppu_comp.vhd
@@ -2,35 +2,41 @@ 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));
+entity ppu_comp is port (
+ OE : in std_logic; -- global output enable (screen active)
+ FG_HIT : in std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0); -- foreground hit array
+ BG_EN : out std_logic; -- background enable output
+ FG_EN : out std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0)); -- foreground enable output
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');
+ signal TMP_BG_EN : std_logic; -- background enable output
+ signal TMP_FG_EN : std_logic_vector(PPU_FG_SPRITE_COUNT-1 downto 0); -- foreground enable output
begin
+ BG_EN <= TMP_BG_EN and OE;
+ FG_EN <= TMP_FG_EN and OE;
+
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';
+ TMP_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';
+ TMP_FG_EN(i) <= '1';
HIT := true;
else
-- make rest low
- FG_EN(i) <= '0';
+ TMP_FG_EN(i) <= '0';
end if;
end loop;
HIT := false;
else
- BG_EN <= '1';
- FG_EN <= (others => '0');
+ TMP_BG_EN <= '1';
+ TMP_FG_EN <= (others => '0');
end if;
end process;
end Behavioral;