返回信息流p0 : process(clk,f_add,f_minus,reset) --an approximation of frequency
begin
if reset = '1' then --
div <= 1420;
f_tmp<="0001";
end if;
if f_add ='1' then
if f_tmp ="1010" then
else
f_tmp <= f_tmp+1;
end if;
end if;
if f_minus='1' then
if f_tmp = "0000" then
else
f_tmp<=f_tmp-1;
end if;
end if;
case f_tmp is
when "0000" => div <=1562;
when "0001" => div <=1420; --1.1KHz
when "0010" => div <=1302; --1.2KHz
when "0011" => div <=1201; --1.3KHz
when "0100" => div <=1116; --1.4KHz
when "0101" => div <=1041; --1.5KHz
when "0110" => div <=976; --1.6KHz
when "0111" => div <=919; --1.7KHz
when "1000" => div <=868; --1.8KHz
when "1001" => div <=822; --1.9KHz
when "1010" => div <=781; --2KHz
when others => div <=1562; --default frequency = 1KHz
end case;
if (clk'event and clk='1') then
if cnt = div then --produce clk_m
cnt<=1;
clk_tmp<= not clk_tmp;
else
cnt<=cnt+1;
end if;
end if;
clk_out<=clk_tmp;
f <= f_tmp;
end process p0;
这个仿真没有输出 只有把if (clk'event and clk='1') then这句放在最上面才有输出 放在下面都没有 有人知道这是为什么吗
这是一条镜像帖。来源:北邮人论坛 / circuit / #18647同步于 2011/10/12
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Circuit机器人发帖
求大神帮忙看段VHDL代码错哪了。。多谢了
abensong
2011/10/12镜像同步8 回复
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
报错是啥。。
【 在 abensong (aben_song) 的大作中提到: 】
: p0 : process(clk,f_add,f_minus,reset) --an approximation of frequency
: begin
: if reset = '1' then --
: ...................
额。。我没用到不等号啊。。。这个没报错 不过仿真没输出。。。
【 在 lanphon 的大作中提到: 】
: 友情提醒lz一声,VHDL中,不等号是“/=”。。。
: --
其实我真心想说lz你应该先找本vhdl的书好好看看。。
【 在 abensong (aben_song) 的大作中提到: 】
: 额。。我没用到不等号啊。。。这个没报错 不过仿真没输出。。。
【 在 abensong 的大作中提到: 】
: 额。。我没用到不等号啊。。。这个没报错 不过仿真没输出。。。
: 【 在 lanphon 的大作中提到: 】
: : 友情提醒lz一声,VHDL中,不等号是“/=”。。。
:
if f_tmp = "0000" then
else
f_tmp<=f_tmp-1;
end if;
这种蛋疼的写法,难道不能用这个么?
if f_tmp /= "0000" then
f_tmp <= f_tmp - 1;
end if;
这种风格,给谁谁都不愿意看啊
同步电路比较好,就是都在时钟上升沿的时候触发。你把你的if语句,case语句,重置等等都放到
if (clk'event and clk='1') then
if cnt = div then --produce clk_m
cnt<=1;
clk_tmp<= not clk_tmp;
else
cnt<=cnt+1;
end if;
end if;
会比较好些,电路会比较稳定。出错比较少。