OpenCores
URL https://opencores.org/ocsvn/usb_fpga_2_13/usb_fpga_2_13/trunk

Subversion Repositories usb_fpga_2_13

[/] [usb_fpga_2_13/] [trunk/] [examples/] [usb-fpga-1.11/] [1.11b/] [lightshow/] [fpga/] [lightshow.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
library ieee;
2
use IEEE.std_logic_1164.all;
3
use IEEE.std_logic_arith.all;
4
use IEEE.std_logic_unsigned.all;
5
 
6
entity lightshow is
7
   port(
8
      led     : out std_logic_vector(11 downto 0);
9
      CLK     : in std_logic            -- 32 MHz
10
   );
11
end lightshow;
12
 
13
--signal declaration
14
architecture RTL of lightshow is
15
 
16
type tPattern is array(11 downto 0) of integer range 0 to 15;
17
 
18
signal pattern1 : tPattern := (0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1);
19
signal pattern2 : tPattern := (6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5);
20
signal pattern3 : tPattern := (0, 1, 4, 9, 4, 1, 0, 0, 0, 0, 0, 0);
21
 
22
type tXlatTable1 is array(0 to 12) of integer range 0 to 1023;
23
constant xt1 : tXlatTable1 := (0, 0, 1, 4, 13, 31, 64, 118, 202, 324, 493, 722, 1023);
24
type tXlatTable2 is array(0 to 9) of integer range 0 to 255;
25
--constant xt2 : tXlatTable2 := (0, 1, 11, 38, 90, 175, 303, 481, 718, 1023);
26
constant xt2 : tXlatTable2 := (0, 0, 3, 9, 22, 44, 76, 120, 179, 255);
27
 
28
signal cp1 : std_logic_vector(22 downto 0);
29
signal cp2 : std_logic_vector(22 downto 0);
30
signal cp3 : std_logic_vector(22 downto 0);
31
signal d : std_logic_vector(16 downto 0);
32
 
33
begin
34
    dpCLK: process(CLK)
35
    begin
36
         if CLK' event and CLK = '1' then
37
 
38
            if ( cp1 = conv_std_logic_vector(3000000,23) )
39
            then
40
                pattern1(10 downto 0) <= pattern1(11 downto 1);
41
                pattern1(11) <= pattern1(0);
42
                cp1 <= (others => '0');
43
            else
44
                cp1 <= cp1 + 1;
45
            end if;
46
 
47
            if ( cp2 = conv_std_logic_vector(2200000,23) )
48
            then
49
                pattern2(10 downto 0) <= pattern2(11 downto 1);
50
                pattern2(11) <= pattern2(0);
51
                cp2 <= (others => '0');
52
            else
53
                cp2 <= cp2 + 1;
54
            end if;
55
 
56
            if ( cp3 = conv_std_logic_vector(1500000,23) )
57
            then
58
                pattern3(11 downto 1) <= pattern3(10 downto 0);
59
                pattern3(0) <= pattern3(11);
60
                cp3 <= (others => '0');
61
            else
62
                cp3 <= cp3 + 1;
63
            end if;
64
 
65
            if ( d = conv_std_logic_vector(1278*64-1,17) )
66
            then
67
                d <= (others => '0');
68
            else
69
                d <= d + 1;
70
            end if;
71
 
72
            for i in 0 to 11 loop
73
                if ( d(16 downto 6) < conv_std_logic_vector( xt1(pattern1(i) + pattern2(i)) + xt2(pattern3(i)) ,11) )
74
                then
75
                    led(i) <= '1';
76
                else
77
                    led(i) <= '0';
78
                end if;
79
            end loop;
80
 
81
        end if;
82
    end process dpCLK;
83
 
84
end RTL;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.