|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:
/ G. ?" f5 T1 q5 i& k计数器(控制展宽电路的宽度)部分:
% _ t: Y }0 S# y) flibrary IEEE;$ o4 Y9 [- P- u8 m) u
use IEEE.STD_LOGIC_1164.ALL;
' J/ n" W3 O. ouse IEEE.STD_LOGIC_ARITH.ALL;! w9 W4 Q2 J- E) W+ N1 D7 H
use IEEE.STD_LOGIC_UNSIGNED.ALL;
& F" N2 I/ B6 k2 p2 tentity counter is
0 P# m: ^ Y' q. `1 K port(reset,en,clk: in std_logic;
2 T4 M- b# T" V, L }5 z. e1 ~ N1,N2,N3,N4: in std_logic;, T9 k+ m6 V8 ~8 d
feed_out: out std_logic);
$ |1 E- G7 `! z" T5 P end counter;/ Z }! X5 E: ] C# r7 [* {% P
architecture Behavioral of counter is, X; H) B, p' E, a
signal temp: integer range 0 to 15:=0;
7 k: `5 p i$ J. {signal k:integer:=0;: q, m3 w3 U8 }5 [9 P/ b4 f. X( D
begin5 ?5 n! l7 M( l5 k
process(N1,N2,N3,N4,k,clk) is
1 T/ X% R* C4 t+ ]begin
" J- Q/ ~, }) J/ h+ I if(N1='1') then temp<=temp+1;! K/ p! Y3 Y! c
elsif(N2='1') then temp<=temp+2;4 g+ O0 A K' \/ K" P8 v. x- ]
elsif(N3='1') then temp<=temp+4; \" ]: Q, v% {
elsif(N4='1') then temp<=temp+8; K# y/ [) d$ B- h7 o
else null;
3 I( S( `/ }, C/ \4 E7 u7 n end if;
3 t' H& f* k/ v6 l6 S7 F if (clk'event and clk='1') then
& e) X' W0 e2 r8 B4 f8 ?) A if (reset='1') then
$ }: J& Z6 l0 Z k<=0; s8 O" w( d2 l' \' p& K: D
feed_out<='0';
3 {7 Y( @# s W& t elsif (en='1') then
; g; P9 q( x( d" B/ `3 L if (k=temp-1) then5 f3 t9 L- R* @
feed_out<='1';
2 ]( J e5 `( V3 ]5 A. W k<=temp-1;1 e# h( V& ]; _4 f6 r) `) {, m% F4 y
else k<=k+1;( D: h# L; J0 S1 {" u3 m1 E' C
end if;& S4 d( S1 z, z
end if;
& p! K, J! s# U) g$ ~8 X C, cend if;
$ z7 \: k4 q% Kend process;7 d& E* j: ?1 T& _% `
end Behavioral;3 T% W. ?: Y8 _/ K5 F
D触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):! B' W/ k4 l9 \4 t0 h* p9 V7 U
library IEEE;% E" S, \; Y4 m6 i- P7 d5 F
use IEEE.STD_LOGIC_1164.ALL;5 R9 u9 S8 W' C! v* c
use IEEE.STD_LOGIC_ARITH.ALL;9 v! t. M7 g8 ]' c; ?
use IEEE.STD_LOGIC_UNSIGNED.ALL;& y" r: H7 i* `& K1 G7 }
entity D_trigger is
& G; q% h/ e5 C- j! z/ R, o) V port(D,clear: in std_logic;- H+ ~- k6 d8 H, m+ P7 k0 J
clk: in std_logic;
/ @2 H1 L! t% g L Q: out std_logic);
6 O/ Z1 k ] N; Z; Q0 qend D_trigger;
9 x# N; `$ e) S# m$ V( ]/ Q) [architecture Behavioral of D_trigger is$ l7 j7 f7 J/ m# @% D! u# X
begin
" Y" o m- h/ g* I3 gprocess(D,clear,clk) is
& O. O8 m7 a( V7 P+ Bbegin
; i( ~# |0 f* [' Z* t A: A if (clear='1') then
; h% q( X+ L2 ] o+ v4 o6 n0 @% C$ p Q<='0';
# Q+ x5 Z! |% e0 ~1 S: V9 `- p elsif (clk'event and clk='1') then* G& T- {. r7 H! l% H
Q<=D;) L) | O- H; \: M
end if;" Y) P) i* \4 a" j" }# r$ t0 y6 N
end process;
1 J& Y1 r2 }4 ]; N' G" M3 G4 dend Behavioral;9 K& ^& m; ]+ L! a' q/ N2 O
外部综合部分:* Y- i4 X5 L# I$ {1 _# {
library IEEE;4 k* M7 V6 b7 x
use IEEE.STD_LOGIC_1164.ALL;
0 `; [, n- j8 m3 [+ g {1 Buse IEEE.STD_LOGIC_ARITH.ALL;: a' \8 ?8 ?! k. {$ J. r; O4 s4 ~3 y
use IEEE.STD_LOGIC_UNSIGNED.ALL;- G3 f1 `' I! O+ p
entity pulse_expand is7 F5 e$ A4 w; m" z! |1 P
port(pulse_in,D_in: in std_logic;
' S1 V+ t3 d/ J5 p3 W) r2 Y. C clk_in: in std_logic;
2 s, s$ S: e% u& ^* Z n1,n2,n3,n4: in std_logic;
) M. w$ w" p3 w6 ^4 T pulsewidth_out: out std_logic);. j: C. H2 Y# M d! t6 l. h
end pulse_expand;
# A" P7 T7 I9 t( d6 m; H/ Qarchitecture Behavioral of pulse_expand is) S/ K8 J2 A, p* Q# k2 `: \ X' ^
signal a1,a2,a3: std_logic;* F" H2 F% d( p
component counter is " q7 S. w) V* s2 {, g
port(reset,en,clk: in std_logic;
/ w9 O4 l# F$ B4 I N1,N2,N3,N4: in std_logic;2 h. y. ^! L2 ~$ Y
feed_out: out std_logic);
+ P& z" g6 p# w8 o. n4 H$ O end component counter;- n. l( N& i) N) N# K0 R
component D_trigger is4 w' F' V2 Z' ?
port(D,clear: in std_logic;
* {* ?9 y* ~% Y$ c/ J, {8 w clk: in std_logic;
9 a8 O3 p/ z; c" p+ D B0 e* c Q: out std_logic);
$ j4 Q- C3 r& Z0 y/ z end component D_trigger;
# p8 {/ E k# rbegin
- _! Y* i. W3 A0 z9 X% aP1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);
; B! p/ J& ?& q4 c1 Fa3<= not a2; u$ C' x# y* k8 v0 F. r
P2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,
) q4 r- ?7 Z9 L9 X5 q8 [: o N1=>n1,N2=>n2,N3=>n3,N4=>n4);9 H+ r/ g* U3 o6 L% }/ c
pulsewidth_out<=a2;9 ~0 f1 x- Z0 \, ~0 y
end Behavioral;& Q/ K* X$ z7 n# Q3 N, K9 E& T$ q
q8 u4 Z9 Y, S0 E5 n$ E% x
[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ] |
|