| library ieee ; <br> use ieee.std_logic_1164.all ;<br>
 entity cycles is <br>
 port (<br>
       clock_main , rst: in std_logic ;<br>
       c0, c1, c2, c3 : out std_logic) ;<br>
 end cycles ;<br>
 architecture rtl of cycles is<br>
 type state_values is (st0 , st1 , st2 ,  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>
   when st0 =><br>
    next_state <= st1 ;<br>
   when st1 =><br>
     next_state <= st2 ;<br>
   when st2 =><br>
    next_state <= st3 ;<br>
   when st3 =><br>
    next_state <= st0 ;<br>
   when others =><br>
    next_state <= st0 ;<br>
 end case ;<br>
 end process;<br>
 with next_state select     --根据次态预先将c0,c0,c1,c2数据放到输出寄存器<br>
     tmpc0 <= '1' when st0,<br>
              '0' when others;<br>
 with next_state select<br>
     tmpc1 <= '1' when st1,<br>
              '0' when others;<br>
 with next_state select<br>
     tmpc2 <= '1' when st2,<br>
              '0' when others;<br>
 with next_state select<br>
     tmpc3 <= '1' when st3,<br>
              '0' when others;<br>
 process (clock_main , rst)   <br>
 begin<br>
 if (rst = '1') then    --异步复位<br>
      pres_state <= st0 ;<br>
       c0<='0';<br>
       c1<='0';<br>
       c2<='0';<br>
       c3<='0';<br>
 elsif (clock_main'event and clock_main= '1') then<br>
       pres_state <= next_state ;<br>
       c0<=tmpc0;        ----将存储在输出寄存器的数据输出<br>
       c1<=tmpc1;<br>
       c2<=tmpc2;<br>
       c3<=tmpc3;<br>
 end if ;<br>
 end process ;<br>
 end rtl ;<br>
 <br>
 觉得这个方法管用或者你能从中学到点什么的话,请给我评分
 
  
 
  |