找回密码
 注册
关于网站域名变更的通知
查看: 1690|回复: 2
打印 上一主题 下一主题

求助!模块分析,十万火急,望各位大大分析下啊

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-4-23 12:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
我做的是出租车计费系统,VHDL语言做的,也就是从网上下载的。请问一下下面的程序中SE模块和DI模块是干什么用的啊?拜托帮忙,快答辩了!3.3.1% O! w( a# m+ d  [( \$ Z

0 K" E* N: P; K9 G# q" b$ o
JIFEI
# w* h8 a& I8 @( @% H3 `9 w
的实现  `& F- H* P7 t

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

CLKSTART
# p1 z+ @3 ^; ^+ s! x' hCHEFEI[12...0]
STOP
5 T% |2 k& d: j& X* yLUC[12...0]
PAUSEJS4 n+ X0 Q$ v& U4 a9 T% Y

$ `0 {$ j- d! @- m

图 4+ t# N, U; J% R0 D# X
JIFEI模 块

输入端口# q' r4 ?" F. b7 \3 b
START、STOP、PAUSE、JS
* F- a2 _, j& t0 n$ \8 y( D" z/ z分别为汽车起动、停止、
暂停、加速按键。程序如下:

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
* ]. f' f' Q% X  c

4 M- N) W: Q6 b! k6 b
X0 w" t) Y) i  P! F0 K- T
的实现+ i! L9 s& b# K/ ~

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

       AGE[3...0]        ASH[3...0]DACLK
* N5 q1 _( ?4 g# fABAI[3...0
]ASCORE
+ x, r( |! @: P; YAQIAN[3...0]
BSCORE" W! i) b3 {! W! c: z3 f
BGE[3...0
BSHI[3...0]BBAI[3...0]BQIAN[3...0]
& w4 r, L" t; X* L, l


% S3 U* O3 s& O4 w& I1 N, x

图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& g' f- F( N! g1 t: l6 q0 @
" q4 ]' N6 E1 C! L
XXX1
) W1 C) \1 C+ {& h
实现5 d( f" C& L2 I. V/ ^6 h

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

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

C[2...0]A1[3...0]A2[3...0] A3[3...0]
/ m% D3 I- W! l) l& R+ d# ~2 c, H2 u0 t4 {, o: ~7 p
DP
A4[3...0]B1[3...0]7 e: o, s, I. _/ O( g- b" G. Z  g

1 b5 a/ O' e; e2 W6 F* a' ND[3...0]
B2[3...0]B3[3...0]B4[3...0]
4 a) H0 y4 E  V# @  T: g- }

% N/ k  K% J: ~) X0 q# x( \- I

图 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 L# \, U+ i; e4 V" D& H% v+ K
when”100”=>d<=b1;

dp<=’0’;

                  when”101”=>d<=b2;

dp<=’0’;

4 |8 o. ]6 B& d4 H; Y$ A
when
”110”=>d<=b3;

dp<=’1’;

when”111”=>d<=b4;

dp<=’0’;

when
) m1 T* a/ E+ w/ f+ \* y6 E% Mothers=>null;

end
- |- v3 D' `1 J7 _8 R( rcase;

end% V! N9 k6 b0 q1 K. d/ [
process;

end
" Y4 i0 J4 `5 G8 D4 H% Brtl;

3.3.48 J  T0 @6 Z# J9 Z9 s, [% w8 `! ^

" T; ^+ b) a8 `! B2 W* _
SE
8 @' b7 E( c& @4 y& w  S) O+ y6 G1 N! B9 h
的实现
9 d1 U) E: ]$ s% e

模块; O1 h" r; K% n! u3 t7 y
SE, j' ]3 d: e( T) W1 _" j8 t
见图! z; Z% Q6 {! N$ E0 I9 O
7:该模块是系统检测模块。

CLK
  K) H5 m/ G1 W7 S% O! ^9 t" V9 ?2 w( q4 B5 j$ \0 `
A[2...0]
5 o! r# r* t, u+ b* I

3 K  U# d8 V! }: z


. J1 V  O' B# N
7
% g: z' `6 s( Z  Y3 V& \SE

# a- T. G3 x$ Z8 u1 y; R/ }9 e

模块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.59 }9 Y6 w* Q% @+ D. q7 E$ A

- m" @- @4 ~: q1 k3 e: [. ^6 s
DI8 q, O8 J4 |6 V  Z
的实现  x! Z5 B* ~+ l# O+ z/ f6 `3 ~

模块DI见图 8

D[3..0]
+ a: n" B6 p  f& V
) N2 S" I4 N5 v  f* FQ[6..0]

: l8 F9 F) w0 [& x
6 F, h& a; G' s% |; G


. K* [; j3 q' a, p3 @! z, |

  n% S* o: W8 O! \$ t- R! v, W


9 I$ R- k& C) r1 c& Q
! b0 Q, X0 X  K5 H1 B
8 DI模块

模块DI的程序如下% j. {: P$ v/ X2 d4 p+ l5 g& H) F# e

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  I9 j* B  M) u9 c- g2 @5 N3 d1 C
rtl 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;

该用户从未签到

2#
发表于 2010-4-26 15:00 | 只看该作者
怎么分析呀,图看不到呀; E( \4 ^' _$ D6 ^$ u7 Y
VHDL忘记的差不多了
" P( D. G% h9 ?  q: y2 c外面的公司,用VERILOG的多些

该用户从未签到

3#
 楼主| 发表于 2010-4-27 09:21 | 只看该作者
回复 2# leiyanjiao ! X/ X) C. s( \; o
5 T% D' U. O6 Y) \
8 e7 g& V7 P* I/ h( @' U
    额,谢谢啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-7-19 18:32 , Processed in 0.140625 second(s), 24 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表