|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:
3 r* T4 y3 `2 B$ T _8 U( @4 k计数器(控制展宽电路的宽度)部分:
2 Z: s+ T: B6 q& ~4 ]$ b( Wlibrary IEEE;
8 Y) [ S$ x7 X. q- Euse IEEE.STD_LOGIC_1164.ALL;1 e( \/ F) @, _. w
use IEEE.STD_LOGIC_ARITH.ALL;; ~5 V" \: M/ O& C
use IEEE.STD_LOGIC_UNSIGNED.ALL;+ G. l, F$ {0 Z' W
entity counter is( D: f# n, ^/ Y# [1 ?
port(reset,en,clk: in std_logic;
1 k2 S1 e( O. C2 c5 S N1,N2,N3,N4: in std_logic;7 M( N& M+ y; P8 ~% g* j" D2 S
feed_out: out std_logic);3 x$ I% \+ R- F* r# o* d( _
end counter;; R; R/ C: q7 U2 u5 c$ T, c
architecture Behavioral of counter is0 \* }; k3 B: @2 s
signal temp: integer range 0 to 15:=0;
& C b& M: \& C, t3 \) D! s( Osignal k:integer:=0;' l8 i# d6 d2 I$ i$ x9 v( ?
begin% c/ ~0 l0 P R1 P% Z
process(N1,N2,N3,N4,k,clk) is& [( q4 O, b2 W! w( e4 D
begin6 d: h9 g3 |( U& Q" M" w
if(N1='1') then temp<=temp+1;$ |( r, l: W9 S }1 n! i+ u
elsif(N2='1') then temp<=temp+2;
. t0 U% R2 q3 n* A, S' H elsif(N3='1') then temp<=temp+4;
& f2 E/ f) |( A. K elsif(N4='1') then temp<=temp+8;6 a0 h V' R" `. \4 b* k
else null;
8 ?3 @, H+ a7 Y4 B end if;
2 J7 L" b- R% G1 L3 `4 p3 u if (clk'event and clk='1') then
$ k/ j0 c D% Y. `: I) {. S6 m: j# c if (reset='1') then- r+ ?7 ^& @" s& M- e0 B' q
k<=0; Q9 O, N4 c# h4 Q4 a
feed_out<='0';- \0 ^3 v4 I. L7 A* a% S
elsif (en='1') then " X) Q1 q9 n! Y
if (k=temp-1) then
/ ?2 [- k+ K. a H. [: I feed_out<='1';
1 a/ b: m9 m4 K# Y k<=temp-1;1 B; w3 l. `8 R6 k6 I: c, I5 N* X! o
else k<=k+1;
$ B$ W/ s* D3 k' t end if;! i. l+ X" ~: Q2 w
end if;+ Q- i# u; |, T
end if;( } \3 ^2 Z5 M8 k- u5 F9 m L4 x7 @
end process;; b6 H% i3 ?& } ~6 l
end Behavioral;
8 g$ m; |$ d$ Z/ `6 nD触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):7 J- _5 @ q/ \2 Y6 E. K" F
library IEEE;
$ m& }7 l* Y3 Wuse IEEE.STD_LOGIC_1164.ALL;2 q: r) T0 a' i1 d
use IEEE.STD_LOGIC_ARITH.ALL;
) F s& g: D! n& Puse IEEE.STD_LOGIC_UNSIGNED.ALL;
, k1 s# i; M4 N- n8 r* G$ centity D_trigger is7 K2 |, U$ m4 }
port(D,clear: in std_logic;
) S' `# ]& R- N: g6 o clk: in std_logic;
$ e) Z) q+ E! z( j+ V% v Q: out std_logic);8 E7 Y6 m, k3 T/ v8 h2 V2 x
end D_trigger;; H! k8 G" Y0 n
architecture Behavioral of D_trigger is
% g8 a7 g, u% zbegin
' R& r6 o" C' x% \5 _" }& qprocess(D,clear,clk) is
" C% i! L% Q8 ?- W$ L2 Ibegin" p9 T, H; ]4 B% d8 ^7 y
if (clear='1') then
) ]1 g0 r' Z. O# j Q<='0'; * W* r5 T" ^+ b7 b6 f
elsif (clk'event and clk='1') then/ C: t. U& G5 X8 c. {
Q<=D;
* H5 g# `$ |2 [ end if;
7 }0 b4 [7 j" Uend process; 1 N1 S1 \/ b. v- }3 F
end Behavioral;
9 a2 W4 t" V$ m6 n0 O+ U# N外部综合部分:6 R$ ~( U0 q5 e" Y6 g
library IEEE;' ^4 W6 s4 s8 p+ t
use IEEE.STD_LOGIC_1164.ALL;/ a+ B$ E1 Z& f
use IEEE.STD_LOGIC_ARITH.ALL;8 B& i; G: `1 f' p2 N
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5 J/ j# u- i, s. y5 \entity pulse_expand is
' y" O% a2 c7 H" q; M N7 X3 Z port(pulse_in,D_in: in std_logic;
! u8 i. l4 u9 R clk_in: in std_logic;
4 q7 {( Q' [4 ?% z" J5 k9 @9 Y n1,n2,n3,n4: in std_logic;
6 {2 V8 n( B$ x( U pulsewidth_out: out std_logic);8 G' W: A0 P$ w! R
end pulse_expand;
+ J R- i. N! |# }4 ?6 H' q' Parchitecture Behavioral of pulse_expand is/ M. k7 N# P6 Y2 H) K ^$ P7 d. ~
signal a1,a2,a3: std_logic;' a. P* K% v# R) n2 I& u" S
component counter is
4 @- W4 A1 l& @7 B( {+ c1 _1 r a: ^ port(reset,en,clk: in std_logic;
( z3 u% S8 M& Z o, p& k2 e N1,N2,N3,N4: in std_logic;
& S& k. ]& H! U+ W; U/ X4 q0 W feed_out: out std_logic);9 h9 A$ f0 v2 x8 B- A+ c7 ~
end component counter;, L, f1 o. t! M# o6 s
component D_trigger is
1 N4 _" V1 L8 o( E+ E, ~ port(D,clear: in std_logic;9 P* y* @$ [" J/ a4 N
clk: in std_logic;5 q) `# J+ `! {# g
Q: out std_logic);! @, W2 x8 L2 i# }; W- l# k, R
end component D_trigger;* }6 y. G* e7 s2 F, _- K' w, g" X
begin" g: T' U8 g1 k
P1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);; W6 r. K$ A/ @1 q2 Z
a3<= not a2;" `+ f9 D# j" w4 w
P2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,6 z) d3 r2 `6 w( R. _
N1=>n1,N2=>n2,N3=>n3,N4=>n4);2 P6 }6 m, z9 t- A6 s
pulsewidth_out<=a2;9 ~0 z+ V4 T2 h9 c' H1 }
end Behavioral;# I7 W f! u5 C. p* H- _- {
+ N+ N6 b! x- V& \5 S
[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ] |
|