Chip123 科技應用創新平台

 找回密碼
 申請會員

QQ登錄

只需一步,快速開始

Login

用FB帳號登入

搜索
1 2 3 4
查看: 9634|回復: 6
打印 上一主題 下一主題

[問題求助] VHDL转verilog问题

[複製鏈接]
跳轉到指定樓層
1#
發表於 2008-12-29 14:16:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
手里面有个VHDL写的FIFO,现在想转换成VERILOG的! T+ A5 P5 i2 z! C. z
原代码如下
  1. ' k+ B& s% b4 t

  2. 5 l6 O. ]$ S1 w1 y6 Q
  3. CNT: process(CLR, WR_PTR, RD_PTR)& o' f; d% P0 }) J
  4.   variable change : integer;  , V) q' j. [+ z& @4 x: W& R8 L5 m
  5. begin  
    " z( Y1 p& g# T- l; g
  6.   if CLR = '1' then
    # @- ]" d' M, y- m5 e! o' r
  7.    count <= 0;; Y  }/ A. c$ L) y* m2 x
  8.    change := 0;/ F* m$ O- n% ~% M. ~9 Z* V# ?
  9.   else- m; [0 M, E% J. U0 X8 E
  10.    change := 0;& F7 z: S; ^' S0 |% `
  11.    if WR_PTR'event then
    4 V6 k( N% g1 H
  12.     change := 1;
    9 q# B- l7 s8 x
  13.    end if;0 ^5 ~) p; [! z1 Y
  14.    if RD_PTR'event then
    % a6 S$ ~0 ~, W. M
  15.     change := change - 1;2 f2 f. t1 t+ r4 c* j3 X" c- o
  16.    end if;
    # u' l0 u& w! w6 o$ y3 N: \) ]
  17.    count <= count + change;
    0 c' P+ X5 V; u& W8 r! I
  18.   end if;
    8 i. c0 s3 D8 G3 ^0 s# R, Y/ a
  19. end process;
複製代碼
不知道改为Verilog该怎么写红色部分。# |- z1 R+ a0 N6 N  |% B
我想是用always@( WR_PTR)
. S8 P3 _/ c3 E8 }4 y$ b但是process(CLR, WR_PTR, RD_PTR)这一句已经用了always了,没办法,刚接触verilog,请大家帮帮忙
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 頂 踩 分享分享
2#
發表於 2009-1-5 12:41:03 | 只看該作者
這個fifo程式有問題喔,沒有clock訊號,很奇怪.
3#
 樓主| 發表於 2009-1-6 16:31:33 | 只看該作者
这个FIFO程式有CLK的,我这里只是一部分代码,没有将所有代码贴出来,只是希望大家告诉我该怎么写if WR_PTR'event then
4#
發表於 2009-1-7 11:42:34 | 只看該作者
1. VHDL clock 語法好像不太對,應該是 if WR_PTR'event and WR_PRT='1' then
/ m+ U9 U, r2 B$ E5 C2. count 沒有clock!你可能需要把全部貼出來,看是不是漏掉了?  A  {' W2 d# e
3. 一個process有兩個clock,一般不會這樣寫的。
5#
 樓主| 發表於 2009-1-10 22:11:05 | 只看該作者
  1. ------------------------------------------------------------------------------------4 `9 T& z2 G6 p$ Q9 f
  2. library IEEE;
    ) r. O" }: [8 y" z- O# o( x
  3. use IEEE.std_logic_1164.all;
    ! ]1 @0 H6 ]% c
  4. entity fifo is7 h1 M" b5 N; I  \* s3 }& @6 t
  5.         generic (
    " y" {+ w# m$ P& x8 Z
  6.                 depth : positive := 16- c1 y$ o6 s, N5 ~$ O
  7.                 );       
    5 F0 E8 n( X5 I& O! Q2 D
  8.         port(" E# i$ W/ e" _. B* q* r
  9.                 CLR   : in  std_logic;  p% ?4 u) c2 K
  10.                 WCLK  : in  std_logic;
    ! L. v" [) e+ v4 f* t
  11.                 WE    : in  std_logic;
    - v7 _5 n2 _0 `, T
  12.                 RCLK  : in  std_logic;# J! p: P" G6 o
  13.                 RE    : in  std_logic;0 P) U0 F2 N% L1 W2 _; R
  14.                 DATA  : in  std_logic_vector(7 downto 0);
    9 y1 G' X0 L3 j# K9 U  {
  15.                 EMPTY : out std_logic;. ]5 |! ?3 M- N2 w$ `* i
  16.                 FULL  : out std_logic;9 v0 O8 N" _" K, ]
  17.                 Q     : out std_logic_vector(7 downto 0)/ \) g! B9 p0 Y6 y4 N1 }
  18.         );
    3 H4 k- T: {4 v4 `! a
  19. end entity;
    $ B' T- F3 @, q  o
  20. library IEEE;* L; b3 n! S2 a$ N
  21. use IEEE.std_logic_unsigned.all;
    ( a0 C! X1 m( S
  22. architecture behavior of fifo is* g0 S! X3 I  T/ C/ k
  23.         constant fmax : positive := depth-1;        3 B+ z+ A- a5 J" w6 G: P
  24.         type fifo_array_type is array (fmax downto 0) of std_logic_vector(7 downto 0);
    , k- W0 _* ]2 }0 Q
  25.         signal fifo_array : fifo_array_type;
    ! t$ T2 t8 z" j
  26.         signal WR_PTR : INTEGER range 0 to fmax;+ T4 \# n9 B. n& B, f3 E
  27.         signal RD_PTR : INTEGER range 0 to fmax;# t" V/ ?) P$ G4 l
  28.         signal count  : INTEGER range 0 to depth;9 x( D* C" M) A2 f# A
  29. begin
    , E8 x- r1 }9 Y3 @% A& C
  30.         CNT: process(CLR, WR_PTR, RD_PTR)
    ; f( Y8 \7 m6 a, @
  31.                 variable change : integer;               
    : M, G* @- a+ L
  32.         begin  + {1 U$ {. |9 j; |* }; O# i4 ^
  33.                 if CLR = '1' then& Y+ q1 s6 H4 E* o; e
  34.                         count <= 0;. W! e1 V$ R( t9 g! Y
  35.                         change := 0;
    ! }; F- N$ V3 R( Q
  36.                 else8 @3 `: T$ A! P7 Z* ?
  37.                         change := 0;  E9 Q4 T4 R4 F9 |1 N0 r/ Z
  38.                         if WR_PTR'event then8 N* Z' j1 T  |5 k+ b" O
  39.                                 change := 1;
    4 l% D) r  L( W  i4 T% l; C' X
  40.                         end if;
    " a2 o# g6 v4 l4 D9 I5 N4 X2 ]
  41.                         if RD_PTR'event then
    5 t! O6 P2 n! Z3 r" A; H1 k  }
  42.                                 change := change - 1;4 q* u  ^: U$ g8 M& X) D! D
  43.                         end if;) `9 g$ x- b- |
  44.                         count <= count + change;
    9 N0 O6 B# G7 {8 w% W
  45.                 end if;9 ^8 i4 w/ j$ w- B2 Z
  46.         end process;       
    3 \$ p' I- o. @; D
  47.         STATUS: process(count)
    ; E: F) Q. S! y9 A
  48.         begin  / b% g, k$ {3 l/ n
  49.                 if count=0 then3 W8 v  {& u* U3 k0 q! h  D
  50.                         FULL   <= '0';. u! }- h1 s' s7 m. }' L
  51.                         EMPTY  <= '1';+ j+ R% X! b) f$ ~7 H( }' k2 P
  52.                 elsif count=depth  then: _5 n/ Q+ ~4 p6 c$ k& z5 V
  53.                         FULL   <= '1'; ) k+ O" W2 o) r+ H+ Y
  54.                         EMPTY  <= '0';
    5 r6 P7 k# b2 l, p
  55.                 else        3 R3 W" H, ~( x3 H1 M* t
  56.                         FULL   <= '0'; / D$ G# B4 K3 n) u5 ^
  57.                         EMPTY  <= '0'; ( v& r; M! v$ a- f) r
  58.                 end if;                        # `2 \  `+ a6 x$ p7 y6 S4 d8 Y$ C
  59.         end process;       
複製代碼
6#
 樓主| 發表於 2009-1-10 22:13:00 | 只看該作者
  1.         FWRITE: process (CLR, WCLK)8 U5 f# h( B4 B) _! ?0 e
  2.         begin
    ' [% r, N0 Y1 V" Z
  3.                 if CLR = '1' then
    4 D$ W! c( H, K; [& g! a6 X
  4.                         for INDEX in fmax downto 0 loop' b0 j6 e/ K( X) \9 u! A. k' s0 b
  5.                                 fifo_array(INDEX) <= (others => '0');
    5 s$ v' I4 [2 Q: v. V  [
  6.                         end loop;- A$ w( U" B. p0 ]3 B1 ]
  7.                         WR_PTR <= 0;& k  V: ?, a; m2 B
  8.                 elsif rising_edge(WCLK) then2 P$ m+ z2 j% S4 ]
  9.                         if WE = '1' and count<depth then
    ( ]# Z$ B& r" k$ R2 t  w0 [( T
  10.                                 fifo_array(WR_PTR) <= DATA;
    0 S1 A6 b( r6 [: p+ J
  11.                                 -- move pointer
    0 U& Z; B9 F- q+ z; n# s3 d% \
  12.                                 if WR_PTR=fmax then
    / R+ H; u  D, L5 d9 e
  13.                                         WR_PTR <= 0;
    # ~- ^5 L; T1 J; B5 h" \
  14.                                 else WR_PTR <= WR_PTR + 1;
    ' I/ v1 t" R  n2 L0 V
  15.                                 end if;
    7 T# V$ X; Q' K- K9 o, s8 o
  16.                         end if;
    6 }& |1 ~, J2 V) b& u* {- V5 w6 \) h9 Q
  17.                 end if;
    # c" P! h0 \! f1 [
  18.         end process;
      _$ L  {# ]& Z8 w  L1 q
  19.         FREAD: process (CLR, RCLK)8 R7 l% n5 {' i# c0 i/ P
  20.         begin7 c8 v1 K" Q0 y; w
  21.                 if CLR = '1' then- _3 ?0 G+ H' {% m& O8 b. F0 L0 z, @
  22.                         RD_PTR <= 0;$ l$ X- E* @4 f; `/ o/ o
  23.                 elsif falling_edge(RCLK) then# P- {/ x& P2 l. a* D! f
  24.                         if RE = '1' and count>0 then; b4 o1 I8 O# V  n: S' |1 n
  25.                                 Q <= fifo_array(RD_PTR);0 k# f+ w, X- ?9 M" W( V, W
  26.                                 -- move pointer
    . S3 h* u) O- g& x7 a6 o1 ^3 Y
  27.                                 if RD_PTR=fmax then
    ; r# i! r( A( e* b
  28.                                         RD_PTR <= 0;
    8 N# a% G3 ~! S- a" o
  29.                                 else RD_PTR <= RD_PTR + 1;
    7 D) k' @  r, _7 Z
  30.                                 end if;
    % ]1 B3 ?# }+ b5 b' @9 u
  31.                         end if;
    5 t; U0 }3 b& K& ?
  32.                 end if;% F$ ^/ x9 v, p% k+ j+ C& t
  33.         end process;# X4 B% g7 _0 c/ \) G7 z7 y' `
  34. end architecture;
複製代碼
7#
發表於 2009-7-4 00:42:31 | 只看該作者
印象中有个工具可以转vhdl 为 verilog,可以看看,或许有用
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

首頁|手機版|Chip123 科技應用創新平台 |新契機國際商機整合股份有限公司

GMT+8, 2024-6-17 02:27 AM , Processed in 0.133016 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表