首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

新手求助

新手求助

抄书上的一个8分频的例子:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity clk_8d is
 port(clk:in std_logic;
   rst:in std_logic;
   signal clk_dut std_logic);
end clk_8d;

architecture one of clk_8d is
 signal count:std_logic_vector(1 downto 0);
 begin
  process(rst,clk)
  begin
   if(rst='0')then
    clk_d <= '0';
    count(1 downto 0)<="00";
   else
    if (clk'event and clk='1')then
     count(1 downto 0)<=count(1 downto 0)+"01";
     if(count(1 downto 0) = "11")then
      clk_d<=not clk_d;
     else
      null;
    end if;
   end if;
  end process;
 end one;

出现如下错误:

在process附近(最后一个process)出现语法错误:expecting a sequential statement

哪位高手帮我解答一下,小弟万分感谢

你有三个if,end if只有两个
美梦成真-->噩梦降临!

谢谢楼上的解答!

还有这个句子clk_d<=not clk_d是错误的,输出是不能做反馈量

看来书上的东西没有错误是不可能的

一般来说,书上只有思路是对的,它提供的例子十有八九是不能直接使用的,多多少少要做一些修改,他这个例子错的有点多了;

改成下面那样就能实现8分频了,还有很多种写法都可以实现,有时间你可以试试看。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity clk_8d is
 port(clk:in std_logic;
   rst:in std_logic;
   clk_dut std_logic);
end clk_8d;

architecture one of clk_8d is
 signal count:std_logic_vector(1 downto 0);
 signal clk_d_temp:std_logic;
 
 begin
  process(rst,clk)
  begin
   if(rst='0')then
    clk_d <= '0';
    count(1 downto 0)<="00";
   else
    if (clk'event and clk='1')then
     count(1 downto 0)<=count(1 downto 0)+"01";
     if(count(1 downto 0) = "11")then
      clk_d_temp <= not clk_d_temp;
     else
      null;
     end if;
    end if;
    clk_d<=clk_d_temp;
   end if;
  end process;
 end one;


美梦成真-->噩梦降临!
返回列表