EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
library ieee;
2 S( g6 H2 I5 B6 h) \use ieee.std_logic_1164.all;/ I5 a! J" T2 B3 a7 |. S" Z
use ieee.std_logic_arith.all;
) Z( Z. V/ {5 [1 Kuse ieee.std_logic_unsigned.all;
+ e7 B0 q- k$ x; h/ sentity time4 is
+ x! P) A0 ~9 r7 ?: L3 W port(ab : in std_logic_vector(1 downto 0);
9 B5 V" L7 M9 O( ^9 Z clk : in std_logic;0 K- n( J; r2 i$ N$ i: g
pp,np : out std_logic);6 V- j G( E* e* t5 e
end time4;) X! h- ^0 j6 H; M
architecture one of time4 is
" V7 N A! q- X$ ssignal state : std_logic_vector(1 downto 0);/ l% {2 |/ a' M* c# j* r0 j
signal ab_1 : std_logic_vector(1 downto 0);1 }7 m; L1 ~$ @2 ^4 U6 b
signal spp,snp : std_logic;
" M5 l8 l n& N. O1 T# `begin2 D b( d7 P, v& v, h
process(clk,ab)
4 E2 {# P9 {+ d2 R5 F0 x begin
/ ]* r0 | M2 T8 H( L- }1 W if(clk'event and clk='0') then ab_1<=ab;
) w. v" G: n1 s A end if;
$ p; e4 z- n0 f1 p end process;% f; R! W. F f" ]
process(clk,state,snp,spp)
, s2 w) a* b# k$ e4 t K begin
) n$ G4 j7 A) ]# N7 W- H if(clk'event and clk='1') then
6 M' d, H. q" M Q1 j; u; l if(ab_1="00") then
4 o# `% x: L) {. Y6 S- @ case state is
1 W+ N1 c# l8 j6 D( o& X- e when "10"=>state<="00";spp<=’1’;
3 p- |4 \1 \ n* P; s4 J when "01"=>state<="00";snp<=’1’;3 w9 U2 n( P' V4 j
when others=>state<="00";spp<='0’;snp<=’0’;$ @% t# w* X, c% a
end case;
' n" k. d: U! g, }, i/ P: p6 K: d elsif(ab_1="01") then
' ?$ V( T$ Q" q0 B2 r. F case state is+ C: L& y) [! N. A3 y) G @5 S
when "00"=>state<="01";spp<='1';2 R, `* u/ ]9 F* n, S' L+ @/ M
when "11"=>state<="01";snp<='1';
$ H5 g9 r# W; E/ d+ [3 d when others=>state<="01";snp<='0';spp<='0';
1 |/ R, Q# H& V! g end case;9 M* t7 R( p) z: T8 I0 S, a
elsif(ab_1="11") then0 y) L' F N) a: r; q9 J
case state is3 \" E' [2 R1 R1 H7 m9 ~6 M
when "01"=>state<="11";spp='1';- j% i) W5 V- ?( b- n$ P
when "10"=>state<="11";snp='1';
+ {3 h% @) A& l4 L when others =>state<="11";--spp='0';snp='0';% F* f1 q1 b9 O
end case;
8 J& [$ M" t5 I( z1 I- l" E0 i' J else5 A1 v0 \) ^; A& S
case state is/ V1 k# i# H+ C/ w( b6 R+ [! x. ]
when "11"=>state<="10";spp='1';4 A& @: H8 L: ]. V" r4 ]
when "00"=>state<="10";snp='1';
" L# O# A; E- T0 e( a8 w4 e when others =>state<="10";snp='0';spp='0';! `) q7 C& |/ v. A+ s4 M) p
end case;
; y8 A, C6 h* B/ ] end if;# D/ K, {- \" T7 H L5 E1 D
end if;
$ T9 _4 X, ^7 B W* E- p$ `0 }% tend process;9 |. M2 t5 X+ Y: H! t
pp<=spp;
) x/ i( @4 n0 E/ t+ M& [1 K np<=snp;# P0 [4 Z' T% i/ T2 \
end one;
: ]! X9 q% p T0 v程序在QII中老是错误,请大虾们帮帮小弟! |