Skip to content

Commit 7ef0ca3

Browse files
committed
fixed: pixel data now comes from outside block
1 parent 4fae21b commit 7ef0ca3

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

src/vga.vhd

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ entity vga is
1515
i_blue : in std_logic_vector(1 downto 0);
1616
i_green : in std_logic_vector(1 downto 0);
1717

18+
-- '1' if ready for pixel else '0'
19+
pxl_rdy : out std_logic;
20+
1821
-- Output colors
1922
-- 4 x 4 x 4 yields 64 different colors
2023
o_red : out std_logic_vector(1 downto 0);
@@ -40,13 +43,6 @@ architecture RTL of vga is
4043
constant V_BACK_PORCH : natural := V_SYNC_PULSE + 6;
4144
constant V_WHOLE_LINE : natural := V_BACK_PORCH + 29;
4245

43-
-- Data for test
44-
constant WHITE_PIXEL : std_logic_vector(5 downto 0) := (others => '1');
45-
46-
alias R : std_logic_vector(1 downto 0) is WHITE_PIXEL(5 downto 4);
47-
alias G : std_logic_vector(1 downto 0) is WHITE_PIXEL(3 downto 2);
48-
alias B : std_logic_vector(1 downto 0) is WHITE_PIXEL(1 downto 0);
49-
5046
procedure SyncCount(signal count : inout natural;
5147
constant wrap : in natural;
5248
constant enable : in boolean;
@@ -104,12 +100,16 @@ begin
104100
-- To display or not to display
105101
if h_count < H_VISIBLE_AREA and v_count < V_VISIBLE_AREA then
106102

107-
o_red <= R;
108-
o_green <= G;
109-
o_blue <= B;
103+
pxl_rdy <= '1';
104+
105+
o_red <= i_red;
106+
o_green <= i_green;
107+
o_blue <= i_blue;
110108

111109
else
112110

111+
pxl_rdy <= '0';
112+
113113
o_red <= (others => '0');
114114
o_green <= (others => '0');
115115
o_blue <= (others =>'0');

test/vga_tb.vhd

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ architecture rtl of vga_tb is
1515

1616
constant RESET_PERIOD : time := 10 us;
1717

18+
constant WHITE_PIXEL : std_logic_vector(5 downto 0) := (others => '1');
19+
alias R : std_logic_vector(1 downto 0) is WHITE_PIXEL(5 downto 4);
20+
alias G : std_logic_vector(1 downto 0) is WHITE_PIXEL(3 downto 2);
21+
alias B : std_logic_vector(1 downto 0) is WHITE_PIXEL(1 downto 0);
22+
1823
signal clk : std_logic := '0';
1924
signal rst : std_logic := '0';
2025

2126
signal hsync, vsync : std_logic;
27+
signal pxl_rdy : std_logic;
2228

29+
signal i_red, i_blue, i_green : std_logic_vector(1 downto 0);
2330
signal o_red, o_blue, o_green : std_logic_vector(1 downto 0);
2431

2532
begin
@@ -33,9 +40,11 @@ begin
3340
vsync => vsync,
3441

3542
-- Input colors
36-
i_red => (others => '0'),
37-
i_blue => (others => '0'),
38-
i_green => (others => '0'),
43+
i_red => i_red,
44+
i_blue => i_blue,
45+
i_green => i_green,
46+
47+
pxl_rdy => pxl_rdy,
3948

4049
-- Output colors
4150
-- 8 x 8 x 8 yields 512 different colors
@@ -57,5 +66,25 @@ begin
5766
wait;
5867
end process;
5968

60-
end architecture rtl;
69+
stim : process
70+
begin
71+
72+
wait until falling_edge(clk);
73+
if pxl_rdy='1' then
74+
i_red <= R;
75+
i_green <= G;
76+
i_blue <= B;
77+
else
78+
i_red <= (others => '0');
79+
i_green <= (others => '0');
80+
i_blue <= (others => '0');
81+
end if;
82+
end process;
83+
84+
kill_sim : process
85+
begin
86+
wait for 100 ms;
87+
assert (false) report "-- SIMULATION COMPLETE --" severity failure;
88+
end process;
6189

90+
end architecture rtl;

0 commit comments

Comments
 (0)