電子產(chǎn)業(yè)一站式賦能平臺

PCB聯(lián)盟網(wǎng)

搜索
查看: 3581|回復(fù): 11
收起左側(cè)

求助帖 求大神幫我看看這個要怎么仿真?

[復(fù)制鏈接]

585

主題

910

帖子

4977

積分

四級會員

Rank: 4

積分
4977
跳轉(zhuǎn)到指定樓層
樓主
發(fā)表于 2022-7-18 15:06:53 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
library ieee;; H( \1 v* Y; m0 R& y) H& ~' @
use ieee.std_logic_1164.all;; g3 v; U4 p0 W* w
use ieee.std_logic_unsigned.all;4 y- C9 a( ]0 u: K6 @% w9 q- k
entity taxi is0 k% }2 R( D& {
port(clk:in std_logic;5 ?( @/ }( J; ^% s3 b+ p2 V
       start:in std_logic;
. N- v3 x. H5 U: D       stop:in std_logic;
, t! Z3 I' {" q2 ?* c3 O: e       pause:in std_logic;, _6 E- A0 P+ s+ d2 W
       speedup:in std_logic_vector(1 downto 0);+ u* H, }8 C9 n3 \  I. w/ |1 `1 W
       money:out integer range 0 to 8000;
8 b( A& }/ a% W2 X- x. p; z       distance:out integer range 0 to 8000);9 p0 y7 C; g" U: H# Z, b, H+ i
end;$ {$ a5 y% g. B
architecture one of taxi is
& v( C" p9 v7 F; xbegin& K8 B& M+ c$ k6 a, i% N; Z
process(clk,start,stop,pause,speedup)  T4 Y$ i3 V* @# d9 m
     variable money_reg,distance_reg:integer range 0 to 8000;
' `5 [$ Y5 y* _+ G: {9 ^     variable num:integer range 0 to 9;7 W0 c* I- V6 Q1 r3 n( }
     variable dis:integer range 0 to 100;
$ {" s: _% y: [& N. r# Z7 a1 E) f     variable d:std_logic;# E- `* ^9 c3 M+ L
begin
6 a; t& p8 Q0 t# ~if stop='1'then& H# n; v9 m& g
      money_reg:=0;
7 x% r4 N0 V; S      distance_reg:=0;+ f, j0 q5 D0 K( D9 U# q7 h
      dis:=0;3 c" O0 N, D% ?0 ?9 Z' f5 s) O
      num:=0;8 K0 m5 J. V8 O" N1 U0 {) m
elsif start='1'then
; }3 ^) K8 w; x! }7 C5 U9 h, l      money_reg:=600;) w% N* N# G0 w% `+ \
      distance_reg:=0;+ |/ }1 s9 k! |$ C4 ~6 E; ~
      dis:=0;
; B  C. S: _0 Y  O5 C3 X* t      num:=0;6 Q! V0 m# h& y/ A2 \  p2 b
elsif clk'event and clk='1'then0 ?( f3 [" b! p" P9 C! _
       if start='0'and speedup="00"and pause='0'  and stop='0'then! A# h7 ]% x/ a5 z
            if num=9 then
2 j  [# V6 T8 s0 a! G. \3 T                 num:=0;
( ^8 \  H1 f/ L' {  G                 distance_reg:=distance_reg+1;
- ?1 @/ e9 o7 ?0 U                 dis:=dis+1;5 Q* o4 W5 I" d6 b! w" q4 m0 Z! O
              else num:=num+1;' L  {  h! j5 R, c. D
              end if;
& t' h7 u, C4 Q4 w3 C0 x. Eelsif start='0'and speedup="01"and pause='0'and stop='0'then) o  ~( I4 p& ?- u
   if num=9 then5 x4 o! T+ K8 s6 z# r1 e9 D# e  S
        num:=0;  [( _% h3 P# ~, w2 j
        distance_reg:=distance_reg+2;0 g# Z; m1 t( z- p) `
        dis:=dis+2;
4 z- F* a" \1 ]% g! Q7 }      else num:=num+1;# j, ?0 |# f, \+ Q" C  K3 o) m
      end if;. q! b) Y) o' x" W" @, K
elsif start='0'and speedup="10"and pause='0'and stop='0'then
) l/ E0 k$ Q4 A/ N  H    if num=9 then5 W4 b" Y* U/ B: \* h' L
        num:=0;
3 g$ z+ [/ K- E         distance_reg:=distance_reg+5;
& d0 p3 k8 U& i4 s4 H) M  T         dis:=dis+5;
4 e. d8 a" \* U3 N    else num:=num+1;) Y( m1 \! l' d2 n* Z
    end if;" D% R  w# O0 j. ~$ w
elsif start='0'and speedup="11"and pause='0'and stop='0'then1 G% O! V& J1 I% ~* A8 j1 D# S
           distance_reg:=distance_reg+1;
! s5 t. c; r) F) x6 U+ S* M          dis:=dis+1;
. L6 |/ Z5 `) `1 m; ~! Q& l+ tend if;8 \3 e9 z" B% e# _- f7 Z' w  A
if dis>=100then3 A" j0 i' A( g* A9 M$ n4 d
         d:='1';  w3 ~; A; I4 U2 V$ x
         dis:=0;1 J! _' H6 \1 M( u" F0 q
      else d:='0';! s7 n5 k+ L3 ^) @
end if;
2 }- s2 ?0 g# k2 ~if distance_reg>=300 then" Q! {, g7 [* w$ \; N: u( @, Q
       if money_reg<2000and d='1'then" k2 ~) t! G. f4 [% P
                money_reg:=money_reg+120;' E9 J: l+ X. y6 o
       elsif money_reg>=2000 and d='1'then5 X2 ^( C! p+ r5 O8 P0 Y
             money_reg:=money_reg+180;
% x8 {4 ~" Y) j       end if;2 p& B' N0 L& o$ P
    end if;
8 C2 ]9 ^8 L. Q( D) {: Z$ L& [" Fend if;
1 e1 v+ H: S5 m! m9 N8 V+ C    money<=money_reg;# h$ m" D+ {6 s6 ?
    distance<=distance_reg;5 ]1 K3 t0 a. }- O
end process;5 s& ?) C0 q' q. N) o7 D' V
end;8 ]4 L4 g( Y% t$ a8 A9 h+ r
程序是這樣的,
回復(fù)

使用道具 舉報

589

主題

924

帖子

4975

積分

四級會員

Rank: 4

積分
4975
沙發(fā)
發(fā)表于 2022-7-18 15:07:14 | 只看該作者

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有賬號?立即注冊

x
回復(fù) 支持 反對

使用道具 舉報

578

主題

858

帖子

4821

積分

四級會員

Rank: 4

積分
4821
板凳
發(fā)表于 2022-7-18 15:07:36 | 只看該作者
到仿真這里我實在是不知道要在每個輸入和輸出端口上面添加什么信號,哪位大神可以幫我看看
回復(fù) 支持 反對

使用道具 舉報

579

主題

911

帖子

5007

積分

四級會員

Rank: 4

積分
5007
地板
發(fā)表于 2022-7-18 15:08:19 | 只看該作者
library ieee;
0 c% ~% a3 Q. I9 \0 X3 n$ ]use ieee.std_logic_1164.all;
' |/ H9 O/ ?: z0 s0 q% Yuse ieee.std_logic_unsigned.all;; p% D* ~, g1 }: G& H9 j' _
entity decoder is& I$ Z$ ]* A; G7 p+ C. s9 @" K
port(clk20mhz:in std_logic;  Q8 f# ?: X/ q+ N- ]  w; ~. B% U
      money_in:in integer range 0to 8000;
4 Q. \9 t" b& ?( Udistance_in:in integer range 0 to 8000;
! P* b" F% @+ X1 K& ~scan:out std_logic_vector(7 downto 0);
8 z1 L! r7 C9 c! r( b8 T1 Gseg7:out std_logic_vector(6 downto 0);' Y7 O1 B) f* _3 p) h# |
dp:out std_logic);
9 k5 r7 J$ j# _8 G$ U/ B$ s9 Nend;+ A- p8 L3 C. y
architecture one of decoder is: I5 ^7 q& N5 |+ y
signal clk1khz:std_logic;
- l0 `  t9 K* x5 J- s' asignal data:std_logic_vector(3 downto 0);
0 p8 |+ w7 K0 F- I. i; X" l2 Zsignal m_one,m_ten,m_hun,m_tho:std_logic_vector(3 downto 0 );
9 s7 q7 o/ k( Isignal d_one,d_ten,d_hun,d_tho:std_logic_vector(3 downto 0);
. y' k. i2 a  Y: ]' \* n; ]begin' E- k! Z0 C, v0 E, ~7 g
process(clk20mhz)" `" {- |7 c: X' w; h0 v7 M
variable count:integer range 0 to 9999;+ X2 z: g4 l+ X+ H) s" c
begin& H$ E: U- k: j- F) @
if clk20mhz'event and clk20mhz='1'then% [  H" a# u9 w4 }1 T  i
   if count=9999 then clk1khz<=not clk1khz;count:=0;
7 N& Z- U+ X, [$ B/ |. I  z7 Z) L: d) Xelse count:=count+1;
% j: }) x0 r5 y0 [6 xend if;3 g- T2 R  A( B/ c( x4 f
end if;, C0 }: f6 d, R% K0 w! @, ^4 f
end process;! d- e( I; Y$ `, P5 ~
process(clk20mhz,money_in)
" S! C: r3 X2 h) M     variable comb1:integer range 0 to 8000;" D" T7 I% V& Y0 m
variable comb1_a,comb1_b,comb1_c,comb1_d:std_logic_vector(3 downto 0);: G$ _: H* Z- V' u4 G, o2 _
begin
# i2 y4 S4 e; Y/ H% u& iif clk20mhz'event and clk20mhz='1'then* j( |- h8 y1 |4 H. m% z  |3 r3 n
      if comb1<money_in then- @0 f7 b9 W. Z
     if comb1_a=9 and comb1_b=9 and comb1_c=9 then
7 `" W7 R% X( k; }     comb1_a:="0000";: {) d/ x: o6 z9 x4 V" y  ^
comb1_b:="0000";  x; F5 [' S% S
comb1_c:="0000";, o7 c( e0 c/ y5 Q! R5 ~
comb1_d:=comb1_d+1;' l: x8 I5 \& y, ]( w% u5 L
comb1:=comb1+1;
& W( ^, d, T7 o0 W' L( e; [- @elsif comb1_a=9 and comb1_b=9 then' P! Z- Z* j- ]3 m  [7 d
comb1_a:="0000";5 I$ ?" t: [: i( |' r3 Z  {6 Q
comb1_b:="0000";
* I/ F* H: l4 L8 b+ I5 N- jcomb1_c:=comb1_c+1;- _4 g  @% P- l; A( L/ M1 p" X
comb1:=comb1+1;* A' d. l( o$ X/ c7 Q
elsif comb1_a=9 then6 e5 `+ d1 [0 ~1 w1 C
      comb1_a:="0000";
/ W7 W2 H# o) f& a& zcomb1_b:=comb1_b+1;$ s9 l3 a+ A! ]
comb1:=comb1+1;
, M& C6 c4 ~$ ~( H* `. R2 `& c8 P else
4 c% }* g6 |1 N$ A8 h* B* L      comb1_a:=comb1_a+1;( ?( N& {# r  ]- R* F  J8 H
comb1:=comb1+1;/ X. Z, l  R* S. }7 Q
  end if;
: Y1 \% {7 {  o3 ?/ D$ A  elsif comb1=money_in then
& K4 w5 Z0 c  o# W, O- H     m_one<=comb1_a;  e. H1 P* y, J* `
m_ten<=comb1_b;3 v# r/ H) b1 D8 |4 |$ ^
m_hun<=comb1_c;
" P4 q$ v1 z  Y4 n1 Q" S, y& Rm_tho<=comb1_d;- d8 o* o2 G$ H5 O7 s
elsif comb1>money_in then
4 N% X8 z/ ?; }: y* K' l           comb1_a:="0000";
0 }' ~  I4 Q# x     comb1_b:="0000";
( k3 j7 l, B5 Z1 v( ]3 U. L2 Y6 g* Ycomb1_c:="0000";$ J; z8 ]% v4 g
     comb1_d:="0000";
, ?: G$ g5 Y& Ccomb1:=0;
  y" m, ^3 K9 d% c* X7 I4 q( Rend if;
7 G$ G4 f1 Q1 D* v/ V4 a) u. h4 nend if;
; i: b: Q- `  w& `" Fend process;
1 X$ S$ s2 p4 G9 Dprocess(clk20mhz,distance_in)$ H" v2 m. D# }5 s. a
      variable comb2:integer range 0 to 8000;
7 o8 q. ^: l+ z; b+ Bvariable comb2_a,comb2_b,comb2_c,comb2_d:std_logic_vector(3 downto 0);
# c2 R5 \- a5 o: Z4 t9 g5 s9 K& Rbegin
4 _) x7 w, ]0 D# {/ M- K4 p" sif clk20mhz'event and clk20mhz='1'then
8 R2 J5 v5 N+ D      if comb2<distance_in then8 h4 g+ H! q1 d* g* t
            if comb2_a=9 and comb2_b=9 and comb2_c=9 then4 y# V4 T) P+ q! T( t4 E2 r& v
                 comb2_a:="0000";
, _% C& K; N- t! c& ^* F          comb2_b:="0000";8 p% l# ?& K3 N; E
          comb2_c:="0000";6 Z! t& D/ f/ L6 a- X: w$ X7 ]6 V
    comb2_d:=comb2_d+1;* c& b1 g1 X5 g; _
    comb2:=comb2+1;
- J# i7 Q9 ?* B$ `2 `; ^7 K8 {9 _elsif comb2_a=9 and comb2_b=9 then
4 A) n, P$ h5 s0 Y! @: d1 t            comb2_a:="0000";; j" w9 W6 @* `' d
       comb2_b:="0000";1 q) r5 K& g0 q$ j/ e3 A3 {4 s
    comb2_c:=comb2_c+1;
5 S1 B/ A' B$ g9 Q4 e/ z    comb2:=comb2+1;
1 f3 K) z0 W1 `+ Oelsif comb2_a=9 then6 c1 a2 R- I) C# J1 D% a& `
            comb2_a:="0000";) \, c! P, {' B9 }" a
      comb2_b:=comb2_b+1;& x$ W( c  j3 a! K5 e. u3 \
      comb2:=comb2+1;$ [/ e* x2 i! e
else  W' q$ `  W) @: U; b4 x, [' B. n7 @& [
               comb2_a:=comb2_a+1;; y4 T' p0 z( G: Q! @6 H
      comb2:=comb2+1;5 R; q8 @0 ^% L
end if;
9 K- N& D4 [" D( |; x# n, R& M     elsif comb2=distance_in then- A7 g4 M, b' F4 l/ b, f
               d_one<=comb2_a;" B( V( \, j6 P. |6 K0 `% O
         d_ten<=comb2_b;
( x6 s4 b) m! ]6 k) n- J      d_hun<=comb2_c;
. o( [) [& I& `5 y( {5 P& I      d_tho<=comb2_d;4 b  r, v( X; F
elsif comb2>distance_in then. j" F1 G: a3 E5 a6 U, Z4 j
               comb2_a:="0000";* p5 a' X+ q) X$ u0 U3 n
        comb2_b:="0000";
1 t* J" N$ y! A2 T' ~- Q0 ?        comb2_c:="0000";
  B3 x% o0 p% i% t) d6 Y5 m        comb2_d:="0000";" ]% D- n8 [4 s$ V' Q3 A
        comb2:=0;3 L/ i; W7 s8 b  a9 o2 p; _
   end if;
; G! [9 [" M- l+ i  cend if;: x2 {+ V& ^, M6 C8 `& s: w  K
end process;- k2 `- \8 @9 F8 u
process(clk1khz,m_one,m_ten,m_hun,m_tho,d_one,d_ten,d_hun,d_tho)
; b. B; o, D- M# r* Qvariable cnt:std_logic_vector(2downto 0);5 \/ S2 H! ]5 A  S: E0 x2 k8 n
begin
7 u. \( ?3 A- K9 ^7 u, aif clk1khz'event and clk1khz='1'then
1 A) ?" G$ I" V0 D$ n" P% r      cnt:=cnt+1;; m2 h5 Y1 {/ l) o/ k: w/ W3 g# T: ~
end if;
. Q! U* U/ k; icase cnt is
: g" D/ n) z1 q% M5 ]6 [' E      when"000"=>data<=m_one;dp<='0';scan<="00000001";9 E" L- i$ N+ o( o4 w* L, Y' u
      when"001"=>data<=m_ten;dp<='0';scan<="00000010";
& A0 c! x7 k4 h      when"010"=>data<=m_hun;dp<='1';scan<="00000100";
; x* _+ q% |% r9 y+ B* w      when"011"=>data<=m_tho;dp<='0';scan<="00001000";
7 k5 y- s3 M4 ^( G' c  when"100"=>data<=m_one;dp<='0';scan<="00010000";
7 C  }3 |, p7 o- x4 ?1 R4 ~! ]      when"101"=>data<=m_ten;dp<='0';scan<="00100000";
, B' T! R6 }" x- v9 v/ G      when"110"=>data<=m_hun;dp<='1';scan<="01000000";2 u" |5 o; U  a2 n% y6 L
      when"111"=>data<=m_tho;dp<='0';scan<="10000000";
; Q8 s2 ~: u) Jend case;
; }9 ]) c9 m0 X: `( |" {* N* iend process;
5 p% `/ ^5 ]6 W# q0 bprocess(data)1 {. a$ Y) o( P4 j8 t
begin
. j3 j0 W4 a5 P6 B  Z! r# Ccase data is$ x$ r# u3 V. [/ `# Y! K
     when"0000"=>seg7<="1111110";* l' o3 B5 _- E1 Y& ^: B
when"0001"=>seg7<="0110000";
. E$ S2 ?, N) b0 M* \* }* Q when"0010"=>seg7<="1101101";
& }" Q# J* n4 `  T+ h when"0011"=>seg7<="1111001";
* K( |$ \3 _2 ~1 q1 ~8 q when"0100"=>seg7<="0110011";' ?: h; {6 t& e, X
when"0101"=>seg7<="1011011";
% ~0 H6 I  s8 M+ R when"0110"=>seg7<="1011111";1 h( w$ g/ L7 x- l
when"0111"=>seg7<="1110000";8 m/ y; m" ^8 i1 ^& C3 u+ Q! `- Q
when"1000"=>seg7<="1111111";
6 C1 B3 n) O' ]5 M% V" m) O when"1001"=>seg7<="1111011";  z' `$ y; E# z& }9 ?, i
when others=>seg7<="0000000";
9 }$ Q( E, h  G: m' tend case;2 _( g9 X7 k7 P$ Z
end process;( t" H) w. E+ U! a' q9 C5 U- w+ Z. w
end;
: |" p" b7 s+ U! p1 U% d. ~1 j& Q& }. Q) c7 _
6 ^4 o6 U  j4 i; i$ T

6 p- a/ ^( k+ J" R! |3 k' u: [9 f" f( W7 o
第二個程序是這樣的
回復(fù) 支持 反對

使用道具 舉報

578

主題

936

帖子

4943

積分

四級會員

Rank: 4

積分
4943
5#
發(fā)表于 2022-7-18 15:09:05 | 只看該作者

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有賬號?立即注冊

x
回復(fù) 支持 反對

使用道具 舉報

579

主題

911

帖子

5007

積分

四級會員

Rank: 4

積分
5007
6#
發(fā)表于 2022-7-18 15:09:35 | 只看該作者
第二個模塊的仿真哪一步是上面這個圖
回復(fù) 支持 反對

使用道具 舉報

604

主題

947

帖子

5151

積分

四級會員

Rank: 4

積分
5151
7#
發(fā)表于 2022-7-18 15:10:35 | 只看該作者
沒人嗎?
回復(fù) 支持 反對

使用道具 舉報

657

主題

1025

帖子

5598

積分

四級會員

Rank: 4

積分
5598
8#
發(fā)表于 2022-7-18 15:10:41 | 只看該作者
求大神幫我仿能真一波  并且把這兩個模塊的接線后的仿真也做一下謝謝了畢業(yè)設(shè)計現(xiàn)在就差這一步了下圖是連接完成的仿真圖
. r7 ~# L( o8 J5 j+ k& h. m0 k

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有賬號?立即注冊

x
回復(fù) 支持 反對

使用道具 舉報

568

主題

922

帖子

4783

積分

四級會員

Rank: 4

積分
4783
9#
發(fā)表于 2022-7-18 15:11:04 | 只看該作者
哦不是仿真圖 是將兩個模塊的連接到一起的原理圖
回復(fù) 支持 反對

使用道具 舉報

598

主題

943

帖子

5138

積分

四級會員

Rank: 4

積分
5138
10#
發(fā)表于 2022-7-18 15:11:10 | 只看該作者
自頂大神在哪里?
回復(fù) 支持 反對

使用道具 舉報

發(fā)表回復(fù)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

關(guān)閉

站長推薦上一條 /1 下一條


聯(lián)系客服 關(guān)注微信 下載APP 返回頂部 返回列表