|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
library ieee;
( b' W P) m( S3 q& Kuse ieee.std_logic_1164.all;
1 j4 {# q8 y" n4 x: juse ieee.std_logic_arith.all;$ H; r/ P* i7 D7 t! q* f+ S$ x
use ieee.std_logic_unsigned.all;$ k J& c4 @9 c" ~, f' v5 D
entity time4 is/ ~* c/ d5 L) W9 h; E& g' S
port(ab : in std_logic_vector(1 downto 0);- M; X8 E% d* u8 R7 ]$ e5 ^
clk : in std_logic;
8 ]* l& q- C' i' i4 Q pp,np : out std_logic);: O2 k! r" r* y# v$ q3 n
end time4;; a# f3 F* E" _4 E) R. H; X' C( x
architecture one of time4 is
" X& r9 C3 F3 o' ]signal state : std_logic_vector(1 downto 0);: w1 |+ E. }1 v) {* ? R$ d! r
signal ab_1 : std_logic_vector(1 downto 0);3 X" R1 ~: c# i7 H, n. f" v
signal spp,snp : std_logic;7 i3 G+ S5 y' I5 P, L# _7 N8 S
begin
5 H% [9 m) E8 P process(clk,ab), c l( C a) B" m$ X' v( e
begin
9 L0 E7 v7 w: O. f7 p6 {0 s- o if(clk'event and clk='0') then ab_1<=ab;: y2 n6 b r! V# `
end if;# w4 c M! w H: \" G
end process;
7 J, K, J; X0 Y% s2 T7 G% y process(clk,state,snp,spp)
) T2 Z4 [* {% n. B begin
4 E% o7 ^; W8 b6 ]( N+ G! k if(clk'event and clk='1') then# B0 E. C4 H2 M) o4 P9 N: m% q
if(ab_1="00") then
; q0 J9 O0 ~0 V4 n; b case state is+ O d, b- h; X+ ]" m
when "10"=>state<="00";spp<=’1’;
) ~: F7 H1 W. t @' M; B when "01"=>state<="00";snp<=’1’;
, M* z7 Y7 t) N when others=>state<="00";spp<='0’;snp<=’0’;
2 Z9 Z$ M( b4 ~# w end case;
! p6 y) N5 \3 k* | elsif(ab_1="01") then
5 I" h( N* i- y3 P case state is
, T G' j+ k3 _7 _ when "00"=>state<="01";spp<='1';! }+ H7 R0 _2 S; q; S8 G
when "11"=>state<="01";snp<='1'; _" ~5 L- X. y
when others=>state<="01";snp<='0';spp<='0';
4 |0 ?" O) B& z( c" X end case;5 ~* m: n5 _* V8 a& t. t
elsif(ab_1="11") then
+ z4 P% n8 ]! [3 T case state is
5 Y0 q% ~' N2 j* ` when "01"=>state<="11";spp='1';$ G3 v2 m0 _1 S3 t! u
when "10"=>state<="11";snp='1';9 m' Y+ d- c4 L* ]. x* u
when others =>state<="11";--spp='0';snp='0'; X6 s, l% R) J1 z! Z, t
end case;
2 F b H3 Q" M7 H6 F else
% Z; H+ g p9 q$ M. Q1 {8 d case state is4 E7 g" ~/ i, I
when "11"=>state<="10";spp='1';3 T5 B4 }( I% w! f; ^" `" S
when "00"=>state<="10";snp='1';
3 Z- B) X9 j9 f when others =>state<="10";snp='0';spp='0';
% d! g7 K/ z) n0 H7 Q) k) v, A end case;
) V$ }8 `& e; f+ @ end if;; U7 D4 c! A$ X( P! P. E: [$ C
end if;7 [2 ?/ t5 g( K, |
end process;
3 t' t+ s) i* j8 g: F/ X: O pp<=spp;' v8 }6 f1 \- p- r( A8 Z" r5 p
np<=snp;: I9 O6 {: i$ T1 t2 Y- [
end one; + v+ w- p( h1 t4 G& X
程序在QII中老是错误,请大虾们帮帮小弟! |
|