------------------------------------------------------------------------------- -- Title : vga_control architecture -- Project : LU Digital Design ------------------------------------------------------------------------------- -- File : vga_control.vhd -- Author : Thomas Handl -- Company : TU Wien -- Created : 2004-12-15 -- Last update: 2006-02-24 ------------------------------------------------------------------------------- -- Description: generation of colors (RGB) ------------------------------------------------------------------------------- -- Copyright (c) 2004 TU Wien ------------------------------------------------------------------------------- -- Revisions : -- Date Version Author Description -- 2004-12-15 1.0 handl Created -- 2006-02-24 2.0 ST revised ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- LIBRARIES ------------------------------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all; use work.vga_pak.all; ------------------------------------------------------------------------------- -- ARCHITECTURE ------------------------------------------------------------------------------- architecture behav of vga_control is attribute syn_preserve : boolean; attribute syn_preserve of behav : architecture is true; -- signal and constant declarations signal r_next, g_next, b_next : std_logic; -- auxiliary signals for next state logic signal toggle_sig : std_logic; -- auxiliary signal to allow read back of toggle signal toggle_counter_sig : std_logic_vector(TOG_CNT_WIDTH-1 downto 0); -- auxiliary signal to allow read back of blinker signal toggle_next : std_logic; -- auxiliary signal for next state logic signal toggle_counter_next : std_logic_vector(TOG_CNT_WIDTH-1 downto 0); -- auxiliary signal for next state logic constant HALFPERIOD : std_logic_vector(TOG_CNT_WIDTH-1 downto 0) := "1100000000010001111011000"; -- define half period of toggle frequency in clock ticks begin ----------------------------------------------------------------------------- -- draw rectangle on screen ----------------------------------------------------------------------------- DRAW_SQUARE_syn: process(clk, reset) begin if (reset = RES_ACT) then -- draw black screen upon reset r <= COLR_OFF; g <= COLR_OFF; b <= COLR_OFF; elsif (clk'event and clk = '1') then -- synchronous capture r <= r_next; g <= g_next; b <= b_next; end if; end process; DRAW_SQUARE_next: process (column_counter, line_counter, v_enable, h_enable, toggle_sig) begin if v_enable = ENABLE and h_enable = ENABLE then if (column_counter >= X_MIN and column_counter <= X_MAX and -- if pixel within the rectangle borders line_counter >= Y_MIN and line_counter <= Y_MAX) then r_next <= toggle_sig; -- ...red g_next <= COLR_OFF; -- ...green b_next <= not toggle_sig; -- ...blue else -- if somewhere else on screen... r_next <= COLR_OFF; g_next <= COLR_OFF; -- ... draw background color b_next <= COLR_OFF; end if; else -- if out of screen... r_next <= COLR_OFF; g_next <= COLR_OFF; -- ... do not activate any color b_next <= COLR_OFF; -- (black screen) end if; end process; ----------------------------------------------------------------------------- -- control blinking of rectangle ----------------------------------------------------------------------------- BLINKER_syn: process(clk, reset) begin if (reset = RES_ACT) then -- asyn reset toggle_counter_sig <= (others => '0'); toggle_sig <= COLR_OFF; elsif(clk'event and clk = '1') then -- synchronous capture toggle_counter_sig <= toggle_counter_next; toggle_sig <= toggle_next; end if; end process; BLINKER_next : process(toggle_counter_sig, toggle_sig) begin if toggle_counter_sig >= HALFPERIOD then -- after half period ... toggle_counter_next <= (others => '0'); -- ... clear counter toggle_next <= not(toggle_sig); -- ... and toggle colour. else -- before half period ... toggle_counter_next <= toggle_counter_sig + '1'; -- ... increment counter toggle_next <= toggle_sig; -- ... and hold colour end if; end process; -- assign auxiliary signals to module outputs toggle <= toggle_sig; toggle_counter <= toggle_counter_sig; end behav; ------------------------------------------------------------------------------- -- END ARCHITECTURE -------------------------------------------------------------------------------