Skip to content

Commit 5d6c5cb

Browse files
committed
updated tests and formatting
1 parent d6e9ea0 commit 5d6c5cb

File tree

4 files changed

+40
-80
lines changed

4 files changed

+40
-80
lines changed

.library_mapping.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.project

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/vga.vhd

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ use ieee.std_logic_1164.all;
33
use ieee.numeric_std.all;
44

55
entity vga is
6-
port(
7-
clk : in std_logic; -- Pixel clock
8-
rst : in std_logic;
9-
10-
hsync : out std_logic;
11-
vsync : out std_logic;
12-
13-
-- Input colors
14-
i_red : in std_logic_vector(1 downto 0);
15-
i_blue : in std_logic_vector(1 downto 0);
16-
i_green : in std_logic_vector(1 downto 0);
17-
18-
-- Output colors
19-
-- 4 x 4 x 4 yields 64 different colors
20-
o_red : out std_logic_vector(1 downto 0);
21-
o_blue : out std_logic_vector(1 downto 0);
22-
o_green : out std_logic_vector(1 downto 0)
6+
port(
7+
clk : in std_logic;
8+
rst : in std_logic;
9+
10+
hsync : out std_logic;
11+
vsync : out std_logic;
12+
13+
-- Input colors
14+
i_red : in std_logic_vector(1 downto 0);
15+
i_blue : in std_logic_vector(1 downto 0);
16+
i_green : in std_logic_vector(1 downto 0);
17+
18+
-- Output colors
19+
-- 4 x 4 x 4 yields 64 different colors
20+
o_red : out std_logic_vector(1 downto 0);
21+
o_blue : out std_logic_vector(1 downto 0);
22+
o_green : out std_logic_vector(1 downto 0)
2323
);
2424
end entity vga;
2525

@@ -69,13 +69,13 @@ architecture RTL of vga is
6969

7070
begin
7171

72-
process(clk)
72+
process(clk)
7373

7474
variable wrapped : boolean;
7575

7676
begin
7777

78-
if rising_edge(clk) then
78+
if rising_edge(clk) then
7979

8080
if rst='1' then
8181

@@ -118,7 +118,7 @@ begin
118118

119119
end if;
120120

121-
end if;
121+
end if;
122122

123-
end process;
123+
end process;
124124
end architecture RTL;

test/vga_tb.vhd

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ architecture rtl of vga_tb is
1010
-- Clock
1111
constant CLOCK_SPEED : natural := 65e6;
1212
constant CLOCK_PERIOD : time := 1.0 sec / CLOCK_SPEED;
13-
constant DUTY_CYCLE : real := 0.5;
13+
constant CLOCK_DUTY : real := 0.5;
14+
constant CLOCK_PHASE : real := 0.0 / 360.0;
15+
16+
constant RESET_PERIOD : time := 10 us;
1417

1518
signal clk : std_logic := '0';
1619
signal rst : std_logic := '0';
1720

1821
signal hsync, vsync : std_logic;
1922

20-
signal o_red, o_blue, o_green : std_logic_vector(2 downto 0);
23+
signal o_red, o_blue, o_green : std_logic_vector(1 downto 0);
2124

2225
begin
2326

2427
vga1 : entity work.vga
2528
port map(
26-
clk => clk, -- Pixel clock
27-
rst => rst,
29+
clk => clk,
30+
rst => rst,
2831

2932
hsync => hsync,
3033
vsync => vsync,
@@ -41,8 +44,18 @@ begin
4144
o_green => o_green
4245
);
4346

44-
45-
clk <= not clk after CLOCK_PERIOD / 2;
47+
clk_gen : process
48+
begin
49+
clk <= transport '1' after (CLOCK_PERIOD * CLOCK_PHASE);
50+
clk <= transport '0' after (CLOCK_PERIOD * (CLOCK_DUTY + CLOCK_PHASE));
51+
wait for CLOCK_PERIOD;
52+
end process;
53+
54+
reset : process
55+
begin
56+
rst <= '1', '0' after RESET_PERIOD;
57+
wait;
58+
end process;
4659

4760
end architecture rtl;
4861

0 commit comments

Comments
 (0)