EDA365电子工程师网

标题: 基于FPGA的单稳态脉冲展宽电路的设计问题! [打印本页]

作者: marshal403006    时间: 2008-6-1 23:30
标题: 基于FPGA的单稳态脉冲展宽电路的设计问题!
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:& [) Q* a/ v. G1 u0 T! F
计数器(控制展宽电路的宽度)部分:" b6 i# S5 Z6 H9 J3 e
library IEEE;
" ]& u: [8 \" E* r  |7 `use IEEE.STD_LOGIC_1164.ALL;+ f3 f9 W1 n3 P( h7 r; }
use IEEE.STD_LOGIC_ARITH.ALL;
# v" P) f" o! ^6 J+ @: N# Ouse IEEE.STD_LOGIC_UNSIGNED.ALL;- m7 h: b2 T: v6 H
entity counter is2 w8 L0 @: y3 a) V
  port(reset,en,clk: in std_logic;
7 y- I- D9 B' k       N1,N2,N3,N4: in std_logic;
8 X5 [; Q- X/ }6 N6 x  b3 A5 I       feed_out: out std_logic);
1 I9 m7 B4 L; ?4 u* i  end counter;
6 O9 q1 A) {  r5 ?architecture Behavioral of counter is
* C4 ?/ }8 t% t. z3 a0 Asignal temp: integer range 0 to 15:=0;/ p5 C6 y; A: W# u3 ~7 \7 o
signal k:integer:=0;
) m. I* ?1 z. s  N; ^# O4 Pbegin
. D$ t& A" O- `) }/ Rprocess(N1,N2,N3,N4,k,clk) is$ M9 A' g  V: `* a2 k/ s
begin7 k  i. t; t% D
   if(N1='1') then temp<=temp+1;' A$ w6 o1 g* R3 T% }2 {
  elsif(N2='1') then temp<=temp+2;; y5 H& L( |1 C: o
  elsif(N3='1') then temp<=temp+4;
5 k; W& ?, R  a2 q; V+ A/ G" O; a  elsif(N4='1') then temp<=temp+8;
3 S' D8 ^0 c2 }: V  else null;* K3 _0 R0 Q7 g; }/ L4 N" ?
  end if;
8 Q9 Q" S1 Y0 n! a' S  if (clk'event and clk='1') then
0 {$ y+ D: G% k+ T5 P( G. U    if (reset='1') then
2 j- e: m2 x/ B) N% O4 K) d' `       k<=0;5 G1 h/ |  H0 e6 t2 f- y! _% j
     feed_out<='0';4 Z8 l. s! P2 b! @' s
     elsif (en='1') then   , [$ n$ ], |. h5 \
    if (k=temp-1) then
& B4 V, X# |$ ?- A4 U5 V5 J: [; U         feed_out<='1';
3 [/ z! }4 J6 S         k<=temp-1;
# V8 P. G/ S# z3 p, j9 d. [     else k<=k+1;
; {* G) m+ \/ Q' t: _    end if;9 i" `$ D6 l: f3 i
    end if;
7 E: u6 t: T& ?+ K1 bend if;% e, n. |4 ~, N& f8 ^
end process;
% `) J& t" n" L# kend Behavioral;
, d  s$ S9 Q% L$ OD触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):
9 j. O6 d/ K* v( ?. [library IEEE;
1 j, ]% R: }2 q! w% Uuse IEEE.STD_LOGIC_1164.ALL;
, [6 C% J0 F* z. E& Ause IEEE.STD_LOGIC_ARITH.ALL;; j; C% P' x4 r; X6 w6 r
use IEEE.STD_LOGIC_UNSIGNED.ALL;4 N4 }6 R. U7 v! M- u9 `
entity D_trigger is
6 A8 i- ^- Y- ]# P' s  port(D,clear: in std_logic;( w5 _; u% q7 b# Y' Z+ P+ Q
       clk: in std_logic;- b5 p8 S2 _0 m8 ]' Z, t6 r+ q" `
   Q: out std_logic);
5 ^/ n: w3 N" Bend D_trigger;; |# Q: z$ o+ K
architecture Behavioral of D_trigger is
% n# a0 n. z4 j7 n/ Wbegin; d6 e4 u) V+ V
process(D,clear,clk) is
1 }0 ^7 ]1 B0 ^begin
% l1 h: c0 ?7 }4 }  if (clear='1') then
4 [0 I$ T6 u' f9 }: k$ h    Q<='0';     
$ ^) g, Q1 I( ]0 k  elsif (clk'event and clk='1') then2 H/ Y2 n6 ]3 T' W
    Q<=D;; s' i; P! L/ L3 `( c* b8 k  s: w
  end if;7 Y1 n( j/ F- h7 \, t
end process;  
" H4 ]- p' f  o5 q+ t6 k/ s# Jend Behavioral;* K8 O) U! t; q  ^, R1 H6 C8 _
外部综合部分:  |; s; H: s& B' I$ ^- [
library IEEE;' f: |6 ^$ h) g7 v5 G( ^/ m# o
use IEEE.STD_LOGIC_1164.ALL;
5 Y) l. o* j# \/ kuse IEEE.STD_LOGIC_ARITH.ALL;
& o$ i7 l" G1 x7 L% wuse IEEE.STD_LOGIC_UNSIGNED.ALL;
8 q2 p! |4 d) s' U( e* pentity pulse_expand is
9 ^; X  z& F- A/ G9 g/ }/ h% Q  port(pulse_in,D_in: in std_logic;1 D& ?' @5 T2 k, a: ]0 w
       clk_in: in std_logic;
) y6 v2 v  ^. U' r   n1,n2,n3,n4: in std_logic;
3 V% \1 o7 G8 @! O" @' o   pulsewidth_out: out std_logic);, \& |% k( D9 Z8 T* z$ y
end pulse_expand;6 }2 q. o/ [. |: r5 O
architecture Behavioral of pulse_expand is
' [2 @/ b8 f9 |: l+ @+ y% h8 |3 ysignal a1,a2,a3: std_logic;
+ u) P( p9 x# _component counter is / E3 \& O" K" r( \" n3 M, B) M% ~
   port(reset,en,clk: in std_logic;
. G$ j( c8 l8 ?" s% L/ Z7 |      N1,N2,N3,N4: in std_logic;
$ o+ H. m, z# J" ^- s# y" l- S6 A1 E        feed_out: out std_logic);
& U. L' Q- S' _) j6 ]/ w1 _# u  end component counter;2 k* i; J" k6 W0 E
  component  D_trigger is
. ^" O, s( J1 G7 C! [, m* ~7 d     port(D,clear: in std_logic;
# q; i8 X/ q+ ^3 M% B  ?          clk: in std_logic;
; G4 [2 T$ _  K  H& C+ o      Q: out std_logic);1 r" D6 W' i+ e
  end component D_trigger;/ z+ ^- Z0 E8 X
begin+ H9 v9 L3 ]) X! U, L" ?. \+ F
P1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);
, w, E5 }& a6 ^7 n! i8 _a3<= not a2;
! D' D$ n6 h! Z. B2 SP2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,
5 i3 Q  H2 w5 Z! z- X8 A: h    N1=>n1,N2=>n2,N3=>n3,N4=>n4);  W. F+ P2 W8 F* \. Y9 Z
pulsewidth_out<=a2;
/ Q5 o# b- m: X6 N! c3 G/ s& `end Behavioral;
& b4 K" h9 U. C! k, _/ J
# l9 p- y3 T/ Y$ p5 H; O[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ]




欢迎光临 EDA365电子工程师网 (https://bbs.elecnest.cn/) Powered by Discuz! X3.2