找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4467|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

VHDL數(shù)組

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:51269 發(fā)表于 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進制表示數(shù)X“2f”,每個數(shù)字代表四位二進制,等于“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進制表示數(shù)O“235”,每個數(shù)字代表三位二進制數(shù),等于“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空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表