Created
February 6, 2014 00:13
-
-
Save axpence/8836044 to your computer and use it in GitHub Desktop.
TOPPER - other guys code.,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.numeric_std.all; | |
use work.lab4package.all; | |
entity lab4top is | |
port( | |
-- input | |
top_clk: in std_logic; | |
switches : in std_logic_vector(2 downto 0); | |
buttons : in std_logic_vector (3 downto 0); | |
-- output | |
top_rgb : out std_logic_vector(2 downto 0); | |
top_HS, top_VS: out std_logic; | |
top_last_column: out std_logic; | |
top_last_row: out std_logic | |
); | |
end lab4top; | |
architecture colorBarTest of lab4top is | |
signal top_pixel_en: std_logic; -- TOGGLE Circuit Component | |
signal reset : std_logic := '1'; | |
signal t_pixel_x: unsigned (9 downto 0); | |
signal t_pixel_y: unsigned (9 downto 0); | |
signal top_blank : std_logic:='0'; | |
-- register signals for HS, VS and RGB | |
signal temp_HS : std_logic := '1'; | |
signal temp_VS : std_logic := '1'; | |
signal temp_rgb : std_logic_vector(2 downto 0) := "000"; | |
--HORIZONTAL COLOR BAR | |
signal rgb_H: std_logic_vector(2 downto 0); | |
constant H1: integer:=79; --Black | |
constant H2: integer := 159; --Blue | |
constant H3 : integer := 239; -- Green | |
constant H4 : integer := 319; -- Cyan | |
constant H5 : integer := 399; -- Red | |
constant H6 : integer :=479; -- Magenta | |
constant H7 : integer := 559; -- Yellow | |
constant H8 : integer := 639; --White | |
-- VERTICAL COLOR BAR | |
signal rgb_V: std_logic_vector(2 downto 0); | |
constant V1: integer:=59; --Black | |
constant V2: integer := 119; --Blue | |
constant V3 : integer := 179; -- Green | |
constant V4 : integer := 239; -- Cyan | |
constant V5 : integer := 299; -- Red | |
constant V6 : integer :=359; -- Magenta | |
constant V7 : integer := 419; -- Yellow | |
constant V8 : integer := 479; --White | |
begin | |
-- Horizontal Colors based on pixel_x | |
rgb_H<= "000" when (t_pixel_x<=H1) else | |
"001" when (t_pixel_x>H1 and t_pixel_x<=H2) else | |
"010" when (t_pixel_x>H2 and t_pixel_x<=H3) else | |
"011" when (t_pixel_x>H3 and t_pixel_x<=H4) else | |
"100" when (t_pixel_x>H4 and t_pixel_x<=H5) else | |
"101" when (t_pixel_x>H5 and t_pixel_x<=H6) else | |
"110" when (t_pixel_x>H6 and t_pixel_x<=H7) else | |
"111" when (t_pixel_x>H7 and t_pixel_x<=H8) else | |
"000"; | |
--Vertical Colors based on pixel_y | |
rgb_V<= "000" when (t_pixel_y<=V1)else | |
"001" when (t_pixel_y>V1 and t_pixel_y<=V2) else | |
"010" when (t_pixel_y>V2 and t_pixel_y<=V3) else | |
"011" when (t_pixel_y>V3 and t_pixel_y<=V4) else | |
"100" when (t_pixel_y>V4 and t_pixel_y<=V5) else | |
"101" when (t_pixel_y>V5 and t_pixel_y<=V6) else | |
"110" when (t_pixel_y>V6 and t_pixel_y<=V7) else | |
"111" when (t_pixel_y>V7 and t_pixel_y<=V8) else | |
"000"; | |
-- the pixel_en and the reset signal | |
process(top_clk) | |
begin | |
if(top_clk'event and top_clk='1')then | |
top_pixel_en<=not(top_pixel_en); | |
reset<='0'; | |
end if; | |
end process; | |
temp_rgb<="000" when (buttons="0001" or top_blank='1') else | |
switches when (buttons="0010") else | |
rgb_V when (buttons="0100") else | |
rgb_H when (buttons="1000") else | |
"100"; | |
process(top_clk, reset) | |
begin | |
if(reset='1') then | |
top_HS <= '1'; | |
top_VS <='1'; | |
top_rgb<="000"; | |
elsif(top_clk'event and top_clk='1')then | |
top_HS<= temp_HS; | |
top_VS<=temp_VS; | |
top_rgb<=temp_rgb; | |
end if; | |
end process; | |
-- component instatiation | |
CBT:vgaTiming | |
port map( | |
clk=>top_clk, | |
rst=>reset, | |
pixel_en => top_pixel_en, | |
HS=>temp_HS, | |
VS=>temp_VS, | |
last_row=>top_last_row, | |
last_column=>top_last_column, | |
blank=>top_blank, | |
pixel_x=>t_pixel_x, | |
pixel_y=>t_pixel_y | |
); | |
end colorBarTest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment