打印
[Actel FPGA]

一个使用VHDL实现十分频的低级问题

[复制链接]
1827|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
shen8103|  楼主 | 2009-5-16 16:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    一个是希望让其输出为初始值“1”,一个是希望计数器cnt初始不为0从而实现移相,可是在定义的后面加:=赋值模拟出来的波形居然是一样的,郁闷死我了。请大虾指教一下问题出在什么地方呀?谢谢了!

    这么简单的东西搞了一个下午搞不定,真是惭愧呀=.=

下面是代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity div5_5 is
    port(clk:    in     std_logic;
    div10:    out    std_logic);
end;

architecture one of div5_5 is
        signal cnt    :std_logic_vector(2 downto 0);
        signal clk_temp    :std_logic;
        signal d        :std_logic;
        constant m        :integer:=4;

begin
process(clk)
begin
if clk'event and clk='1' then
    if cnt=m then
        clk_temp<=not clk_temp;
        cnt<="000";
    else
        cnt<=cnt+1;
    end if;
end if;
end process;

div10<=clk_temp;
end;

相关帖子

沙发
zlgactel| | 2009-5-19 15:41 | 只看该作者

发现一个错误,

if cnt=m then
        clk_temp<=not clk_temp;
        cnt<="000";
end if;
    else
        cnt<=cnt+1;
    end if;

注意第一个end if,很久没用VHDL,其余的错误有待你自己发现,如果要赋初值,加入以复位信号即可。

使用特权

评论回复
板凳
usber| | 2009-5-20 12:58 | 只看该作者

路过

使用特权

评论回复
地板
shen8103|  楼主 | 2009-5-26 11:23 | 只看该作者

谢谢

使用特权

评论回复
5
vxxw| | 2009-5-26 16:27 | 只看该作者

可以通过别的方法移相

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

entity div5_5 is
    port(clk:    in     std_logic;
    div10:    out    std_logic);
end;

architecture one of div5_5 is
        signal cnt    :integer rang 0 to 9;
       signal clk_temp:std_logic;
begin
process(clk,cnt)
begin
if clk'event and clk='1' then
    if cnt<9 then
        cnt<=cnt+1;
else cnt<=0;
        end if;
    
    end if;
if cnt<5 then clk_temp<='1';
else clk_temp<='0';
end if;
end process;

div10<=clk_temp;
end one;


使用特权

评论回复
6
yxhyxh| | 2009-6-1 11:58 | 只看该作者

呵呵,是这里错了

cnt<=cnt+1;
改成
cnt<=cnt+'1';

VHDL与C不一样哦。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

54

主题

252

帖子

1

粉丝