|
----------------------------------------------------<br>
----------------------------------------------------<br>
-- <br>
-- Library Name : encoder<br>
-- Unit Name : state_control<br>
-- Unit Type : State Machine<br>
-- <br>
------------------------------------------------------<br>
<br>
library ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.STD_LOGIC_UNSIGNED.all;<br>
library synplify;<br>
use synplify.attributes.all;<br>
<br>
<br>
entity state_control is<br>
port (<br>
reset : in std_logic;<br>
d : in std_logic_vector(7 downto 0 );<br>
clk : in std_logic;<br>
eoc : in std_logic;<br>
oe : out std_logic;<br>
adda : out std_logic;<br>
ale : out std_logic;<br>
start : out std_logic;<br>
q : out std_logic_vector(7 downto 0 );<br>
QQ : out std_logic_vector(3 downto 0 )<br>
);<br>
<br>
end state_control;<br>
<br>
<br>
architecture state_control of state_control is<br>
<br>
signal lock : std_logic;<br>
<br>
type visual_S0_states is (S0, S1, S2, S3, S4, S5, S6, S7);<br>
signal visual_S0_current : visual_S0_states;<br>
<br>
<br>
begin<br>
adda<='1';(出错是这个赋值产生的!!!)<br>
<br>
<br>
<br>
-- Synchronous process<br>
state_control_S0:<br>
process (clk, reset)<br>
begin<br>
<br>
if (reset = '1') then<br>
visual_S0_current <= S0;<br>
elsif (clk'event and clk = '1') then<br>
<br>
case visual_S0_current is<br>
when S0 =><br>
visual_S0_current <= S1;<br>
<br>
when S1 =><br>
visual_S0_current <= S2;<br>
<br>
when S2 =><br>
visual_S0_current <= S3;<br>
<br>
when S3 =><br>
if (eoc = '0') then<br>
adda<='0';<br>
visual_S0_current <= S4;<br>
else<br>
visual_S0_current <= S3;<br>
end if;<br>
<br>
when S4 =><br>
if (eoc = '1') then<br>
visual_S0_current <= S5;<br>
else<br>
visual_S0_current <= S4;<br>
end if;<br>
<br>
when S5 =><br>
visual_S0_current <= S6;<br>
<br>
when S6 =><br>
visual_S0_current <= S7;<br>
<br>
when S7 =><br>
visual_S0_current <= S0;<br>
<br>
when others =><br>
<br>
visual_S0_current <= S0;<br>
end case;<br>
end if;<br>
end process;<br>
<br>
-- Combinational process<br>
state_control_S0_comb:<br>
process (d, visual_S0_current)<br>
begin -- Combinational process<br>
<br>
case visual_S0_current is<br>
when S0 =><br>
qq<="0000";<br>
ale<='0';<br>
start<='0';<br>
oe<='0';<br>
lock<='0';<br>
<br>
when S1 =><br>
qq<="0001";<br>
ale<='1';<br>
start<='0';<br>
oe<='0';<br>
lock<='0';<br>
<br>
when S2 =><br>
qq<="0010";<br>
ale<='1';<br>
start<='1';<br>
oe<='0';<br>
lock<='0';<br>
<br>
when S3 =><br>
qq<="0011";<br>
ale<='1';<br>
start<='1';<br>
oe<='0';<br>
lock<='0';<br>
<br>
when S4 =><br>
qq<="0100";<br>
ale<='0';<br>
start<='0';<br>
oe<='0';<br>
lock<='0';<br>
<br>
when S5 =><br>
qq<="0101";<br>
ale<='0';<br>
start<='1';<br>
oe<='1';<br>
lock<='0';<br>
<br>
when S6 =><br>
qq<="0110";<br>
ale<='0';<br>
start<='0';<br>
oe<='1';<br>
lock<='1';<br>
q<=d;<br>
<br>
when S7 =><br>
qq<="0111";<br>
ale<='0';<br>
start<='0';<br>
oe<='1';<br>
lock<='1';<br>
<br>
when others =><br>
null;<br>
end case;<br>
end process;<br>
<br>
<br>
end state_control;<br> |
|