|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:3 a' l! E. z. l5 g, l1 O/ q
计数器(控制展宽电路的宽度)部分:$ s& ?6 D* ?4 f
library IEEE;/ I( y, y. t4 x2 _# X& T( P0 j
use IEEE.STD_LOGIC_1164.ALL;. U9 q- p1 }# A
use IEEE.STD_LOGIC_ARITH.ALL;
4 u! D; h% O/ C* \ t% luse IEEE.STD_LOGIC_UNSIGNED.ALL;
- F$ R# F7 X6 F8 c1 e, |& `; V+ ^- sentity counter is
3 O- M( l3 z9 E+ M# g1 C( n port(reset,en,clk: in std_logic;5 W, z4 r! h9 V0 o& K
N1,N2,N3,N4: in std_logic;) O& {2 K- T5 _
feed_out: out std_logic);
# }5 D$ ^9 K5 P4 V end counter;
; u/ V d+ |" g9 ?' Barchitecture Behavioral of counter is
2 g3 Y* T; G) Qsignal temp: integer range 0 to 15:=0;
; U% s. D( U4 A: C8 n* E$ e2 esignal k:integer:=0;
# l. Q. g1 v) D6 h0 [/ t6 Y0 qbegin( Y x# _" I8 @1 h3 Q
process(N1,N2,N3,N4,k,clk) is
1 I! X8 N0 {9 u$ X+ ybegin
( V- Q! T! N* j: b' q if(N1='1') then temp<=temp+1;- {9 U) |* e/ a7 H+ a
elsif(N2='1') then temp<=temp+2;
* H+ Q) D& v) T1 Q$ H elsif(N3='1') then temp<=temp+4;
% H3 Q# e. g" Q6 O elsif(N4='1') then temp<=temp+8;
. L7 v" S6 i4 _/ a3 V" `9 ? else null;
1 |7 O% Y4 G# k8 x4 k3 G3 q7 O end if;4 g! ~: e# D5 F3 S$ k' g
if (clk'event and clk='1') then& i8 R' a3 e6 _. M
if (reset='1') then9 A4 C! h* t4 P% k u
k<=0;( \" {( ^6 P1 [ Q
feed_out<='0';
' \' b- C. P8 b J( A elsif (en='1') then
# W" \4 Y- X9 O: K if (k=temp-1) then
# T+ { h' Z% A% `/ Q feed_out<='1';! z( k- q; a; a2 w9 W
k<=temp-1;0 ?0 Y5 V9 o: X# D: r' n4 @
else k<=k+1;- E+ M# Y I8 y6 W/ a# K( w
end if;
8 c, ^! c0 Q+ y3 P) U3 N end if;
' S) o) F' a: X4 g4 ^7 P5 [% `end if;
: o) d5 h5 }0 i' f" Y% Uend process;
! y! q, E/ {9 Wend Behavioral;+ k4 U) h$ D% G! N/ I7 [6 x" U
D触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):' e9 K0 @$ ]" {8 Q" M8 P9 k
library IEEE;" j- ~4 E1 m0 J a/ m$ @
use IEEE.STD_LOGIC_1164.ALL;
' B! {9 A; N" c* F; Fuse IEEE.STD_LOGIC_ARITH.ALL;
! i7 |* K" N) Y' a0 `# Nuse IEEE.STD_LOGIC_UNSIGNED.ALL; o7 _" I* \3 }) m ?% r+ K
entity D_trigger is
& j# K* D3 m% k$ l9 m0 }0 ~. ^3 H port(D,clear: in std_logic;, I% c) t% ^# ^; p
clk: in std_logic;! w- z! R: W& \% c" Z6 p
Q: out std_logic);2 e T) Q! H" i
end D_trigger;
) O2 C8 w7 P& m) [& f+ j: harchitecture Behavioral of D_trigger is5 U, |: J$ ?$ C5 t9 }4 F# h3 M% N' ^
begin4 I5 V! \/ [, a" T9 A3 |3 Q) @ s, Z. }
process(D,clear,clk) is+ x2 _! U, [2 B* S1 `& n
begin
! y$ J% G1 N, K* K3 b if (clear='1') then
) _* Z9 v; O8 c# b# L O. |& B Q<='0';
. A( A p7 ]) R4 t! Y elsif (clk'event and clk='1') then
& _+ L2 A, Q0 A Q<=D;
8 U4 V7 I- e+ C end if;
$ I: q7 b/ {" i( k3 I& ~end process;
: M7 V2 M4 i% Q, S# l) |( ^% `end Behavioral;
3 Q1 w: G& t+ i* H& [9 j外部综合部分:6 A4 E0 Z8 H8 u% w3 o# G. k: I
library IEEE;
1 A p- ]2 R& W2 d) f0 Xuse IEEE.STD_LOGIC_1164.ALL;
3 f: R3 x( S: Q+ yuse IEEE.STD_LOGIC_ARITH.ALL;( A& G, ?) v$ W8 W4 S3 t
use IEEE.STD_LOGIC_UNSIGNED.ALL;# ]( J; y# z: ]
entity pulse_expand is" g9 V3 W) g% r
port(pulse_in,D_in: in std_logic;
/ }9 q# \ k% o6 C7 `, L clk_in: in std_logic;, K; |) D: ~6 Q* r" P; V5 t9 c
n1,n2,n3,n4: in std_logic;
& M" u( v1 W, W: p8 G I pulsewidth_out: out std_logic);
, R' |% D5 m1 m; Pend pulse_expand;. E, d" N9 P" n
architecture Behavioral of pulse_expand is
3 U F( l! E( Y" a4 [, T" l5 ?3 m* isignal a1,a2,a3: std_logic;# {7 d0 C! q* T# f) h* B
component counter is
& @$ z4 Z7 n. E% l ]- `) t port(reset,en,clk: in std_logic;/ {+ ~# B5 [: P. J1 t) I
N1,N2,N3,N4: in std_logic;. j$ A$ W7 J* s, l8 D
feed_out: out std_logic);( N, o* f) q1 O3 }5 Y y
end component counter;
7 U9 y# T* |9 g E, H component D_trigger is
+ r. w' @( m0 o; m; l port(D,clear: in std_logic;
6 \! E' |' o1 X. o5 W4 x; Z clk: in std_logic;
# J# e3 S, Z! P* {& Q, S' B$ @ Q: out std_logic);* `5 Q/ \( R! H2 t- G
end component D_trigger;
" ?7 K% D7 A2 r1 y4 Fbegin
) A: ^% f; o/ a- a. ZP1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);# }: n, r, _; z6 v! K+ U
a3<= not a2;
. P$ P- @: J8 UP2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,
* K9 _/ `' y5 o4 S N1=>n1,N2=>n2,N3=>n3,N4=>n4);
, K6 h, u- B0 W2 lpulsewidth_out<=a2;
. U# @3 e7 V& }) O9 I4 X9 A2 vend Behavioral;
, c" z6 u0 V, n$ x
4 e" \1 ? t6 e! `3 T+ A3 { J. K[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ] |
|