EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
library ieee;
0 O+ o c& T% I8 B2 `( Suse ieee.std_logic_1164.all;. S9 m' q7 c7 m' t8 @0 }
use ieee.std_logic_arith.all;: t1 d; _8 q" e& v0 q0 l& {
use ieee.std_logic_unsigned.all;" j1 O3 O' s8 n; p* @
entity time4 is
6 n( u8 V& u2 `: p. B9 M$ _& |/ F port(ab : in std_logic_vector(1 downto 0);
8 v: h4 s. h; B9 v& q2 x' o& V clk : in std_logic;
' O( i. w! o! E) _% K pp,np : out std_logic);. ]% Q" W$ i/ f6 ]0 Q& E4 V
end time4;# z8 Q/ E0 H) Y1 o, W
architecture one of time4 is
" [( O6 f5 a: E+ ~5 j7 |1 ?signal state : std_logic_vector(1 downto 0);. d0 g" ?# [7 b1 X
signal ab_1 : std_logic_vector(1 downto 0);4 }! z! S* U3 b: E+ u6 k
signal spp,snp : std_logic;. e6 f3 U3 o: X8 r6 D; r" I* a% A
begin/ [5 ^0 W3 P; U3 }! K% l
process(clk,ab)' m6 |8 i- `. B7 Y; j; |
begin
5 `$ h+ F0 w* Y: F if(clk'event and clk='0') then ab_1<=ab;% ]- P7 w* t" d5 D$ ^1 ?7 |
end if;' i- N h v- Y8 l) n
end process;
5 x' Z# ~+ T5 X0 E4 k2 y8 C$ U process(clk,state,snp,spp)& \* v+ D6 }, U L8 l' f7 `. ?
begin7 e0 A3 n& q! L; d
if(clk'event and clk='1') then
8 y6 I9 w5 Y2 \. {7 \9 g9 } if(ab_1="00") then
7 X8 |5 J& ?" S) c; G case state is7 h H1 C% s- j) q! D! D& e
when "10"=>state<="00";spp<=’1’;
) h0 a& @' J' q! d: Z- s when "01"=>state<="00";snp<=’1’;0 x z0 T& x" a9 j& `% r7 N
when others=>state<="00";spp<='0’;snp<=’0’;; @! O+ \) ~# c, k5 Q0 @# K1 j
end case;
* m6 ~4 X0 J# k elsif(ab_1="01") then
) q3 k5 Y4 u" f0 S4 E case state is
: `, A. C0 h! ? when "00"=>state<="01";spp<='1';+ D# P* F% a$ G. W, j1 {+ l+ G7 U' V
when "11"=>state<="01";snp<='1';# Z2 Z8 ]0 {+ w+ f* a0 v. W
when others=>state<="01";snp<='0';spp<='0';, C/ a; o7 x5 v+ h
end case;
, H2 W$ Y; _* A/ `1 ] elsif(ab_1="11") then) o0 K1 W8 k. w/ Y7 A
case state is: R3 I' V- w* x% z* Q
when "01"=>state<="11";spp='1';$ ^9 i9 B5 Q# s
when "10"=>state<="11";snp='1';# @% b3 }3 _4 s: J
when others =>state<="11";--spp='0';snp='0';% R! x& Z& Q# G, F- D7 g4 q3 Q- ]1 a
end case;# p3 ]0 l6 `4 a1 `, ]
else
4 v. e; ]9 i3 l- h& } case state is
8 h4 t2 ]) p- }; @9 g1 W9 Q when "11"=>state<="10";spp='1';
; x9 g; C p$ N0 C8 d when "00"=>state<="10";snp='1';
1 R E/ Q5 b# m- d* A6 [ when others =>state<="10";snp='0';spp='0';
" \* Q& }: w+ Y8 z5 e7 S end case;
( E2 [5 X6 {# [' O- q8 ^% l% L end if;% u# d2 M" q- U" Z# X
end if;. {5 M0 e( _+ O
end process;0 O6 h: } u8 H$ Q$ S
pp<=spp;
$ A2 a* ?2 `) W1 n np<=snp;1 i5 b: I! G1 j i2 Z
end one; 7 E- Q' H' z2 {% {
程序在QII中老是错误,请大虾们帮帮小弟! |