|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
library ieee;. h! F# z# b! m E2 K
use ieee.std_logic_1164.all;
' y/ }& R7 L% _1 p w% Ouse ieee.std_logic_arith.all;
/ X, s/ d3 m/ E. c- U# Y" ?8 Vuse ieee.std_logic_unsigned.all;
2 }0 {& W5 f! _: t1 a) Q: [5 aentity time4 is
- \- H" i% X- ^9 m( H port(ab : in std_logic_vector(1 downto 0);1 f( f* S( f2 [6 ~* i! Q0 K1 w
clk : in std_logic;: U- _! y2 J- G C$ a6 M5 d# m" d
pp,np : out std_logic);" a6 u" `! ~$ T4 h
end time4;/ C; P, c. x& z+ ^7 P! ]( i8 Q
architecture one of time4 is
9 q& P4 j& l8 hsignal state : std_logic_vector(1 downto 0);
% B0 R- Y) e. n0 }% |; @3 _& Bsignal ab_1 : std_logic_vector(1 downto 0);
- Q- Y- W% t& r' I6 }4 Usignal spp,snp : std_logic;0 ^0 }. L2 O9 o8 {+ ]' x, C! U
begin, J* n5 f# R$ \0 u- [- l4 S" o
process(clk,ab). ~# E. d6 L; ]& L: y- L
begin
3 y- p- A# l3 } if(clk'event and clk='0') then ab_1<=ab;
. {! P5 L, H! [ D end if;; y! m$ R7 p& Q
end process;6 ]- `& z. k8 X' {% n
process(clk,state,snp,spp)
: ^. p1 j k& l' D* U& N7 @5 u# E/ G begin
6 D: o% Y( k' b8 W! F9 F7 u! c$ r: { if(clk'event and clk='1') then
) L) G; V v, s7 p, s, s' a if(ab_1="00") then- f. l! m; G/ l7 S- N) H
case state is
D3 ^' J2 j0 \; O: T! o when "10"=>state<="00";spp<=’1’;; {+ z3 Y I9 L
when "01"=>state<="00";snp<=’1’;
6 H+ x7 x! t- W% X; k5 U4 E4 V# o when others=>state<="00";spp<='0’;snp<=’0’;$ L5 a# ~) U% O. c' e' ~) w. C$ G2 [, G
end case;
6 s0 R* d4 g* j5 I2 F- x6 U elsif(ab_1="01") then
# T5 m" m- ~: p. M+ b) }3 A case state is, f2 X+ D0 K( L6 V' H
when "00"=>state<="01";spp<='1';
+ I Z, m! e) w8 z: k: |4 D J when "11"=>state<="01";snp<='1';
. K m) m+ {( G0 S6 J when others=>state<="01";snp<='0';spp<='0';4 e( K, R l+ w) Y1 J! u3 [
end case;3 H: y6 h6 J( H
elsif(ab_1="11") then
. M3 l4 Y% x6 U( }& B case state is9 g- h" ^$ W! A, }: b
when "01"=>state<="11";spp='1';
* Q2 M! r& i9 _2 A/ b when "10"=>state<="11";snp='1';
x: g5 p' d8 C3 L7 ?; Z5 _4 C when others =>state<="11";--spp='0';snp='0';
) x/ N' t7 r! v/ Z8 E end case;
) t7 Z7 W- i& z1 L: L else# [5 p0 z. E. f1 r5 F
case state is
( |6 C, P% |8 F0 {0 y when "11"=>state<="10";spp='1';
+ ?* v& X2 x) d when "00"=>state<="10";snp='1';
9 M5 {* f* y( P9 O. r3 f/ j when others =>state<="10";snp='0';spp='0';
8 p0 Q- t& r# x8 ~, |9 Y' d4 Q end case;
. M; M: n# T5 {7 M end if;1 D6 ~+ B8 {. s& ~
end if;; ? u/ C+ o/ ]* c0 P2 m5 J; C
end process;
5 g4 H( p# K3 W9 S# E7 k% \ pp<=spp;
. i. L9 z" Y/ j8 L0 a7 W np<=snp;7 k. S! ^- |& j- a9 f& S2 B
end one; , ?* T0 c. R" v4 w+ n. [
程序在QII中老是错误,请大虾们帮帮小弟! |
|