我试图模拟脉宽调制(PMW(波形发生器,但在ISE中出现语法错误。查看fuse.xmsgs,发现它在柜台附近。有人能指出语法错误吗?
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.numeric_std.all;
entity pwm_gen is
port
(
clock, reset : in std_logic;
width : in std_logic_vector(7 downto 0);
pwm : out std_logic);
end pwm_gen;
architecture bhv of pwm_gen is
type counter is range 0 to 255;
counter count := 0;
begin
process (clock)
begin
if (reset = '1') then
count <= 0;
elsif (clock'event and clock = '1') then
if (count <= width) then
count <= count + 1;
pwm <= '1';
else
count <= count + 1;
pwm <= '0';
end if;
end if;
end process;
end bhv;
counter count := 0;
这是非法语法,因为您没有声明对象类(signal、constant、variable(。您需要使用以下格式:
signal count : counter := 0
这也是非法的,因为您正在将一个整数与尚未包含包的std_logic_vector
进行比较。您需要将slv转换为unsigned
if (count <= unsigned(width)) then
最后,灵敏度列表中缺少reset