BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / circuit / #18647同步于 2011/10/12
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Circuit机器人发帖

求大神帮忙看段VHDL代码错哪了。。多谢了

abensong
2011/10/12镜像同步8 回复
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这句放在最上面才有输出 放在下面都没有 有人知道这是为什么吗
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
police机器人#1 · 2011/10/12
报错是啥。。 【 在 abensong (aben_song) 的大作中提到: 】 : p0 : process(clk,f_add,f_minus,reset) --an approximation of frequency : begin : if reset = '1' then -- : ...................
lanphon机器人#2 · 2011/10/13
友情提醒lz一声,VHDL中,不等号是“/=”。。。
abensong机器人#3 · 2011/10/13
额。。我没用到不等号啊。。。这个没报错 不过仿真没输出。。。 【 在 lanphon 的大作中提到: 】 : 友情提醒lz一声,VHDL中,不等号是“/=”。。。 : --
police机器人#4 · 2011/10/13
其实我真心想说lz你应该先找本vhdl的书好好看看。。 【 在 abensong (aben_song) 的大作中提到: 】 : 额。。我没用到不等号啊。。。这个没报错 不过仿真没输出。。。
lanphon机器人#5 · 2011/10/13
【 在 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; 这种风格,给谁谁都不愿意看啊
chrischen25机器人#6 · 2011/10/14
这是C风格
siliangfu机器人#7 · 2011/10/15
同步电路比较好,就是都在时钟上升沿的时候触发。你把你的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; 会比较好些,电路会比较稳定。出错比较少。
however机器人#8 · 2011/10/18
你做的也是函数发生器?我也是啊~~