Refines VHDL formatting and counter logic

Aligns signal and port declarations for improved readability.
Adjusts horizontal and vertical counter bit-width calculations for accuracy.
Splits conditional statements across multiple lines for better clarity.

No functional changes introduced.
This commit is contained in:
2025-04-16 17:29:41 +00:00
parent cd6524c62e
commit ff7782fd91
2 changed files with 26 additions and 40 deletions

View File

@@ -22,58 +22,58 @@ entity VGATimingGenerator is
--@ Horizontal Front Porch --@ Horizontal Front Porch
G_HFront : integer := 16; G_HFront : integer := 16;
--@ Horizontal Sync Pulse --@ Horizontal Sync Pulse
G_HSync : integer := 96; G_HSync : integer := 96;
--@ Horizontal Back Porch --@ Horizontal Back Porch
G_HBack : integer := 48; G_HBack : integer := 48;
--@ Horizontal Total resolution --@ Horizontal Total resolution
G_HTotal : integer := 800; G_HTotal : integer := 800;
--@ Vertical Front Porch --@ Vertical Front Porch
G_VFront : integer := 10; G_VFront : integer := 10;
--@ Vertical Sync Pulse --@ Vertical Sync Pulse
G_VSync : integer := 2; G_VSync : integer := 2;
--@ Vertical Back Porch --@ Vertical Back Porch
G_VBack : integer := 33; G_VBack : integer := 33;
--@ Vertical Total resolution --@ Vertical Total resolution
G_VTotal : integer := 525 G_VTotal : integer := 525
); );
port ( port (
--@ Clock signal; **Rising edge** triggered --@ Clock signal; **Rising edge** triggered
I_CLK : in std_logic; I_CLK : in std_logic;
--@ Clock Enable signal --@ Clock Enable signal
I_CE : in std_logic; I_CE : in std_logic;
--@ Synchronous reset signal --@ Synchronous reset signal
I_RST : in std_logic; I_RST : in std_logic;
--@ Ready signal (AXI like) to indicate that the pixel data is ready to be displayed --@ Ready signal (AXI like) to indicate that the pixel data is ready to be displayed
O_PixelReady : out std_logic; O_PixelReady : out std_logic;
--@ @virtualbus VGA-Timing-Signals @dir out VGA timing signals --@ @virtualbus VGA-Timing-Signals @dir out VGA timing signals
--@ Horizontal Sync signal; **Active low** --@ Horizontal Sync signal; **Active low**
O_HSync : out std_logic; O_HSync : out std_logic;
--@ Vertical Sync signal; **Active low** --@ Vertical Sync signal; **Active low**
O_VSync : out std_logic O_VSync : out std_logic
--@ @end --@ @end
); );
end entity VGATimingGenerator; end entity VGATimingGenerator;
architecture RTL of VGATimingGenerator is architecture RTL of VGATimingGenerator is
--@ Horizontal Counter; max value = G_HTotal --@ Horizontal Counter; max value = G_HTotal
signal R_HorizontalCounter : unsigned(integer(ceil(log2(real(G_HTotal)))) downto 0) := (others => '0'); signal R_HorizontalCounter : unsigned(integer(ceil(log2(real(G_HTotal)))) - 1 downto 0) := (others => '0');
--@ Vertical Counter; max value = G_VTotal --@ Vertical Counter; max value = G_VTotal
signal R_VerticalCounter : unsigned(integer(ceil(log2(real(G_VTotal)))) downto 0) := (others => '0'); signal R_VerticalCounter : unsigned(integer(ceil(log2(real(G_VTotal)))) - 1 downto 0) := (others => '0');
--@ Counter Enable signal for Vertical Counter --@ Counter Enable signal for Vertical Counter
signal C_VerticalCE : std_logic := '0'; signal C_VerticalCE : std_logic := '0';
--@ Flag to indicate if the horizontal counter is in the visible area --@ Flag to indicate if the horizontal counter is in the visible area
signal C_HorizontalVisible : std_logic := '0'; signal C_HorizontalVisible : std_logic := '0';
--@ Flag to indicate if the vertical counter is in the visible area --@ Flag to indicate if the vertical counter is in the visible area
signal C_VerticalVisible : std_logic := '0'; signal C_VerticalVisible : std_logic := '0';
--@ Horizontal Sync signal shift register --@ Horizontal Sync signal shift register
signal R_HSync : std_logic_vector(1 downto 0) := (others => '0'); signal R_HSync : std_logic_vector(1 downto 0) := (others => '0');
--@ Vertical Sync signal register --@ Vertical Sync signal register
signal R_VSync : std_logic := '1'; signal R_VSync : std_logic := '1';
--@ Pixel Ready signal --@ Pixel Ready signal
signal C_PixelReady : std_logic := '0'; signal C_PixelReady : std_logic := '0';
begin begin
--@ Horizontal Pixel Counter. --@ Horizontal Pixel Counter.
--@ Overflows at G_HTotal. --@ Overflows at G_HTotal.
@@ -112,7 +112,8 @@ begin
--@ Flag generator for horizontal visible area. --@ Flag generator for horizontal visible area.
P_HorizontalVisible : process (R_HorizontalCounter) P_HorizontalVisible : process (R_HorizontalCounter)
begin begin
if R_HorizontalCounter >= G_HSync + G_HBack and R_HorizontalCounter <= G_HTotal - G_HFront - 1 then if R_HorizontalCounter >= G_HSync + G_HBack and
R_HorizontalCounter <= G_HTotal - G_HFront - 1 then
C_HorizontalVisible <= '1'; C_HorizontalVisible <= '1';
else else
C_HorizontalVisible <= '0'; C_HorizontalVisible <= '0';
@@ -166,7 +167,8 @@ begin
--@ Flag generator for vertical visible area. --@ Flag generator for vertical visible area.
P_VerticalVisible : process (R_VerticalCounter) P_VerticalVisible : process (R_VerticalCounter)
begin begin
if R_VerticalCounter >= G_VSync + G_VBack and R_VerticalCounter <= G_VTotal - G_VFront - 1 then if R_VerticalCounter >= G_VSync + G_VBack and
R_VerticalCounter <= G_VTotal - G_VFront - 1 then
C_VerticalVisible <= '1'; C_VerticalVisible <= '1';
else else
C_VerticalVisible <= '0'; C_VerticalVisible <= '0';
@@ -189,15 +191,15 @@ begin
begin begin
if rising_edge(I_CLK) then if rising_edge(I_CLK) then
if I_RST = '1' then if I_RST = '1' then
O_HSync <= '1'; O_HSync <= '1';
O_VSync <= '1'; O_VSync <= '1';
O_PixelReady <= '0'; O_PixelReady <= '0';
elsif I_CE = '1' then elsif I_CE = '1' then
O_HSync <= R_HSync(0); O_HSync <= R_HSync(0);
O_VSync <= R_VSync; O_VSync <= R_VSync;
O_PixelReady <= C_PixelReady; O_PixelReady <= C_PixelReady;
end if; end if;
end if; end if;
end process; end process;
end architecture RTL; end architecture RTL;

View File

@@ -1,16 +0,0 @@
[libraries]
defaultlib.files = [
'tests/*.vhd',
'src/*.vhd',
'src/*/*.vhd',
]
# Libraries can be marked as third-party to disable some analysis warnings, such as unused declarations
UNISIM.files = [
'/opt/Xilinx/14.7/ISE_DS/ISE/vhdl/src/unisims/unisim_VCOMP.vhd',
]
UNISIM.is_third_party = true
[lint]
unused = 'error' # Upgrade the 'unused' diagnostic to the 'error' severity
unnecessary_work_library = false # Disable linting for the 'library work;' statement