library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;-----------------------包含各种需要的工作库
-------------------------------------------------------
entity top is
Port ( clk32MHz ,handTOauto: in std_logic; --'0' auto;
code1 : out std_logic_vector(6 downto 0);
index1:in std_logic_vector(7 downto 0);
high1 : out std_logic;
spkout : out std_logic);
end top;
-------------------------------------------------------定义输入输出
architecture Behavioral of top is
-------------------------
component automusic
Port ( clk ,Auto: in std_logic;
index2:in std_logic_vector(7 downto 0);
index0 : out std_logic_vector(7 downto 0));
end component;
--------------------------------------------------------元件例化,引入automusic,相当于对
component tone ------automusic进行封装使用
Port ( index : in std_logic_vector(7 downto 0);
code : out std_logic_vector(6 downto 0);
high : out std_logic;
tone0 : out integer range 0 to 2047);
end component;
--------------------------------------------------------元件例化,引入tone
component speaker
Port ( clk1 : in std_logic;
tone1 : in integer range 0 to 2047;
spks : out std_logic);
end component;
--------------------------------------------------------元件例化,引入speaker
signal tone2: integer range 0 to 2047;---------------定义信号tone2,整数型,范围从0到2047
signal indx:std_logic_vector(7 downto 0);------------定义信号indx,8位逻辑矢量
begin
u0:automusic port map(clk=>clk32MHZ,index2=>index1,index0=>indx,Auto=>handtoAuto);
u1: tone port map(index=>indx,tone0=>tone2,code=>code1,high=>high1);
u2: speaker port map(clk1=>clk32MHZ,tone1=>tone2,spks=>spkout);
end Behavioral;--------------------元件端口说明,相当于用图形法时的连线。=>表示从某个端口连接到 ---另一个端口
―――――――――――――――――――――――――――――――――――――――
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-----------------------------------------同上
entity tone is
Port ( index : in std_logic_vector(7 downto 0);
code : out std_logic_vector(6 downto 0);
high : out std_logic;
tone0 : out integer range 0 to 2047);
end tone;
-----------------------------------------同上
architecture Behavioral of tone is
begin
search :process(index)
begin
case index is
when "00000001" => tone0<=773;code<="1001111";high<='1';
when "00000010"=> tone0<=912;code<="0010010";high<='1';
when "00000100" => tone0<=1036;code<="0000110";high<='1';
when "00001000" => tone0<=1116;code<="1001100";high<='1';
when "00010000" => tone0<=1197;code<="0100100";high<='1';
when "00100000" => tone0<=1290;code<="0100000";high<='0';
when "01000000" => tone0<=1372;code<="0001111";high<='0';
when "10000000" => tone0<=1410;code<="0000000";high<='0';
when others => tone0<=2047;code<="0000001";high<='0';
end case;
end process;
end Behavioral;
楼主的程序不完整,缺少对 automusic speaker 两个元件的说明,故具体它的功能没法做出准确回答。
port map 是元件例化语句的组成部分。元件例化语句由两部分组成,第一部分是对一个现成的设计实体定义为一个元件,语句的功能是对待调用的语句的元件做出声明,它的最简表达式为:
component 元件名 is
port(端口名);
end component 元件名;
第二部分则是此元件与当前设计实体中的元件间及端口的连接说明,表达如下:
例化名:元件名 port map(端口名=>连接端口名);
例化名就是你这里的u1,u2 的啦。不知道这样说你懂不懂。