|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:
7 s. S. I; v# n, [8 @计数器(控制展宽电路的宽度)部分:
; N% e, \, h- y8 E, dlibrary IEEE;8 p1 W9 g N" _/ j( l7 F: D! j7 J& Y
use IEEE.STD_LOGIC_1164.ALL;
; j9 h1 i! Z5 _$ _' Ouse IEEE.STD_LOGIC_ARITH.ALL;
1 ?9 ~+ \6 I9 @+ O3 e1 buse IEEE.STD_LOGIC_UNSIGNED.ALL;7 ~% I4 `& S- m* s# h, z8 R
entity counter is
; d/ T K1 R/ |) J port(reset,en,clk: in std_logic;
. E( s0 ]+ h9 k# V5 y1 [8 @7 g N1,N2,N3,N4: in std_logic;2 a' q& u8 ^+ w
feed_out: out std_logic);
1 n0 T, Y3 ?9 s0 |0 h$ s4 o- ` end counter;- |1 {7 F+ Z, u, o, U9 C, Z! ?) ~" f
architecture Behavioral of counter is2 z% r. ?7 d7 o0 ]
signal temp: integer range 0 to 15:=0;# D9 d( O2 K) T* q: r7 w
signal k:integer:=0;' R' W! o5 }( Q: _
begin8 m0 R l* f6 Z4 T0 A* L( I
process(N1,N2,N3,N4,k,clk) is7 R6 T5 |& p3 x5 Q2 `5 W& W: R
begin
4 K8 Y3 R8 s J: f2 N- {) q if(N1='1') then temp<=temp+1;
. q- Z) O3 N4 o0 ? elsif(N2='1') then temp<=temp+2;
m8 w8 ?% p9 l# l0 a! x elsif(N3='1') then temp<=temp+4;
' B8 i3 E1 n6 A elsif(N4='1') then temp<=temp+8;
. I |& a5 Z; V. j+ P# D, W else null;; \- S% j5 u# @7 N \5 u+ M6 [3 \0 L
end if;9 p+ p) i$ f7 z4 B8 I; D
if (clk'event and clk='1') then
# A1 {/ @4 O, Y if (reset='1') then
2 _5 H; b9 f4 c4 l k<=0;
9 q K9 {" G$ N7 W! `& `1 t; F feed_out<='0';
, n5 r2 O: D8 o }2 ]9 N5 d elsif (en='1') then ! Z1 m/ c9 d' T2 L6 Q
if (k=temp-1) then+ J) `/ X+ i* |. [+ N9 D3 v
feed_out<='1';" l" R1 R; \2 e% d: y
k<=temp-1;# n4 T( G: e. t! ?6 A* X' U- }5 p
else k<=k+1;
, k0 x7 Z( c" c1 P end if;# f I# @1 |% g5 g! R' i; k
end if;& Q1 @2 P* i; B; ^* t- ^9 {
end if;
1 [1 I( _5 ^- x( e( C1 l: ]end process;
1 _5 ^. r4 ^8 h" X$ Send Behavioral;1 }+ p5 ~3 E8 k
D触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):
8 h+ E- D1 W1 P' H3 ylibrary IEEE;" f2 R8 g9 S) z7 S0 }/ x
use IEEE.STD_LOGIC_1164.ALL;
# ]! `# D, A$ {, d: xuse IEEE.STD_LOGIC_ARITH.ALL;& f$ G; g& r' C# u
use IEEE.STD_LOGIC_UNSIGNED.ALL;# Q! [' W9 p4 o5 r$ \
entity D_trigger is
6 X' s: V0 f1 j0 J s; N' B2 X port(D,clear: in std_logic;
5 E) J7 z3 J; p7 h! \ clk: in std_logic;& ]$ }, T d; W+ u
Q: out std_logic);' i, P/ ?4 `, L* V$ d. q
end D_trigger;% R8 c, }2 e6 v% a( h# ~
architecture Behavioral of D_trigger is
7 L" [" u4 _6 Z4 `) ~& D4 Y% \begin' z# N( O, U3 a2 `
process(D,clear,clk) is
; P- U3 U. C& B5 Qbegin
: I- T3 V' z0 G" Q+ x+ y0 ^$ m if (clear='1') then7 q# K4 ]) g8 R% J$ ~
Q<='0';
0 I+ e; `6 H/ @( [ elsif (clk'event and clk='1') then
3 G2 @) ~+ z5 _ [ Q<=D;
6 [' _; f9 O" x end if;3 g+ u& W: D# [6 c w* Z
end process;
0 ~' R) b+ q$ F( U Cend Behavioral;
1 ]4 C- v8 T0 e H- F& ?1 l# b8 C" `外部综合部分:) R" e2 J+ D' Y! J# |: n/ Z
library IEEE;
. i2 u4 U2 ]0 T2 Euse IEEE.STD_LOGIC_1164.ALL;
! O" }$ ?9 A" K; c% P( Uuse IEEE.STD_LOGIC_ARITH.ALL;
( P& K) x2 G2 G: K1 p" t/ ?* ouse IEEE.STD_LOGIC_UNSIGNED.ALL;: f1 z% P/ s* c1 r
entity pulse_expand is1 E& E% I6 ^6 @0 f( K/ |
port(pulse_in,D_in: in std_logic;
& x, Y: e2 [; U- r9 P/ v clk_in: in std_logic;
- ^, @2 M* q; w* h3 N0 h7 }6 t n1,n2,n3,n4: in std_logic;
2 Z* m/ r/ b& C pulsewidth_out: out std_logic);- c3 u, p- i5 W8 O; k
end pulse_expand;
& |% p4 b% d. U2 h& tarchitecture Behavioral of pulse_expand is
6 B% @- w! M3 ]- `) b) N2 V7 S/ dsignal a1,a2,a3: std_logic;
/ u; _2 q5 K% |3 w* ?: T8 ^& c, icomponent counter is
) s7 ^ q* K) l3 X" o0 G! ` port(reset,en,clk: in std_logic; G: @3 J1 R7 T7 n
N1,N2,N3,N4: in std_logic;, W" H: s }3 O0 @1 \
feed_out: out std_logic); h% d- H5 N. V
end component counter;
& Y% A4 M& x5 z% o$ C3 t3 @3 N+ u component D_trigger is$ N- R+ _5 }; B8 `
port(D,clear: in std_logic;
% q/ F- N6 |6 j, Z [: x4 F clk: in std_logic;
" W/ T+ |7 m' s Q: out std_logic);0 l( e& t0 D& [: g% `, e! z
end component D_trigger;# r5 P) S8 E& p, I% g# m: X7 j
begin
8 k( q. V+ j* F& v2 d1 ~& q% OP1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);
5 |! ~& r- N9 B( M0 da3<= not a2;
+ j0 C6 x8 Y- \$ |5 t1 }/ a8 DP2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,
) f: X, n1 W# Z% B% C" I! ]! e$ A N1=>n1,N2=>n2,N3=>n3,N4=>n4);
/ v, k$ K" A! E5 n$ F' Tpulsewidth_out<=a2;0 R" K) q( k; ?
end Behavioral;& b8 S# O: B- O+ `2 }
* t" U$ k9 e- s3 G
[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ] |
|