EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我做的是出租车计费系统,VHDL语言做的,也就是从网上下载的。请问一下下面的程序中SE模块和DI模块是干什么用的啊?拜托帮忙,快答辩了!3.3.1
+ Z" {0 ~+ A7 S1 a+ R# _模块
- V# B$ |; o1 W4 nJIFEI' F9 n# {+ L# @ z! k
的实现
i# z1 {+ N$ e- K+ l0 ~该模块是模拟汽车启动,停止,暂停加速。模块如图4: CLKSTART
) i$ _( Y# u7 k" @CHEFEI[12...0]STOP
; i A* d1 R5 Q4 gLUC[12...0]PAUSEJS0 \' S7 j) E& S3 ?9 v4 H/ U
|
+ K2 f( B7 g. T7 c. e ]5 x" `( r图 4. P0 T, n f3 }, D% _
JIFEI模 块 输入端口
9 [, m+ K, ?+ X1 sSTART、STOP、PAUSE、JS8 M+ F- @4 C! U5 h
分别为汽车起动、停止、暂停、加速按键。程序如下: 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,luc ut 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$ x1 v5 r$ V- ]8 G1 J
模块
4 L: w9 d( Q) n5 K' rX
; M( _! s+ L; |的实现
! A' [4 n8 G5 w7 f模块X见图5。该模块把车费和路程转化为4位十进制数,daclk的频率要比 clk快得多。 AGE[3...0] ASH[3...0]DACLK- Q c: O6 A% W4 v$ l- ^' y0 {
ABAI[3...0]ASCORE3 I- a+ t4 V( }4 r Z7 Q' [
AQIAN[3...0]BSCORE
7 f. ~; S: G- YBGE[3...0BSHI[3...0]BBAI[3...0]BQIAN[3...0]
" I$ Y5 @& N. @3 q1 }5 y1 @ | ; h J- _8 B, M
图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,bqian ut 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
. C8 P3 F+ f5 x; ?模块
( c7 E4 k6 } T, yXXX1
& B3 ~ ?. z/ e2 N# N实现
4 v9 W5 }6 y, R7 f) K9 w模块XXX1见图6。经过该八进制模块将车费和路程显示出来。该设计采用的是共阴极七段数码管,根据16进制和七段显示段码表对应关系,用VHDL的CASE语句可方便的实现他们的译码。 动态扫描时利用人眼的视觉暂留原理,只要扫描频率不小于34HZ,人眼就感觉不到显示器的闪烁。本系统24HZ的扫描脉冲由相对应的外围电路提供。动态扫描电路设计的关键在于位选信号要与显示的数据在时序上一一对应,因此电路中必须提供同步脉冲信号。 C[2...0]A1[3...0]A2[3...0] A3[3...0]
5 @1 Q" J! r( L6 [5 k h
+ |3 B5 V$ A& m+ X, [0 c; v/ s4 T) NDPA4[3...0]B1[3...0]
/ [ c z2 S1 B& s- g/ p- {) u/ G9 r
D[3...0]B2[3...0]B3[3...0]B4[3...0]- n3 c# t" R9 N, s: F
|
0 J5 B$ f' Z; ]$ |+ i* X( G, V图 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); dp ut 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 when”000”=>d<=a1; dp<=’0’; when”001”=>d<=a2; dp<=’0’; when”010”=>d<=a3; dp<=’1’; when”011”=>d<=a4; dp<=’0’ ;
' h- h$ r; d* T, U0 O+ B4 ?. nwhen”100”=>d<=b1; dp<=’0’; when”101”=>d<=b2; dp<=’0’;
6 t. M- S" Q1 I# u& swhen”110”=>d<=b3;
dp<=’1’; when”111”=>d<=b4; dp<=’0’; when
* u# z+ D* N8 Xothers=>null; end5 m- B u* l; d+ _
case; end
' ?" B+ ^' Z2 w+ g: z+ l2 n$ Wprocess; end0 I2 e: J( w2 k/ ] b0 ?
rtl; 3.3.45 ]! G# V* j' x/ T. p9 Y
模块
4 ], \* k2 {1 pSE: f) Z7 s" P. Z( \9 \, D! H: _
的实现
0 }7 z/ z; X0 w( M& D1 [; r模块
' A& N" L. C; e, gSE% D( F4 g: B1 \2 u( _ j' `1 `; A
见图
8 N0 E n {$ r4 U# O$ r7:该模块是系统检测模块。 CLK9 ^) Y' G3 X* h, O" N. d3 Q L( U) F
. Z/ B* B% _1 M- B
A[2...0] r3 H; c0 k1 p, D* G: u
| * S2 R$ C# R! I- K. \8 z2 r2 d
图! l9 c* r# M/ D0 i4 Y
7
# h$ a: a, V. \1 Q1 ? a) d- MSE模8 Z8 d: e4 O% L4 w* g5 u1 W$ d- O% x
块 模块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(clk’event 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: U6 T5 a% i( \2 y3 N% ^$ U
模块2 R) ]1 m8 r* _% M0 i
DI* P) b) p+ B! o' V0 t
的实现
( D' \# s! Y' x4 V/ T7 {模块DI见图 8 D[3..0]8 h# H" ~1 ^1 ?' Q! `" Y6 B
( t4 V9 p" ~9 `* T6 |& N- zQ[6..0]& M" N: }; }1 g, g c+ h" W
|
+ B2 \) o! ]0 P$ N: |% u( B
! n; K: U9 d7 ]" \8 ]0 n+ E% r
( m% ^) @1 l. C# A
! [7 T% ^& v& k6 M9 I9 V" W" ^图8 DI模块
模块DI的程序如下4 Y; e5 K. m$ b x5 M0 [- U
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
/ r4 J9 l1 F' B6 \! o% U6 Trtl of di is begin process(d) begin case d is when”0000”=>q<=”0111111”; when”0001”=>q<=”0000110”; when”0010”=>q<=”1011011”; when”0011”=>q<=”1001111”; when”0100”=>q<=”1100110”; when”0101”=>q<=”1101101”; when”0110”=>q<=”1111101”; when”0111”=>q<=”0100111”; when”1000”=>q<=”1101111”; when others=>q<=”1101111”; end case; end process; end rtl; |