|
本帖最后由 chenqinte 于 2009-5-5 14:34 编辑 3 b$ g) Q* M( B* O" r5 q3 J
3 }+ B- o1 t! {- g$ q- R没人顶哦,这是我写的一个小程序不过仿真的结果可以实现3分频,但在板子上跑时,分频乱七八糟的,不知道为什么$ r: B# A3 h0 u! m+ @
library ieee;
6 L, N/ r$ k; Y6 I+ Q; b. m; \9 ^use ieee.std_logic_1164.all;) i$ u& s3 C: c9 n5 S
use ieee.std_logic_arith.all;
# n6 n8 h }' `' w5 O* g' \use ieee.std_logic_unsigned.all;7 z3 f9 @7 E4 B3 ]$ E4 L+ Z: v( C! v, S) }
entity febpin is& g: T, m+ B5 d i7 B7 _
port(0 d: l0 G! h: ~- o
clk:in std_logic;$ J3 V6 B7 N* O& U6 ~
div3:inout std_logic- b! ?" \6 W" r2 Z5 Y
);1 ?- G( _0 G: m( q9 T
end;' M8 N0 v1 F7 X2 i
architecture behavioral of febpin is5 }6 \/ W; m' @3 h& J/ b! F
signal cnt:integer range 0 to 2; b% y: ?' {, \; y# N
signal q:std_logic:='0';
: R% j! R0 o* B S7 y* sbegin7 G. E% s1 }7 H) ^7 S4 z+ m! Q% v
process(clk)
, E/ ]3 \8 x" Y& m. Q! g" k begin
" J3 Q# b9 e/ A( o( i d6 ^: B" | if (clk'event) then- {9 l/ @4 D8 y/ _+ I' i
if cnt=2 then
' v E% r7 Q. g8 Q, i+ Z U( Z q<=not q;
. C; q x' a8 \( m+ i& _ cnt<=0;: {: X! \; }4 F# d/ D( q
else
5 h. p' I' f- n5 c& h7 v cnt<=cnt+1;& q' g: M( ]# E3 b/ A2 B k
end if;: w3 U+ `) ?8 A2 t" y
end if;
) A% S6 `% |& H% G- ?1 x end process;" j8 @" x) L# `0 w
div3<=q;
& h# `8 I- j1 v7 aend behavioral; |
|