Browse Source

VGA process done. UCF done.

master
Enrique Fernandez 3 years ago
parent
commit
6a5d2ea3de
  1. 140
      PicoBlaze_s3estarterUCF.backup
  2. 10
      controllerVGA.vhd
  3. 28
      projectVGA.ucf
  4. 65
      toplevel.vhd

140
PicoBlaze_s3estarter.ucf → PicoBlaze_s3estarterUCF.backup

@ -1,73 +1,73 @@
# ==== Clock inputs (CLK) ====
NET "clk" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
# Define clock period for 50 MHz oscillator (40%/60% duty-cycle)
NET "clk" PERIOD = 20.0ns HIGH 40%;
# ==== Slide Switches (SW) ====
#NET "SW<0>" LOC = "L13" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<1>" LOC = "L14" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<2>" LOC = "H18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<3>" LOC = "N17" | IOSTANDARD = LVTTL | PULLUP ;
# ==== Discrete LEDs (LED) ====
# These are shared connections with the FX2 connector
NET "LED" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<0>" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<1>" LOC = "E12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<2>" LOC = "E11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<3>" LOC = "F11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<4>" LOC = "C11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<5>" LOC = "D11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<6>" LOC = "E9" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<7>" LOC = "F9" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
## ==== RS-232 Serial Ports (RS232) ====
NET "rx" LOC = "R7" | IOSTANDARD = LVTTL ;
NET "tx" LOC = "M14" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
# ==== Clock inputs (CLK) ====
NET "clk" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
# Define clock period for 50 MHz oscillator (40%/60% duty-cycle)
NET "clk" PERIOD = 20.0ns HIGH 40%;
# ==== Slide Switches (SW) ====
#NET "SW<0>" LOC = "L13" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<1>" LOC = "L14" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<2>" LOC = "H18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "SW<3>" LOC = "N17" | IOSTANDARD = LVTTL | PULLUP ;
# ==== Discrete LEDs (LED) ====
# These are shared connections with the FX2 connector
NET "LED" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<0>" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<1>" LOC = "E12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<2>" LOC = "E11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<3>" LOC = "F11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<4>" LOC = "C11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<5>" LOC = "D11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<6>" LOC = "E9" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
#NET "LED<7>" LOC = "F9" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
## ==== RS-232 Serial Ports (RS232) ====
NET "rx" LOC = "R7" | IOSTANDARD = LVTTL ;
NET "tx" LOC = "M14" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
#NET "RS232_DCE_RXD" LOC = "R7" | IOSTANDARD = LVTTL ;
#NET "RS232_DCE_TXD" LOC = "M14" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
#NET "RS232_DTE_RXD" LOC = "U8" | IOSTANDARD = LVTTL ;
#NET "RS232_DTE_TXD" LOC = "M13" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
#
## ==== Rotary Pushbutton Switch (ROT) ====
#NET "ROT_A" LOC = "K18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "ROT_B" LOC = "G18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "ROT_CENTER" LOC = "V16" | IOSTANDARD = LVTTL | PULLDOWN ;
#
## ==== Pushbuttons (BTN) ====
#NET "BTN_EAST" LOC = "H13" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_NORTH" LOC = "V4" | IOSTANDARD = LVTTL | PULLDOWN ;
NET "reset" LOC = "K17" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_SOUTH" LOC = "K17" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_WEST" LOC = "D18" | IOSTANDARD = LVTTL | PULLDOWN ;
#
#NET "in_port<7>" LOC = "";
#NET "in_port<6>" LOC = "";
#NET "in_port<5>" LOC = "";
#NET "in_port<4>" LOC = "";
#NET "in_port<3>" LOC = "";
#NET "in_port<2>" LOC = "";
#NET "in_port<1>" LOC = "";
#NET "in_port<0>" LOC = "";
#NET "out_port<7>" LOC = "";
#NET "out_port<6>" LOC = "";
#NET "out_port<5>" LOC = "";
#NET "out_port<4>" LOC = "";
#NET "out_port<3>" LOC = "";
#NET "out_port<2>" LOC = "";
#NET "out_port<1>" LOC = "";
#NET "out_port<0>" LOC = "";
#NET "port_id<7>" LOC = "";
#NET "port_id<6>" LOC = "";
#NET "port_id<5>" LOC = "";
#NET "port_id<4>" LOC = "";
#NET "port_id<3>" LOC = "";
#NET "port_id<2>" LOC = "";
#NET "port_id<1>" LOC = "";
#NET "port_id<0>" LOC = "";
#NET "a5" LOC = "";
#NET "read_strobe" LOC = "";
#NET "write_strobe" LOC = "";
#NET "interrupt" LOC = "";
#NET "RS232_DTE_TXD" LOC = "M13" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
#
## ==== Rotary Pushbutton Switch (ROT) ====
#NET "ROT_A" LOC = "K18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "ROT_B" LOC = "G18" | IOSTANDARD = LVTTL | PULLUP ;
#NET "ROT_CENTER" LOC = "V16" | IOSTANDARD = LVTTL | PULLDOWN ;
#
## ==== Pushbuttons (BTN) ====
#NET "BTN_EAST" LOC = "H13" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_NORTH" LOC = "V4" | IOSTANDARD = LVTTL | PULLDOWN ;
NET "reset" LOC = "K17" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_SOUTH" LOC = "K17" | IOSTANDARD = LVTTL | PULLDOWN ;
#NET "BTN_WEST" LOC = "D18" | IOSTANDARD = LVTTL | PULLDOWN ;
#
#NET "in_port<7>" LOC = "";
#NET "in_port<6>" LOC = "";
#NET "in_port<5>" LOC = "";
#NET "in_port<4>" LOC = "";
#NET "in_port<3>" LOC = "";
#NET "in_port<2>" LOC = "";
#NET "in_port<1>" LOC = "";
#NET "in_port<0>" LOC = "";
#NET "out_port<7>" LOC = "";
#NET "out_port<6>" LOC = "";
#NET "out_port<5>" LOC = "";
#NET "out_port<4>" LOC = "";
#NET "out_port<3>" LOC = "";
#NET "out_port<2>" LOC = "";
#NET "out_port<1>" LOC = "";
#NET "out_port<0>" LOC = "";
#NET "port_id<7>" LOC = "";
#NET "port_id<6>" LOC = "";
#NET "port_id<5>" LOC = "";
#NET "port_id<4>" LOC = "";
#NET "port_id<3>" LOC = "";
#NET "port_id<2>" LOC = "";
#NET "port_id<1>" LOC = "";
#NET "port_id<0>" LOC = "";
#NET "a5" LOC = "";
#NET "read_strobe" LOC = "";
#NET "write_strobe" LOC = "";
#NET "interrupt" LOC = "";

10
controllerVGA.vhd

@ -6,6 +6,7 @@ use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity controllerVGA is
port(
clk : in std_logic; -- Spartan 3E 50MHz de clk
clk_25 : out std_logic; -- reloj 25MHz del VGA
hsync, vsync : out std_logic;
ready : out std_logic;
x : out std_logic_vector(9 downto 0);
@ -26,7 +27,7 @@ architecture controllerVGA of controllerVGA is
constant v_backPorch : integer := 33;
constant v_syncPulse : integer 2;
signal clk_25 : std_logic := '0'; -- Empieza en 0.
signal s_clk_25 : std_logic := '0'; -- Empieza en 0.
-- Max valor será 800 (h_limit) 800 -> 1100100000
signal h_currentPos : std_logic_vector(9 downto 0) := (others=> '0');
@ -45,14 +46,15 @@ begin
clk25MHz: process(clk):
begin
if(rising_edge(clk)) then
clk_25 <= NOT clk;
s_clk_25 <= NOT s_clk_25;
end if;
end process;
clk_25 <= s_clk_25;
-- Proceso de actualización de VGA. Barrido de sincronizacion hor/ver
sync: process(clk_25):
sync: process(s_clk_25):
begin
if(rising_edge(clk_25)) then
if(rising_edge(s_clk_25)) then
if h_currentPos < h_limit - 1 then
-- Aumentamos el contador Horizontal.
h_currentPos <= h_currentPos + 1;

28
projectVGA.ucf

@ -0,0 +1,28 @@
#####################################################
### SPARTAN-3E STARTER KIT BOARD CONSTRAINTS FILE
#####################################################
## Mapeo de puertos de salida para el proyecto de la P2.
## ==== Clock inputs (CLK) ====
NET "clk" LOC = "C9" | IOSTANDARD = LVCMOS33 ;
# Define clock period for 50 MHz oscillator (40%/60% duty-cycle)
NET "clk" PERIOD = 20.0ns HIGH 40%;
## ==== Discrete LEDs (LED) ====
NET "LED" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
## ==== RS-232 Serial Ports (RS232) ====
NET "rx" LOC = "R7" | IOSTANDARD = LVTTL ;
NET "tx" LOC = "M14" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
## ==== Pushbuttons (BTN) ====
# Boton derecha
NET "reset" LOC = "K17" | IOSTANDARD = LVTTL | PULLDOWN ;
## ==== VGA Port (VGA) ====
NET "R" LOC = "H14" ;
NET "G" LOC = "H15" ;
NET "B" LOC = "G15" ;
NET "H" LOC = "F15" ;
NET "V" LOC = "F14" ;

65
toplevel.vhd

@ -15,7 +15,7 @@ entity toplevel is
tx : out std_logic;
LED : out std_logic; --led de comprobacion y reset
-- Cosas del VGA
R,G,B : out std_logic;
R,G,B : out std_logic;
H,V : out std_logic);
end toplevel ;
@ -79,7 +79,10 @@ x"2A", x"0A", x"0D", x"00", x"00", x"00", x"00", x"00" );
signal rxbuff_out,RAM_out: std_logic_vector(7 downto 0);
-- VGA signals
constant h_displayArea : integer := 640;
constant v_displayArea : integer := 480;
signal x, y : std_logic_vector(9 downto 0);
signal clk_25 : std_logic;
signal ready : std_logic;
signal r,g,b : std_logic;
signal hsync, vsync : std_logic;
@ -128,17 +131,65 @@ begin
vga:controllerVGA
port map( clk => clk,
clk_25 => clk_25;
hsync => hsync,
vsync => vsync,
ready => ready,
x => x,
y => y);
-- Mandamos la sincronziacion a los puertos de salida
x => x, -- X es la cuenta de la posicion
y => y); -- Y es la cuenta de la posicion
-- TODO: Proceso controlador del VGA. SIN COMPROBAR!!!
vga:process(clk25)
-- Variable para los colores. CARGA INSTANTANEA DEL VALOR, SOLO PARA USO TEMPORAL!!
variable RGB : std_logic_vector(2 downto 0) := (others => '0');
begin
if rising_edge(clk25) then
if reset = '1' then
hsync <= '1';
vsync <= '1';
RGB := (others => '0');
else
-- Si estamos dentro del rango de display
if (x < h_displayArea AND y < v_displayArea) then
-- Default color como black
RGB := (others => '0');
-- Dibujamos un borde de 2px en LEFT
if x>= 0 AND x<2 then
RGB := "1" & "1" & "0";
-- Dibujamos un borde de 2px en RIGHT
elsif x<= h_displayArea - 1 AND x > h_displayArea - 3 then
RGB := "1" & "1" & "0";
end if;
-- Dibujamos borde de 2px en TOP
if y>=0 AND y<2 then
RGB := "1" & "1" & "0";
-- Dibujamos borde de 2px en BOT
elsif y<= v_displayArea - 1 AND y > v_displayArea - 3 then
RGB := "1" & "1" & "0";
end if;
-- Por si queremos dibujar más mierda va aqui
-- Sacamos los colores por los puertos de la FPGA
R <= RGB(2);
G <= RGB(1);
B <= RGB(0);
else
R <= "0";
G <= "0";
B <= "0";
end if;
end if;
end if;
end process;
-- Mandamos la sincronziacion a los puertos de salida
H <= hsync;
V <= vsync;
-- TODO: Proceso controlador del VGA.
--registra el bit tx del puerto de salida, por si éste cambia
-- Usamos el puerto FF.

Loading…
Cancel
Save