aboutsummaryrefslogtreecommitdiff
path: root/basys3/basys3.srcs/ppu_pceg.vhd
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-02-24 13:20:02 +0100
committerlonkaars <loek@pipeframe.xyz>2023-02-24 13:20:02 +0100
commitf3a47bde9bfaaa716de835c0c1499a685b4ac4f7 (patch)
tree90abe28726ea7484184179129256022472eb2e24 /basys3/basys3.srcs/ppu_pceg.vhd
parent7da7908989686daa2ac9fd2f3f79cad2f03c0828 (diff)
parent14a1c464c27206bff847fd46d3d5594b30f53af9 (diff)
Merge branch 'dev' into ppu-interface
Diffstat (limited to 'basys3/basys3.srcs/ppu_pceg.vhd')
-rw-r--r--basys3/basys3.srcs/ppu_pceg.vhd46
1 files changed, 46 insertions, 0 deletions
diff --git a/basys3/basys3.srcs/ppu_pceg.vhd b/basys3/basys3.srcs/ppu_pceg.vhd
new file mode 100644
index 0000000..1aaeee4
--- /dev/null
+++ b/basys3/basys3.srcs/ppu_pceg.vhd
@@ -0,0 +1,46 @@
+library ieee;
+use ieee.std_logic_1164.all;
+--use ieee.numeric_std.all;
+
+entity ppu_pceg is port(
+ CLK : in std_logic; -- system clock
+ RESET : in std_logic; -- async reset
+ SPRITE : out std_logic; -- sprite info fetch + sprite pixel fetch
+ COMP_PAL : out std_logic; -- compositor + palette lookup
+ DONE : out std_logic); -- last pipeline stage done
+end ppu_pceg;
+
+architecture Behavioral of ppu_pceg is
+ constant PPU_PL_TOTAL_STAGES : natural := 14;
+
+ type states is (PL_SPRITE, PL_COMP_PAL, PL_DONE);
+ signal state : states := PL_SPRITE;
+begin
+ -- output drivers
+ SPRITE <= CLK when RESET = '0' and state = PL_SPRITE else '0';
+ COMP_PAL <= CLK when RESET = '0' and state = PL_COMP_PAL else '0';
+ DONE <= '1' when RESET = '0' and state = PL_DONE else '0';
+
+ process(CLK, RESET)
+ variable CLK_IDX : natural range 0 to PPU_PL_TOTAL_STAGES+1 := 0;
+ begin
+ if RESET = '1' then
+ state <= PL_SPRITE;
+ elsif rising_edge(CLK) then
+ -- clock counter ranges
+ if CLK_IDX < 4 then
+ state <= PL_SPRITE;
+ elsif CLK_IDX < 5 then
+ state <= PL_COMP_PAL;
+ else
+ state <= PL_DONE;
+ end if;
+
+ -- increment clock counter
+ CLK_IDX := CLK_IDX + 1;
+ if CLK_IDX = PPU_PL_TOTAL_STAGES then
+ CLK_IDX := 0;
+ end if;
+ end if;
+ end process;
+end Behavioral;