EDA365电子工程师网

标题: 求助!模块分析,十万火急,望各位大大分析下啊 [打印本页]

作者: amd521    时间: 2010-4-23 12:36
标题: 求助!模块分析,十万火急,望各位大大分析下啊
我做的是出租车计费系统,VHDL语言做的,也就是从网上下载的。请问一下下面的程序中SE模块和DI模块是干什么用的啊?拜托帮忙,快答辩了!3.3.16 U1 o% }" F3 v/ @3 Q

' K% h; @4 S$ y- [2 _( k
JIFEI4 q9 x! V% ~7 v4 R6 D) C) \
的实现# {5 P+ a, q3 _4 _7 Z' V( [& l3 Z2 f

该模块是模拟汽车启动,停止,暂停加速。模块如图4:

CLKSTART
. P' P! R' W" R% c" ?) WCHEFEI[12...0]
STOP
' n! X& ]. R; F9 l- k) X. ZLUC[12...0]
PAUSEJS
1 L) y& k( L- g& F* J! o( \/ ]

1 i4 m% b0 v  T" v$ O+ w

图 4
, y5 A& N) J- |9 MJIFEI模 块

输入端口1 v2 g. [# ^& @& A0 L" l
START、STOP、PAUSE、JS
' q7 Z) E1 J; T$ ^5 R) q分别为汽车起动、停止、
暂停、加速按键。程序如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity jifei is

port (clk,start,stop,pause,js:in std_logic;

chefei,lucut integer range 0 to 8000);

end jifei;

architecture rtl of jifei is begin process(clk,start,stop,pause,js) variable a,b:std_logic;

variable aa:integer range 0 to 100; variable chf,lc:integer range 0 to 8000; variable num:integer range 0 to 9;

begin if(clk'event and clk='1')then if(stop='0')then

chf:=0;

num:=0;

b:='1';

aa:=0; lc:=0; elsif(start='0')then b:='0';

chf:=700;

lc:=0;

elsif(start='1' and js='1'and pause='1')then if(b='0')then

num:=num+1; end if; if(num=9)then lc:=lc+5; num:=0; aa:=aa+5;

end if;

elsif(start='1'and js='0'and pause='1')then lc:=lc+1;

aa:=aa+1; end if; if(aa>=100)then a:='1';

aa:=0; else a:='0'; end if;

if(lc<300)then null;

elsif(chf<2000 and a='1')then chf:=chf+220;

elsif(chf>=2000 and a='1')then chf:=chf+330;

end if;

end if; chefei<=chf; luc<=lc;

end process;

end rtl;

3.3.2
6 s8 P% _1 z7 ]; d" s( n0 l

/ W3 b5 [( A" t7 P7 q
X" L/ s7 t' V- h# L+ N0 _8 _: u
的实现$ \1 V( B) ]) v/ Q0 H# Q% [

模块X见图5。该模块把车费和路程转化为4位十进制数,daclk的频率要比 clk快得多。

       AGE[3...0]        ASH[3...0]DACLK
! d3 g6 P/ P3 Q' D( xABAI[3...0
]ASCORE! R9 o9 O3 k8 p) s  g: B9 ]1 {4 t
AQIAN[3...0]
BSCORE
1 v& d0 B3 A8 W0 R( d8 Y2 `0 KBGE[3...0
BSHI[3...0]BBAI[3...0]BQIAN[3...0]
6 x/ b; ?; H( X$ S

8 d; r- G% \9 T; C" w2 u0 e+ S

图5 X模块

该模块的程序如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity x is

port(daclk:in std_logic; ascore,bscore:in integer range 0 to 8000; age,ashi,abai,aqian,bge,bshi,bbai,bqianut std_logic_vector(3 downto 0)); end x ;

architecture rtl of x is begin

process(daclk,ascore)

variable comb1:integer range 0 to 8000;

variable comb1a,comb1b,comb1c,comb1d:std_logic_vector(3 downto 0);

begin

if(daclk'event and daclk='1')then

if(comb1<ascore)then

if(comb1a=9 and comb1b=9 and comb1c=9)then comb1a:="0000";

comb1b:="0000"; comb1c:="0000"; comb1d:=comb1d+1; comb1:=comb1+1;

elsif(comb1a=9 and comb1b=9)then comb1a:="0000";

comb1b:="0000"; comb1:=comb1+1; comb1c:=comb1c+1; elsif(comb1a=9)then comb1a:="0000"; comb1b:= comb1b+1; comb1:= comb1+1; else

comb1a:= comb1a+1; comb1:= comb1+1; end if;

else

ashi<= comb1b; age<= comb1a; abai<= comb1c; aqian<= comb1d; comb1:=0; comb1a:="0000"; comb1b:="0000"; comb1c:="0000"; comb1d:="0000"; end if;

end if;

end process;

process(daclk,bscore)

variable comb2:integer range 0 to 8000;

variable comb2a,comb2b, comb2c,comb2d:std_logic_vector(3 downto 0);

begin

if(daclk'event and daclk='1')then if(comb2<bscore)then

if(comb2a=9 and comb2b=9 and comb2c=9)then comb2a:="0000";

comb2b:="0000"; comb2c:="0000"; comb2d:=comb2d+1; comb2:=comb2+1;

elsif(comb2a=9 and comb2b=9)then comb2a:="0000";

comb2b:="0000"; comb2:= comb2+1; comb2c:= comb2c+1; elsif(comb2a=9)then comb2a:="0000"; comb2b:=comb2b+1; comb2:=comb2+1;

else

comb2a:= comb2a+1; comb2:= comb2+1; end if;

else bshi<=comb2b; bge<=comb2a; bbai<=comb2c; bqian<=comb2d;

comb2:=0;

comb2a:="0000";

comb2b:="0000"; comb2c:="0000"; comb2d:="0000"; end if;

end if;

end process;

end rtl;

3.3.3
- n; g2 |0 Y* |( |3 x
, q' X( h! j4 c) Z$ j: \" s" n
XXX1
4 |7 o! O6 R1 T0 N. B" L
实现0 v' R! F$ L5 @, l; I3 ]

模块XXX1见图6。经过该八进制模块将车费和路程显示出来。该设计采用的是共阴极七段数码管,根据16进制和七段显示段码表对应关系,用VHDL的CASE语句可方便的实现他们的译码。

动态扫描时利用人眼的视觉暂留原理,只要扫描频率不小于34HZ,人眼就感觉不到显示器的闪烁。本系统24HZ的扫描脉冲由相对应的外围电路提供。动态扫描电路设计的关键在于位选信号要与显示的数据在时序上一一对应,因此电路中必须提供同步脉冲信号。

C[2...0]A1[3...0]A2[3...0] A3[3...0]
  q5 J" `& I* }! L. |* k
+ R- C8 K' S5 I! ]) v- K* A: WDP
A4[3...0]B1[3...0]
# E# H+ I6 h/ Y5 ?! `. h- j, r1 V% |% Y, ?8 u
D[3...0]
B2[3...0]B3[3...0]B4[3...0]
5 k" V9 m4 l9 ?6 U$ q


) D, I2 `, _) @5 Q; L6 e' D  e

图 6 模块XXX1

这里采用八位计数器提供同步脉冲,VHDL语言如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity XXX1 is

port(c:in std_logic_vector(2 downto 0);

dput std_logic;

a1,a2,a3,a4,b1,b2,b3,b4:in std_logic_vector(3 downto 0);

d:out std_logic_vector(3 downto 0));

end XXX1;

architecture rtl of xxx1 is begin process(c,a1,a2,a3,a4,b1,b2,b3,b4)

variable comb:std_logic_vector(2 downto 0);

begin

comb:=c;

case comb is when000=>d<=a1;

dp<=0;

when001=>d<=a2;

dp<=0;

when010=>d<=a3;

dp<=1;

when011=>d<=a4;

dp<=0

;
+ U% I8 h' ]$ o7 u9 W
when”100”=>d<=b1;

dp<=’0’;

                  when”101”=>d<=b2;

dp<=’0’;


0 O5 R8 P! m4 n1 K) v; v6 j, Vwhen
”110”=>d<=b3;

dp<=’1’;

when”111”=>d<=b4;

dp<=’0’;

when
& K- H( b+ X  L6 n- c% y1 Dothers=>null;

end
7 _/ }, F% A& e# b  k5 gcase;

end
: v  \- v8 h" n' f* b0 a% M- E3 e; cprocess;

end0 @9 R% F3 `$ U5 \% t% A( u" R! Q3 L
rtl;

3.3.4
0 u( M/ J8 H, G7 k

2 a0 }4 u8 r/ ~# y- |) N- z
SE
# D- [4 N4 A9 e2 [/ `
的实现& O& _& I& h$ F

模块8 }6 B8 ]8 I) o' G2 f* R
SE
0 v( |6 k6 F- b& Q3 c; p* m( H- U见图; \4 ^5 o& l# r3 \$ P$ J) z/ D
7:该模块是系统检测模块。

CLK- `* i8 F# U, j) k  ?- f

2 y  S6 |& ^3 G: F( JA[2...0]

1 W, V2 A* K6 J1 e9 D0 L) D


$ P/ g  D3 n. l  L) z

8 N. A1 Q- c  n$ M) e8 b
7 ; G5 ~: D2 ?' m) d/ J$ n0 I( Q# |
SE

2 v- X( Z3 S/ @" h

模块SE程序如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity se is port(clk:in std_logic;

a:out std_logic_vector(2 downto 0));

end se;

architecture rtl of se is begin

process(clk)

variable b:std_logic_vector(2 downto 0);

begin

if(clkevent and clk=1)then if(b=111)then

b:=000;

else b:=b+1; end if; end if; a<=b;

end process;

end rtl;

3.3.5. ~1 X4 g6 a5 M* R$ G" o' n6 D

( u; T% ?+ A1 }/ Z
DI( I' P" U7 s7 F6 o2 g2 o& w
的实现  t1 Q3 X- b5 t' [  ?  v& t1 @

模块DI见图 8

D[3..0]7 o  F/ q$ f# X. ?) z( [: L

( Z" O  t; E2 y1 ]8 Y  k3 WQ[6..0]

% F) w9 a$ Y$ o: z

  ?7 J/ T+ \6 k  P


. v0 s- {( y) v1 Z! X

  T6 v3 S. P/ q9 [+ [


" H1 d/ Z5 _: [7 j; n" S+ Q
2 b5 g8 u1 h( f, ^
8 DI模块

模块DI的程序如下* [1 O  s) T! [' c2 w

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity di is

port(d:in std_logic_vector(3 downto 0);

q:out std_logic_vector(6 downto 0));

end di;

architecture
$ ]( P$ t; _# A6 o! Trtl of di is begin

process(d)

begin

case d is when0000=>q<=0111111;

when0001=>q<=0000110;

when0010=>q<=1011011;

when0011=>q<=1001111;

when0100=>q<=1100110;

when0101=>q<=1101101;

when0110=>q<=1111101;

when0111=>q<=0100111;

when1000=>q<=1101111;

when others=>q<=1101111;

end case;

end process;

end rtl;


作者: leiyanjiao    时间: 2010-4-26 15:00
怎么分析呀,图看不到呀
% x" a3 x( G! i! U$ OVHDL忘记的差不多了
6 l$ a; L8 N4 x5 f/ ~外面的公司,用VERILOG的多些
作者: amd521    时间: 2010-4-27 09:21
回复 2# leiyanjiao
( l: E) E2 i% e7 X. A
8 v/ A% T- C" F
6 R/ s7 b' q) W! s4 }3 p5 x    额,谢谢啊




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