blob: 67b7e1c04b22aec79ed37487057bab5ab6feb242 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
library ieee;
use ieee.std_logic_1164.all;
use work.ppu_consts.all;
use work.ppu_pceg_consts.all;
entity ppu_pceg is port(
CLK : in std_logic; -- system clock
RESET : in std_logic; -- async reset
SPRITE_BG : out ppu_sprite_bg_pl_state := PL_BG_IDLE; -- sprite info fetch + sprite pixel fetch
SPRITE_FG : out ppu_sprite_fg_pl_state := PL_FG_IDLE; -- sprite pixel fetch
DONE : out std_logic; -- last pipeline stage done
READY : out std_logic); -- rgb buffer propagation ready
end ppu_pceg;
architecture Behavioral of ppu_pceg is
signal CLK_IDX_T : natural range 0 to PPU_PCEG_TOTAL_STAGES+1 := 0;
begin
process(CLK, RESET)
variable CLK_IDX : natural range 0 to PPU_PCEG_TOTAL_STAGES+1 := 0;
begin
if RESET = '1' then
CLK_IDX := 0;
SPRITE_BG <= PL_BG_IDLE;
SPRITE_FG <= PL_FG_IDLE;
DONE <= '0';
READY <= '0';
elsif falling_edge(CLK) then
case CLK_IDX is
when 0 =>
DONE <= '0';
READY <= '0';
SPRITE_BG <= PL_BG_IDLE;
SPRITE_FG <= PL_FG_IDLE;
when 1 =>
SPRITE_BG <= PL_BG_BAM_ADDR;
SPRITE_FG <= PL_FG_TMM_ADDR;
when 3 =>
SPRITE_BG <= PL_BG_IDLE;
SPRITE_FG <= PL_FG_IDLE;
when 4 =>
SPRITE_BG <= PL_BG_BAM_DATA;
SPRITE_FG <= PL_FG_TMM_DATA;
when 5 =>
SPRITE_BG <= PL_BG_TMM_ADDR;
SPRITE_FG <= PL_FG_IDLE;
when 6 => null;
when 7 =>
SPRITE_BG <= PL_BG_IDLE;
when 8 =>
DONE <= '1';
SPRITE_BG <= PL_BG_TMM_DATA;
when 9 =>
SPRITE_BG <= PL_BG_IDLE;
READY <= '1';
when others => null;
end case;
-- increment clock counter
CLK_IDX := CLK_IDX + 1;
if CLK_IDX = PPU_PCEG_TOTAL_STAGES then
CLK_IDX := 0;
end if;
CLK_IDX_T <= CLK_IDX;
end if;
end process;
end Behavioral;
|