|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
library ieee;0 i9 u8 w: B$ ^5 w8 t) u H
use ieee.std_logic_1164.all;
$ ?. j& h, ^. v4 `1 @use ieee.std_logic_arith.all;
/ l* ^ z# x- h1 ^4 uuse ieee.std_logic_unsigned.all;! F+ w+ N& w7 h1 M
entity time4 is
& u( D$ R5 V; `0 Y- l& m port(ab : in std_logic_vector(1 downto 0);0 {0 `" c( Y# p& j, b2 h
clk : in std_logic;
' B. l% c* r; k/ g pp,np : out std_logic);
3 z7 E, F: X) P( xend time4;
0 _% u& @+ R( K: t! Karchitecture one of time4 is* d1 l# x6 d8 A; j: R5 y4 I
signal state : std_logic_vector(1 downto 0);
/ u( Q' B# T! l: m: ]signal ab_1 : std_logic_vector(1 downto 0);
: `% e7 L# m# H/ p/ hsignal spp,snp : std_logic;1 K0 u. Q( A( e/ w( F* I$ F
begin
% N( z8 ?2 H. [ process(clk,ab)- c9 `2 Z- ~0 [2 H
begin; p5 H6 C, \6 T/ p! e; J
if(clk'event and clk='0') then ab_1<=ab;+ s/ R+ ]4 C) Z' Y1 s6 v" w8 V
end if;" q9 x. B6 a N X
end process;: x9 o j: O6 v! A
process(clk,state,snp,spp)
5 N" S0 ~0 N1 y begin
8 R! @& [3 @: m5 q4 Z7 E if(clk'event and clk='1') then
$ C6 }: ^' Z2 [* Z2 x if(ab_1="00") then
% B+ c( | A3 h( D3 ^4 s4 y9 R case state is1 D& d0 Q3 l0 G s
when "10"=>state<="00";spp<=’1’;
* {+ k/ b5 `, }- \! u3 J7 u9 l when "01"=>state<="00";snp<=’1’;3 Z: J/ s1 _7 O9 E4 J
when others=>state<="00";spp<='0’;snp<=’0’;
+ p! ~: g- J% d/ Q; i/ y end case;5 [2 t1 j8 Q+ I
elsif(ab_1="01") then
8 e/ f8 { e- u! L case state is
6 t; y0 T9 T& o when "00"=>state<="01";spp<='1';# R1 S' g: w# ^2 A* g" Y5 H
when "11"=>state<="01";snp<='1';
; Z$ C( Z" `- h& W& D0 x2 _ when others=>state<="01";snp<='0';spp<='0';* [' P! c% I) F' R" X( \
end case;, f% n8 z, X5 L( y4 f( ?. X
elsif(ab_1="11") then* v' G$ m7 [4 v
case state is% |& c8 E6 G1 b$ u' }: S4 w+ @4 ?- b
when "01"=>state<="11";spp='1';! w: G2 x/ W9 T" E% }& {* ^: K
when "10"=>state<="11";snp='1';( k! I. Y0 }/ f F; G4 H* m" {
when others =>state<="11";--spp='0';snp='0';; q, R: b$ g, f o
end case;
% c" f) ]; ^+ y8 w( c1 { else
* n: m' h; Q& Z8 j+ B case state is; B2 S! I, U& q, j. k5 m6 q3 y
when "11"=>state<="10";spp='1';0 }: K& L: S$ w
when "00"=>state<="10";snp='1';- B- l2 q- f+ r& y7 z7 R
when others =>state<="10";snp='0';spp='0';# `0 R$ I; e h/ a4 H
end case;* W: ?. y6 F" I$ z0 f6 l( C/ l7 d
end if;
$ W Z0 q6 H6 L% U: e" v' A: Q end if;$ h! X- f7 j9 o, Z
end process;
- p; Z# a- A0 t pp<=spp;
( T3 r5 b- M* l np<=snp;
5 x. Y5 s- C' Y5 ?8 _9 q! m* \end one; 2 A# e: s8 w: z8 ^
程序在QII中老是错误,请大虾们帮帮小弟! |
|