集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: inter

VHDL状态机的时钟产生问题

[复制链接]
VVC 发表于 2010-6-26 10:54:15 | 显示全部楼层
可以采用并行输出寄存器的译码输出,缩短输出到管脚的延时,见下贴<br>
<br>
[ 本帖最后由 rose8866 于 2007-6-25 20:40 编辑 ]
CTT 发表于 2010-6-26 12:23:06 | 显示全部楼层
library ieee ; <br>
use ieee.std_logic_1164.all ;<br>
entity cycles is <br>
port (<br>
&nbsp; &nbsp;&nbsp; &nbsp;clock_main , rst: in std_logic ;<br>
&nbsp; &nbsp;&nbsp; &nbsp;c0, c1, c2, c3 : out std_logic) ;<br>
end cycles ;<br>
architecture rtl of cycles is<br>
type state_values is (st0 , st1 , st2 ,&nbsp;&nbsp;st3) ;<br>
signal pres_state , next_state : state_values ;<br>
signal tmpc0,tmpc1,tmpc2,tmpc3 : std_logic;<br>
begin<br>
process(pres_state)<br>
begin<br>
case pres_state is<br>
&nbsp;&nbsp;when st0 =&gt;<br>
&nbsp; &nbsp;next_state &lt;= st1 ;<br>
&nbsp;&nbsp;when st1 =&gt;<br>
&nbsp; &nbsp; next_state &lt;= st2 ;<br>
&nbsp;&nbsp;when st2 =&gt;<br>
&nbsp; &nbsp;next_state &lt;= st3 ;<br>
&nbsp;&nbsp;when st3 =&gt;<br>
&nbsp; &nbsp;next_state &lt;= st0 ;<br>
&nbsp;&nbsp;when others =&gt;<br>
&nbsp; &nbsp;next_state &lt;= st0 ;<br>
end case ;<br>
end process;<br>
with next_state select&nbsp; &nbsp;&nbsp;&nbsp;--根据次态预先将c0,c0,c1,c2数据放到输出寄存器<br>
&nbsp; &nbsp; tmpc0 &lt;= '1' when st0,<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; '0' when others;<br>
with next_state select<br>
&nbsp; &nbsp; tmpc1 &lt;= '1' when st1,<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; '0' when others;<br>
with next_state select<br>
&nbsp; &nbsp; tmpc2 &lt;= '1' when st2,<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; '0' when others;<br>
with next_state select<br>
&nbsp; &nbsp; tmpc3 &lt;= '1' when st3,<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; '0' when others;<br>
process (clock_main , rst)&nbsp; &nbsp;<br>
begin<br>
if (rst = '1') then&nbsp; &nbsp; --异步复位<br>
&nbsp; &nbsp;&nbsp;&nbsp;pres_state &lt;= st0 ;<br>
&nbsp; &nbsp;&nbsp; &nbsp;c0&lt;='0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;c1&lt;='0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;c2&lt;='0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;c3&lt;='0';<br>
elsif (clock_main'event and clock_main= '1') then<br>
&nbsp; &nbsp;&nbsp; &nbsp;pres_state &lt;= next_state ;<br>
&nbsp; &nbsp;&nbsp; &nbsp;c0&lt;=tmpc0;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;----将存储在输出寄存器的数据输出<br>
&nbsp; &nbsp;&nbsp; &nbsp;c1&lt;=tmpc1;<br>
&nbsp; &nbsp;&nbsp; &nbsp;c2&lt;=tmpc2;<br>
&nbsp; &nbsp;&nbsp; &nbsp;c3&lt;=tmpc3;<br>
end if ;<br>
end process ;<br>
end rtl ;<br>
<br>
觉得这个方法管用或者你能从中学到点什么的话,请给我评分
       

       
longt 发表于 2010-6-26 14:04:37 | 显示全部楼层
事实上对于楼主的第一个程序采用one-hot编码的话,那就是最优的程序,延时也最小(每一个编码的其中一位正好是一个输出)。之所以会有半个周期的延时,是和器件的性能有关的。<br>
<br>
我给的方法在输出逻辑比较复杂时有用。
ANG 发表于 2010-6-26 15:25:46 | 显示全部楼层
Sunlife 发表于 2015-6-25 09:59:00 | 显示全部楼层

建议状态机用时钟沿触发~!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 18:15 , Processed in 0.059934 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表