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

请教牛人看个多频信号发生器的VHDL代码哪里有问题

hlh
2008/11/4镜像同步14 回复
请教牛人看个多频信号发生器的代码哪里有问题? 设计多频信号发生器电路。电路的输入时钟频率为1MHz,要求能够生产下表所示的四种输出信号。画出状态转移图,标明各个状态的转移条件和输出。用VHDL完成设计。 Select[1..0] 输出信号 10 250KHz,1:3的方波 11 20KHz,1:1的方波 01 1KHz,1:49的方波 00 1Hz,持续一个时钟周期的高电平周期脉冲 ———————————————————————— 上面的是题目。 下面的是我写的代码。搞出来貌似类似倍频器了……不知道怎么改。 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity multi_frequency is port(clk:in std_logic; sel:in std_logic_vector(1 downto 0); dout:out std_logic); end multi_frequency; architecture behav of multi_frequency is type state_type is(f250khz,f20khz,f1khz,f1hz); signal current_state,next_state:state_type:=f250khz; begin --为系统中同步元件(触发器)建模的进程 synch:process begin wait until (clk'event and clk='1'); current_state<=next_state; end process synch; --为输出逻辑建模的进程 combin:process(sel,current_state) variable count:integer range 0 to 2000000; begin case current_state is when f250khz=> if sel="10" then count:=count+1; if count>5 then count:=0; dout<='1'; elsif count>1 and count<4 then dout<='0'; else dout<='1'; end if; next_state<=f250khz; else next_state<=f20khz; end if; when f20khz=> if sel="11" then count:=count+1; if count>26 then count:=0; dout<='0'; elsif count>13 and count<25 then dout<='0'; else dout<='1'; end if; next_state<=f20khz; else next_state<=f1khz; end if; when f1khz=> if sel="01" then count:=count+1; if count>1001 then count:=0; dout<='1'; elsif count>21 and count<1000 then dout<='0'; else dout<='1'; end if; next_state<=f1khz; else next_state<=f1hz; end if; when f1hz=> if sel="00" then count:=count+1; if count>1000001 then count:=0; dout<='1'; elsif count>1 and count<1000000 then dout<='0'; else dout<='1'; end if; next_state<=f1hz; else next_state<=f250khz; end if; end case; end process combin; end behav;
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
fzylijun886机器人#1 · 2008/11/4
时刻不忘母校啊
hlh机器人#2 · 2008/11/4
身为编程大牛不解答还调侃我…… 【 在 fzylijun886 的大作中提到: 】 : 时刻不忘母校啊
teamo机器人#3 · 2008/11/4
昂?呵呵 【 在 hlh (干云豪客) 的大作中提到: 】 : 身为编程大牛不解答还调侃我……
force机器人#4 · 2008/11/4
怎么感觉不是1:1 1:3 1:49
hlh机器人#5 · 2008/11/4
是啊…… 【 在 force 的大作中提到: 】 : 怎么感觉不是1:1 1:3 1:49
force机器人#6 · 2008/11/4
跑仿真了么
hlh机器人#7 · 2008/11/4
跑了……花了好久出来的波形不对……不像分频倒像倍频了……应该是状态机和时钟的问题 【 在 force 的大作中提到: 】 : 跑仿真了么
force机器人#8 · 2008/11/4
不会倍频吧 仿真没仿好吧
hlh机器人#9 · 2008/11/4
偶是菜鸟……不太懂~呵呵 【 在 force 的大作中提到: 】 : 不会倍频吧 仿真没仿好吧