Tengo un código para mostrar el bloque en la pantalla VGA pero quiero mostrar los números en él. Tengo una pequeña idea de cómo diseñarlo, pero programáticamente, estoy teniendo dificultades. Puedo definirlo como una constante en términos de número binario como este: constante uno :: = (0 = > ”0000001110000000”, 1 = > ”0000001110000000”, 2 = > ”0000001110000000”, 3 = > ”0000001110000000”, 4 = > ”0000001110000000”, 5 = > ”0000001110000000”, 6 = > ”0000001110000000”, 7 = > ”0000001110000000”, 8 = > ”0000001110000000”, 9 = > ”0000001110000000”, 10 = > ”0000001110000000”, 11 = > ”0000001110000000”, 12 = > ”0000001110000000”, 13 = > ”0000001110000000”, 14 = > ”0000001110000000”, 15 = > ”0000001110000000”);
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity TheirVGA is
port(mclk, btn, reset: in std_logic;
vs, hs: out std_logic;
red, grn, blu, led: out std_logic);
attribute syn_noclockbuf : boolean;
attribute syn_noclockbuf of btn : signal is true;
end TheirVGA;
architecture Behavioral of TheirVGA is
signal clkPix: std_logic;
signal cntHorz, cntVert: std_logic_vector(9 downto 0);
signal sncHorz, clkLine, blkHorz: std_logic;
signal sncVert, blkVert, blkDisp, clkColor: std_logic;
signal cntImg: std_logic_vector(6 downto 0);
signal cntColor: std_logic_vector(2 downto 0);
signal upper, left, lower, right: std_logic_vector(11 downto 0);
begin
---------------------------------------------------------------
VGA Controller Test
------------------------------------------------------------------------
-- Divide the D2XL oscillator down to form the pixel clock
-- that is the basis for all of the other timing.
process (mclk)
begin
if mclk = '1' and mclk'Event then
clkPix <= not clkPix;
end if;
end process;
-- Generate the horizontal timing.
process (clkPix)
begin
if clkPix = '1' and clkPix'Event then
if cntHorz = "0001011101" then
cntHorz <= cntHorz + 1;
sncHorz <= '1';
elsif cntHorz = "0010001100" then
cntHorz <= cntHorz + 1;
blkHorz <= '0';
elsif cntHorz = "1100001100" then
cntHorz <= cntHorz + 1;
blkHorz <= '1';
elsif cntHorz = "1100011010" then
cntHorz <= "0000000000";
clkLine <= '1';
sncHorz <= '0';
else
cntHorz <= cntHorz + 1;
clkLine <= '0';
end if;
end if;
end process;
-- Generate the vertical timing.
process (clkLine)
begin
if clkLine = '1' and clkLine'Event then
if cntVert = "0000000001" then
cntVert <= cntVert + 1;
sncVert <= '1';
elsif cntVert = "0000011010" then
cntVert <= cntVert + 1;
blkVert <= '0';
elsif cntVert = "0111111010" then
cntVert <= cntVert + 1;
blkVert <= '1';
elsif cntVert = "1000001100" then
cntVert <= "0000000000";
sncVert <= '0';
if(reset = '1') then
left <= X"12C";
right <= X"1F4";
lower <= X"1C2";
upper <= X"0FA";
elsif(btn = '1') then
left <= left - 2;
right <= right - 2;
lower <= lower - 1;
upper <= upper -1;
end if;
else
cntVert <= cntVert + 1;
end if;
end if;
end process;
-- Divide the active portion of a scan line into 8 regions.
-- This counts up to 79 and then resets. Each time it
-- resets, it generates a pulse on clkColor.
process (clkPix, blkDisp)
begin
if clkPix = '1' and clkPix'Event then
if blkDisp = '1' then
cntImg <= "0000000";
else
if cntImg = "1001111" then
cntImg <= "0000000";
clkColor <= '1';
else
cntImg <= cntImg + 1;
clkColor <= '0';
end if;
end if;
end if;
end process;
-- Increment the output color for each scan line region.
--process (clkPix, clkColor, blkDisp)
-- begin
-- if clkPix = '1' and clkPix'Event then
-- if blkDisp = '1' then
-- cntColor <= "111";
-- else
-- if clkColor = '1' then
-- cntColor <= cntColor + 1;
-- end if;
-- end if;
-- end if;
--end process;
led <= btn;
blkDisp <= blkVert or blkHorz;
cntColor <= "110" when cntHorz < right and cntHorz > left and cntVert < lower and cntVert > upper else "100"; -- and else "111";
vs <= sncVert;
hs <= sncHorz;
blu <= cntColor(0) and (not blkDisp);
grn <= cntColor(1) and (not blkDisp);
red <= cntColor(2) and (not blkDisp);
end Behavioral;