aboutsummaryrefslogtreecommitdiff
path: root/basys3/basys3.srcs/ppu_consts.vhd
diff options
context:
space:
mode:
Diffstat (limited to 'basys3/basys3.srcs/ppu_consts.vhd')
-rw-r--r--basys3/basys3.srcs/ppu_consts.vhd29
1 files changed, 27 insertions, 2 deletions
diff --git a/basys3/basys3.srcs/ppu_consts.vhd b/basys3/basys3.srcs/ppu_consts.vhd
index 75b6168..4784950 100644
--- a/basys3/basys3.srcs/ppu_consts.vhd
+++ b/basys3/basys3.srcs/ppu_consts.vhd
@@ -10,6 +10,7 @@ package ppu_consts is
constant PPU_RAM_BUS_DATA_WIDTH : natural := 16; -- RAM bus data width
constant PPU_FG_SPRITE_COUNT : natural := 128; -- foreground sprites
constant PPU_COLOR_OUTPUT_DEPTH : natural := 4; -- VGA output channel depth
+ constant PPU_RGB_COLOR_OUTPUT_DEPTH : natural := 3 * PPU_COLOR_OUTPUT_DEPTH;
constant PPU_PALETTE_COLOR_WIDTH : natural := 3; -- palette index width (within sprite)
constant PPU_PALETTE_INDEX_WIDTH : natural := 3; -- palette index width (palette table)
constant PPU_PALETTE_CIDX_WIDTH : natural := (PPU_PALETTE_COLOR_WIDTH + PPU_PALETTE_INDEX_WIDTH); -- global palette index width
@@ -30,8 +31,11 @@ package ppu_consts is
constant PPU_SPRITE_PIDX_WIDTH : natural := 8; -- bits needed to identify horizontal and vertical pixel within sprite
constant PPU_SPRITE_POS_H_WIDTH: natural := 4; -- bits needed to identify horizontal pixel within sprite
constant PPU_SPRITE_POS_V_WIDTH: natural := 4; -- bits needed to identify vertical pixel within sprite
- constant PPU_SCREEN_WIDTH : natural := 320; -- absolute screen width (pixels)
- constant PPU_SCREEN_HEIGHT : natural := 240; -- absolute screen height (pixels)
+ constant PPU_SCREEN_WIDTH : natural := 320; -- absolute screen width (tiny pixels)
+ constant PPU_SCREEN_HEIGHT : natural := 240; -- absolute screen height (tiny pixels)
+ constant PPU_NATIVE_SCREEN_WIDTH : natural := 2 * PPU_SCREEN_WIDTH; -- screen width (native pixels)
+ constant PPU_NATIVE_SCREEN_HEIGHT : natural := 2 * PPU_SCREEN_HEIGHT; -- screen height (native pixels)
+ constant PPU_DISPCTL_SLBUF_ADDR_WIDTH : natural := ceil_log2(2 * PPU_SCREEN_WIDTH);
constant PPU_BG_CANVAS_TILES_H : natural := 40; -- tiles (horizontally) on background canvas
constant PPU_BG_CANVAS_TILES_V : natural := 30; -- tiles (vertically) on background canvas
constant PPU_BG_CANVAS_TILE_H_WIDTH : natural := 6; -- bits needed to describe horizontal bg tile index (grid coordinates)
@@ -44,6 +48,27 @@ package ppu_consts is
constant PPU_TMM_CACHE_FETCH_C_COUNT : natural := PPU_SPRITE_WORD_COUNT + 1;
constant PPU_TMM_CACHE_FETCH_A_COUNT : natural := PPU_TMM_CACHE_FETCH_C_COUNT * PPU_FG_SPRITE_COUNT; -- amount of clocks to fetch new TMM cache
constant PPU_TMM_CACHE_FETCH_A_WIDTH : natural := ceil_log2(PPU_TMM_CACHE_FETCH_A_COUNT);
+ constant PPU_ACCURATE_FG_SPRITE_COUNT : natural := 16;
+ constant PPU_PL_TOTAL_STAGES : natural := 14;
+ -- VGA signal timings (https://tomverbeure.github.io/video_timings_calculator)
+ constant PPU_VGA_H_ACTIVE : natural := PPU_NATIVE_SCREEN_WIDTH;
+ constant PPU_VGA_H_PORCH_FRONT : natural := 96;
+ constant PPU_VGA_H_SYNC : natural := 16;
+ constant PPU_VGA_H_PORCH_BACK : natural := 48;
+ constant PPU_VGA_H_BLANK : natural := PPU_VGA_H_PORCH_FRONT + PPU_VGA_H_SYNC + PPU_VGA_H_PORCH_BACK;
+ constant PPU_VGA_H_TOTAL : natural := PPU_VGA_H_BLANK + PPU_VGA_H_ACTIVE;
+ constant PPU_VGA_V_ACTIVE : natural := PPU_NATIVE_SCREEN_HEIGHT;
+ constant PPU_VGA_V_PORCH_FRONT : natural := 10;
+ constant PPU_VGA_V_SYNC : natural := 2;
+ constant PPU_VGA_V_PORCH_BACK : natural := 29;
+ constant PPU_VGA_V_BLANK : natural := PPU_VGA_V_PORCH_FRONT + PPU_VGA_V_SYNC + PPU_VGA_V_PORCH_BACK;
+ constant PPU_VGA_V_TOTAL : natural := PPU_VGA_V_BLANK + PPU_VGA_V_ACTIVE;
+ constant PPU_VGA_SIGNAL_PIXEL_IDX_MAX : natural := PPU_VGA_V_TOTAL * PPU_VGA_H_TOTAL; -- horizontal and vertical pixel clock index
+ constant PPU_VGA_SIGNAL_PIXEL_WIDTH : natural := ceil_log2(PPU_VGA_SIGNAL_PIXEL_IDX_MAX); -- bit width to count total horizontal and vertical pixel clock index
+ constant PPU_SCREEN_T_POS_X_WIDTH : natural := ceil_log2(PPU_SCREEN_WIDTH);
+ constant PPU_SCREEN_T_POS_Y_WIDTH : natural := ceil_log2(PPU_SCREEN_HEIGHT);
+ constant PPU_SCREEN_N_POS_X_WIDTH : natural := ceil_log2(PPU_NATIVE_SCREEN_WIDTH);
+ constant PPU_SCREEN_N_POS_Y_WIDTH : natural := ceil_log2(PPU_NATIVE_SCREEN_HEIGHT);
end package ppu_consts;
package body ppu_consts is
-- https://stackoverflow.com/questions/21783280/number-of-bits-to-represent-an-integer-in-vhdl