EDA365电子工程师网

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

作者: amd521    时间: 2010-4-23 12:36
标题: 求助!模块分析,十万火急,望各位大大分析下啊
我做的是出租车计费系统,VHDL语言做的,也就是从网上下载的。请问一下下面的程序中SE模块和DI模块是干什么用的啊?拜托帮忙,快答辩了!3.3.1/ h# Z2 o: I8 F9 O* d  q0 A
! Y5 u7 x0 d' a
JIFEI
; |/ U6 n$ C! y8 R8 q$ {, r
的实现' Q3 f; A1 z  D2 F" o8 u8 g1 |

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

CLKSTART2 N! x6 `/ V7 v4 J
CHEFEI[12...0]
STOP, {/ [0 D6 {: w  B( i
LUC[12...0]
PAUSEJS2 O! ]3 w8 {# K- n) }

: a$ T. `- p, |

图 4
3 ]% ]5 ~) a. `  f0 D5 `JIFEI模 块

输入端口
4 O/ g* s: }/ RSTART、STOP、PAUSE、JS
+ f) M) |. I* _! t分别为汽车起动、停止、
暂停、加速按键。程序如下:

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" M+ o& N, X; q5 F2 r$ W
4 z! C% Q: b8 u
X5 C$ c( M# b) b& q, a9 e
的实现
( J; [" Y' @+ u& k8 z- S" |* v

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

       AGE[3...0]        ASH[3...0]DACLK9 t) {4 C$ q7 g- W/ X
ABAI[3...0
]ASCORE
+ v8 s& T$ C& B+ PAQIAN[3...0]
BSCORE
' k$ j8 ]& ?$ P  h( P. \# y0 cBGE[3...0
BSHI[3...0]BBAI[3...0]BQIAN[3...0]6 R/ _# b3 p5 W8 p& J

* \, N( [: @' y! s6 Y! V& }/ q+ n

图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  D4 Z  P' q! X; I2 J8 z8 `+ w

( `0 }* a3 ^* D0 B) T3 b* z
XXX1/ A: ^: M5 M7 A6 U0 [' u* J
实现9 x3 _& t" w( ~9 _1 v0 @' F

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

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

C[2...0]A1[3...0]A2[3...0] A3[3...0]
7 J" K' c- H! E( T/ d4 j5 O9 s6 I9 v
$ @7 ~& X$ `* V/ mDP
A4[3...0]B1[3...0]- ]8 \- \- V. E

5 j( O- g4 s) R; A" I  GD[3...0]
B2[3...0]B3[3...0]B4[3...0]
0 h- ^! G4 y- M4 o3 k/ [  ^

5 ^; w3 t8 Q; A

图 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

;
6 C5 ^; C0 z- W" P
when”100”=>d<=b1;

dp<=’0’;

                  when”101”=>d<=b2;

dp<=’0’;


" t8 x5 J  o  r: i9 l4 Owhen
”110”=>d<=b3;

dp<=’1’;

when”111”=>d<=b4;

dp<=’0’;

when
! u* p! P5 q) o1 a# ]others=>null;

end
+ ^$ f# }9 \) O9 Q: Xcase;

end
: B0 L( X# g( l8 Jprocess;

end
6 M0 k# V# q/ }6 W# J# U* frtl;

3.3.4
; z; q& M' x+ l+ v. q6 Y

" j* ?+ m$ d0 j7 i
SE
. c# ?# N4 b% S  K# t, i  ]5 J
的实现- I9 {. Y8 }! W

模块  A1 @/ I+ B; U# Y3 m' o
SE5 x! _: X: c5 m; g/ `7 w4 c8 p
见图4 i9 s6 F5 H" M7 u+ I- z
7:该模块是系统检测模块。

CLK: _" `$ M# h- C( t3 Q; \
$ a0 e# x9 a# q8 Y
A[2...0]
% O+ c8 Y6 ~( {! _3 @

" W6 {& U6 F" ~6 ~) ~9 ?2 m

3 r  k- {  b4 }8 w/ v
7 % p' u1 q- |. ?: T
SE
' C# Z) o, _2 a

模块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
+ p  g% S( ?6 K; r. s
* }) Y! s9 g- L% K
DI. K, p/ p7 ^( r! K4 i
的实现
: I( s" o. S! |! p7 W

模块DI见图 8

D[3..0]- n4 k3 |/ U. {" B3 Q, C( b5 S

" Y, |0 N+ y3 D6 s# f- g( j4 wQ[6..0]
8 Z8 r; r- t$ i% b$ O9 c

( P, S) d3 `% ~  c

4 Q' Y; k6 V+ m


; u/ f9 a) n; M. B7 F% A! K6 }' z

8 d8 ~( ]. I, o2 C

6 b& K7 x+ {/ W8 Z$ o$ n
8 DI模块

模块DI的程序如下
8 v+ W$ m# Y" b9 o

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
; r: ^- J* x. v1 e; z6 D* H* Urtl 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
怎么分析呀,图看不到呀$ q! t' o0 l/ S
VHDL忘记的差不多了( z2 j  p1 h7 Z6 t. n, m8 i
外面的公司,用VERILOG的多些
作者: amd521    时间: 2010-4-27 09:21
回复 2# leiyanjiao
/ f; C& _4 q3 E# U; V; f2 E) K- r& g; f) y. k& n! ^# y3 j
- X) \+ w# r& J# g, S
    额,谢谢啊




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