|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 BYbread 于 2015-4-26 15:42 编辑
底层实体(entity)定义了D:in integer range 0 to 15;
在顶层的例化(component)写成D:IN STD_LOGIC_VECTOR()3 DOWNTO 0);仿真出错。在quartus ii中的程序编译是OK的,quartus 8自带的仿真可以运行。但为什么在modelsim中说数据类型不匹配。# ** Failure: (vsim-3807) Types do not match between component and entity for port "d".
# Time: 0 ps Iteration: 0 Instance: /pwm/u1 File: E:/..................count.vhd Line: 8
# Fatal error in file E:/.............../count.vhd
# while elaborating region: /pwm/u1
# Load interrupted
# Error loading design代码如下:底层:
- library ieee ;
- use ieee.std_logic_1164.all ;
- entity count is
- port
- (
- clk,ld:in std_logic;
- d:in integer range 0 to 255;
- over:out std_logic
- );
- end entity count;
- architecture art of count is
- signal count_255:integer range 0 to 255;
- begin
- process(clk) is
- begin
- if rising_edge(clk) then
- if ld='1' then count_255 <= d;
- else count_255 <= count_255+1;
- end if;
- end if;
- end process;
-
- process(count_255) is
- begin
- if count_255 = 255 then over <= '1';
- else over <= '0';
- end if;
- end process;
- end architecture art;
复制代码 顶层:
- library ieee ;
- --use ieee.std_logic_arith.all;
- use ieee.std_logic_1164.all ;
- --use ieee.std_logic_unsigned.all ;
- entity PWM is
- port
- (
- clk:in std_logic;
- A,B:in std_logic_vector(7 downto 0);
- pwm:out std_logic
- );
- end entity PWM;
- architecture art of PWM is
- component count is
- port
- (
- clk,ld:in std_logic;
- d:in STD_logic_vector(7 DOWnto 0) ;
- over:out std_logic
- );
- end component;
- signal over1,over2 : std_logic;
- signal ld1, ld2 : std_logic;
- signal spwm : std_logic:='0';
- signal data1,data2 : integer range 0 to 255;
- begin
- u1:count port map(clk,ld1,A,over1);
- u2:count port map(clk,ld2,B,over2);
- process(over1,over2) is
- begin
- if over1= '1' then spwm <= '0';
- elsif rising_edge(over2) then spwm <= '1';
- end if;
- end process;
- ld1 <= not spwm ;
- ld2 <= spwm ;
- pwm <=spwm ;
- end architecture art;
复制代码 |
|