找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3972|回复: 0
打印 上一主题 下一主题
收起左侧

VHDL数组

[复制链接]
跳转到指定楼层
楼主
ID:51269 发表于 2014-11-10 15:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Library ieee;
use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
entity ddd is
port(clk:in std_logic;
     sec:out std_logic;
     Q:out std_logic_vector(17 downto 0));
end ;
Architecture dd of ddd is
   type ram2 is array(0 to 59) of std_logic_vector(17 downto 0);
   constant cgram:ram2:=(
          ("100000000000000001"),
          ("110000000000000011"),
          ("111000000000000111"),
          ("111100000000001111"),
          ("111110000000011111"),
          ("111111000000111111"),
          ("111111100001111111"),
          ("111111110011111111"),
          ("111111111111111111"),
          ("111111110011111111"),
          ("111111100001111111"),
          ("111111000000111111"),   
          ("111110000000011111"),
          ("111100000000001111"),
          ("110000000000000011"),
          ("100000000000000001"),
         ("100000000000000001"),
          ("010000000000000010"),
          ("001000000000000100"),
          ("000100000000001000"),
          ("000010000000010000"),
          ("000001000000100000"),
          ("000000100001000000"),
          ("000000010010000000"),
          ("000000001100000000"),
          ("100000000000000000"),
          ("010000000000000000"),
         ("001000000000000000"),
         ("000100000000000000"),
         ("000010000000000000"),
         ("000001000000000000"),
         ("000000100000000000"),
          ("000000010000000000"),
          ("000000001000000000"),
    ("000000000100000000"),
    ("000000000010000000"),
    ("000000000001000000"),
    ("000000000000100000"),
    ("000000000000010000"),
    ("000000000000001000"),
          ("000000000000000100"),
    ("000000000000000010"),
    ("000000000000000001"),
    ("000000000000000010"),
    ("000000000000000100"),
    ("000000000000001000"),
      ("000000000000010000"),
          ("000000000000100000"),
    ("000000000001000000"),
    ("000000000010000000"),
    ("000000000100000000"),
    ("000000001000000000"),
    ("000000010000000000"),
    ("000000100000000000"),
          ("000001000000000000"),
    ("000010000000000000"),
    ("000100000000000000"),
    ("001000000000000000"),
    ("010000000000000000"),
    ("100000000000000000"));
   
signal cp:std_logic;
signal ww:integer range 0 to 5000000;
signal cnt:integer range 0 to 59;
begin
process(clk)
   begin
   if clk'event and clk='1' then
       ww<=ww+1;
    if ww=0 then
       cp<=not cp;     
   end if;   
   end if;
   end process;
  process(cp)
  begin
    if cp'event and cp='1' then
     cnt<=cnt+1;
   Q<=cgram(cnt);   
   end if;
  end process;
end;
----------------------------------------------------------------------------------------------------------------------
Library ieee;
use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
entity ddd is
port(clk:in std_logic;
     sec:out std_logic;
     Q:out std_logic_vector(17 downto 0));
end ;
Architecture dd of ddd is
   type ram2 is array(0 to 55) of std_logic_vector(19 downto 0);
   constant cgram:ram2:=(
--用16进制表示数X“2f”,每个数字代表四位二进制,等于“00101111”
      (X"20001"),(X"30003"),(X"38007"),(X"3c00f"),(X"3e01f"),
  (X"3f03f"),(X"3f87f"),(X"3fcff"),(X"3ffff"),(X"3fcff"),
  (X"3f87f"),(X"3f03f"),(X"3e01f"),(X"3c00f"),(X"38007"),
  (X"30003"),(X"20001"),(X"00000"),(X"20000"),(X"10000"),
  (X"08000"),(X"04000"),(X"02000"),(X"01000"),(X"00800"),
  (X"00400"),(X"00200"),(X"00100"),(X"00080"),(X"00040"),
  (X"00020"),(X"00010"),(X"00008"),(X"00004"),(X"00002"),
  (X"00001"),(X"00000"),(X"00001"),(X"00002"),(X"00004"),
      (X"00008"),(X"00010"),(X"00020"),(X"00040"),(X"00080"),
  (X"00100"),(X"00200"),(X"00400"),(X"00800"),(X"01000"),
  (X"02000"),(X"04000"),(X"08000"),(X"10000"),(X"20000"),
  (X"00000")
);
    type ram1 is array(0 to 5) of std_logic_vector(5 downto 0);
   constant dat:ram1:=(
--用8进制表示数O“235”,每个数字代表三位二进制数,等于“010 011 101“
     (o"01"),(o"02"),(O"04"),(o"10"),(o"20"),(o"40")
);
signal cp:std_logic;
signal ww:integer range 0 to 1000000;
signal cnt:integer range 0 to 55;
begin
process(clk)
   begin
   if clk'event and clk='1' then
       ww<=ww+1;
    if ww=0 then
       cp<=not cp;     
   end if;   
   end if;
   end process;
  process(cp)
  begin
    if cp'event and cp='1' then
     cnt<=cnt+1;
   Q<=cgram(cnt)(17 downto 0);   
   end if;
  end process;
end;

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表