如何解决我在计数器附近的 VHDL 代码中遇到语法错误
我正在尝试模拟脉冲宽度调制 (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 count : counter := 0
这也是非法的,因为您正在将一个整数与一个 std_logic_vector
进行比较,而该 unsigned
没有包含一个包。您需要将 slv 转换为 if (count <= unsigned(width)) then
reset
最后,敏感度列表中缺少@Component
@RequiredArgsConstructor
public class MySchedule {
private final MyClassThatHasTheProcessing process;
@Scheduled(cron = "*/5 * * * * MON-FRI")
public void doSomething() {
// the actual process is made by the method doHeavyProcessing
process.doHeavyProcessing();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。