EDA365电子论坛网

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

作者: marshal403006    时间: 2008-6-1 23:30
标题: 基于FPGA的单稳态脉冲展宽电路的设计问题!
请各位高手看看本人的程序,编译通过了,仿真却没有结果。我想实现的功能是单稳态脉冲展宽(通过外端口控制展宽宽度)。程序如下:
( F! i/ b9 K- d. h( M计数器(控制展宽电路的宽度)部分:
1 I; {' ?, W# Z' E! N$ y6 C4 slibrary IEEE;" e% Z+ Q" X$ B1 \6 w
use IEEE.STD_LOGIC_1164.ALL;, V/ n2 K5 ]3 d
use IEEE.STD_LOGIC_ARITH.ALL;
3 [% j3 C; I+ e/ _- h" s  d9 Yuse IEEE.STD_LOGIC_UNSIGNED.ALL;
. i6 t7 Z4 V/ J3 Wentity counter is
0 {8 F# Q; {& [' h( U3 \: |  port(reset,en,clk: in std_logic;
% \0 g# g9 S+ Z4 C3 A% Y( S4 C* K/ x       N1,N2,N3,N4: in std_logic;
; Q  D& x( D7 N6 ~* d0 D6 L! B" ^7 i       feed_out: out std_logic);. [8 l/ N& |, [; [5 S6 e" C6 o8 m. d
  end counter;
: c% T( j; V( i& O/ X  uarchitecture Behavioral of counter is
: `. e' C4 k5 |" [3 tsignal temp: integer range 0 to 15:=0;
  w) n' }) W& D% i* Wsignal k:integer:=0;! O3 `, I8 K/ ?5 N$ E, u) j: n( Z
begin
  u; \) S6 R! R. f+ J( w  cprocess(N1,N2,N3,N4,k,clk) is
: I, \1 `/ d2 Rbegin5 d; w7 Z2 p4 F( Q
   if(N1='1') then temp<=temp+1;9 U3 q. d3 T% b
  elsif(N2='1') then temp<=temp+2;
4 B: R4 J% {' x8 ?  elsif(N3='1') then temp<=temp+4;4 X; a8 R( J: K0 m1 Q# f2 O2 u
  elsif(N4='1') then temp<=temp+8;
$ G) s* s- U1 I  else null;7 Q- |6 i1 f" ?
  end if;
" ?. I3 V* d- Q1 Y  if (clk'event and clk='1') then* J6 {5 N0 l$ n! C$ D  S% S$ x
    if (reset='1') then: y9 a4 J1 ]  R/ b* s/ X
       k<=0;
  x% C* G. ~: G! k7 A3 Q2 H) ~5 }     feed_out<='0';: x% g# J- o8 a8 `
     elsif (en='1') then   
1 M5 m! I  R& M5 O2 Z9 u    if (k=temp-1) then
( V; ?# z/ A' \6 c# t2 y         feed_out<='1';9 v" m. }% |/ y* i: j  B
         k<=temp-1;3 U1 T# ]) i' X2 f' @
     else k<=k+1;( @; ?1 ^& G) G# t6 h' U/ a  Z4 P  [# D
    end if;7 z% D, i" C( z6 r: z
    end if;
4 e# Z7 F& j, ~. Nend if;% R$ J0 I2 Y& T" d3 w  t: G9 e
end process;
( r4 }  q3 W9 ^, l& f5 vend Behavioral;, o  I+ f: i0 r* f# l
D触发器(脉冲前沿产生电路,又是展宽脉冲宽度形成电路):
6 M4 T/ A0 ]# B5 Blibrary IEEE;
3 P) C3 E- X% s( h6 euse IEEE.STD_LOGIC_1164.ALL;
7 d$ |7 F: @) \7 l2 cuse IEEE.STD_LOGIC_ARITH.ALL;2 R5 A. w" e7 O  y5 a
use IEEE.STD_LOGIC_UNSIGNED.ALL;8 _3 ]( O$ d3 m- i' k
entity D_trigger is
" I! {3 R: F- u2 |. z- y; ~8 ?  port(D,clear: in std_logic;5 ]/ V  Z# a; _) F
       clk: in std_logic;
4 d7 J# \5 d: P" ~3 g1 k, y   Q: out std_logic);
) Z+ A9 m' P6 iend D_trigger;
% ^3 R( s$ ~# _architecture Behavioral of D_trigger is9 d. U( K, t1 n/ V5 a
begin
2 b7 z+ y7 H$ s8 D4 J$ t6 @process(D,clear,clk) is3 Y* ~/ M. |3 {# i3 T" B
begin
5 Z  f* f  [2 J$ x  if (clear='1') then: }$ s: l4 U1 }# |
    Q<='0';     
) _" c! B& p. b9 C0 `8 |4 ?  elsif (clk'event and clk='1') then2 q7 w' l' A% r, _. j  {7 u
    Q<=D;, M+ H, j" ?3 d6 D) _8 d
  end if;
1 M6 Z  m7 I) g& `9 \3 [end process;  * N5 B3 h! ^1 D4 r) C6 }
end Behavioral;
; R- B) X% X1 q9 _! M8 [* [8 G% G外部综合部分:
. G! P3 p, G  X( e) y3 Wlibrary IEEE;( h4 O9 Q: a' ~5 B% G
use IEEE.STD_LOGIC_1164.ALL;
/ }+ ?" x2 \" p) [use IEEE.STD_LOGIC_ARITH.ALL;
; j( n7 D0 M5 x3 l, g, iuse IEEE.STD_LOGIC_UNSIGNED.ALL;
2 W: h+ ?5 f+ I/ [( x, Y5 a; |entity pulse_expand is% C$ y( s: x: D: }/ K6 l6 r
  port(pulse_in,D_in: in std_logic;
6 `) `( {! `) _8 x$ U       clk_in: in std_logic;
) A/ r+ Y$ Z* l8 `/ k& B+ c   n1,n2,n3,n4: in std_logic;5 i' Q3 ^4 w/ D; R
   pulsewidth_out: out std_logic);" ?$ _# x2 A5 x# V6 j: ^1 S* z
end pulse_expand;
3 r: f: l8 K" }% |- E3 }architecture Behavioral of pulse_expand is
  {# `6 }2 I, i- p1 tsignal a1,a2,a3: std_logic;3 N7 q' f3 L7 Y, B
component counter is
- E) w7 v) U, p! ~8 N) m4 G0 M* K   port(reset,en,clk: in std_logic;2 K  x$ r3 j4 k, V/ i* Y# L
      N1,N2,N3,N4: in std_logic;" Q8 ~7 K: ~  J  X" v
        feed_out: out std_logic);" `' L# N+ X- A
  end component counter;1 H- J4 ^9 [; A8 k0 q
  component  D_trigger is3 M' F3 _7 I. b+ h+ `
     port(D,clear: in std_logic;4 g* O5 U* S+ Z* e9 m
          clk: in std_logic;
2 P8 w% Q7 N- b+ E9 K/ a/ S      Q: out std_logic);
0 b+ s; y2 G! o/ z* ~: m  end component D_trigger;
. b" o. M. N" m* gbegin1 Z  B. D- e/ \( T
P1: D_trigger port map (D=>D_in,clear=>a1,clk=>pulse_in,Q=>a2);
, q. L- z* w# S3 \+ G- sa3<= not a2;
+ ]* O* H& L, L4 S5 V& NP2: counter port map ( reset=>a3,en=>a2,clk=>clk_in,feed_out=>a1,
! q# k* i- [- M# P    N1=>n1,N2=>n2,N3=>n3,N4=>n4);* {, }8 t' ~2 ^. C, ]+ e4 H
pulsewidth_out<=a2;9 ?9 M# g! Y: c3 r
end Behavioral;
  N, ^! I3 n7 j; i  \  N* ?, p% F2 \6 T
[ 本帖最后由 marshal403006 于 2008-6-2 09:38 编辑 ]




欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) Powered by Discuz! X3.2