Chip123 科技應用創新平台

 找回密碼
 申請會員

QQ登錄

只需一步,快速開始

Login

用FB帳號登入

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

[問題求助] VHDL转verilog问题

[複製鏈接]
跳轉到指定樓層
1#
發表於 2008-12-29 14:16:18 | 只看該作者 回帖獎勵 |正序瀏覽 |閱讀模式
手里面有个VHDL写的FIFO,现在想转换成VERILOG的
1 G' S: h, `8 ^7 T" C原代码如下
  1. ( k1 I; }) A0 I$ @% p9 y

  2. 4 p) U1 ?3 a* A9 g
  3. CNT: process(CLR, WR_PTR, RD_PTR)
      [" b  X; ~. G6 t6 d  V
  4.   variable change : integer;  . t  k8 c. L3 q: j% k. Y. \
  5. begin  2 g6 O; y' Y7 L. n2 l. u
  6.   if CLR = '1' then  V2 I$ [/ L- h
  7.    count <= 0;
    * C0 e2 R: _& M, l: O) e/ k3 D% O' r
  8.    change := 0;( s* a% z0 |- w- z/ P3 `& s! }+ O
  9.   else
    " {8 v) q0 a4 l: I
  10.    change := 0;6 [/ K" M; {$ b4 @9 O# S9 J5 S; B9 Y
  11.    if WR_PTR'event then
    6 X8 L. S7 g, Z1 v4 ?' p8 N
  12.     change := 1;
    : ?1 r5 g4 t) ~5 v3 Q; r
  13.    end if;0 d* N0 ]% \4 }! c! r% ~
  14.    if RD_PTR'event then6 Q7 F/ B- D1 `9 K5 W+ {
  15.     change := change - 1;
    / y% s: d* m$ H) }# G4 H. b; Y
  16.    end if;
    " e2 n0 l/ x. E4 |! X8 b
  17.    count <= count + change;
    ( k$ k4 e) q; N, J2 @7 Z, v
  18.   end if;; R1 @8 H# H2 l5 Y6 e. h
  19. end process;
複製代碼
不知道改为Verilog该怎么写红色部分。
7 i  k1 e. Z% N: n: J5 p我想是用always@( WR_PTR)
* M# W. }2 K/ E, L! ?( m4 f) c但是process(CLR, WR_PTR, RD_PTR)这一句已经用了always了,没办法,刚接触verilog,请大家帮帮忙
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 頂 踩 分享分享
7#
發表於 2009-7-4 00:42:31 | 只看該作者
印象中有个工具可以转vhdl 为 verilog,可以看看,或许有用
6#
 樓主| 發表於 2009-1-10 22:13:00 | 只看該作者
  1.         FWRITE: process (CLR, WCLK)+ V* \3 z! A( t, ]' n. E( c( e. g
  2.         begin
    ( r# [) V, D5 [, N- u
  3.                 if CLR = '1' then
    4 m9 {: z8 @3 J1 m% _, o  h
  4.                         for INDEX in fmax downto 0 loop5 J- i5 ?# L; B; N# Y
  5.                                 fifo_array(INDEX) <= (others => '0');
    # }& w( ^) L& z
  6.                         end loop;
    ' S2 ]3 R( h1 [; i  Y
  7.                         WR_PTR <= 0;
    3 G+ |6 O* R4 ?2 j
  8.                 elsif rising_edge(WCLK) then) X( p5 r2 q1 {% p0 A  V1 H+ q
  9.                         if WE = '1' and count<depth then3 `6 B) i# T% E" i8 I& A
  10.                                 fifo_array(WR_PTR) <= DATA;( H0 b: e8 u8 ]4 w  s
  11.                                 -- move pointer% h0 |5 G. l$ n1 Z; X
  12.                                 if WR_PTR=fmax then
    " o, m/ h, o( F1 ?/ a! S) [
  13.                                         WR_PTR <= 0; , s  j, ?  z& V& o  U
  14.                                 else WR_PTR <= WR_PTR + 1;
    5 J5 S; J+ M3 b' N9 a) ~: v# Y
  15.                                 end if;
    % [, o) O/ M# u& P
  16.                         end if;
    $ p& d! L* q; J
  17.                 end if;/ k1 f/ ~! F" n* Y" b3 F
  18.         end process;$ P! \) l: \- d4 \9 }
  19.         FREAD: process (CLR, RCLK)
    0 t- Q; d" g8 W6 J2 b: N; M) e
  20.         begin
    ' j" [8 R% H% ^( M+ O; R
  21.                 if CLR = '1' then
    2 U/ d8 N% p! l* ]3 {
  22.                         RD_PTR <= 0;) V) K) }* R4 Y
  23.                 elsif falling_edge(RCLK) then0 @+ I5 {2 i% ~. `( V% ?
  24.                         if RE = '1' and count>0 then" f4 y6 ^4 n$ Q! y* q
  25.                                 Q <= fifo_array(RD_PTR);
    / g" X$ \) d; f0 x' Q0 V
  26.                                 -- move pointer
    ( U- ~; p6 L$ ?/ V3 W/ W# f
  27.                                 if RD_PTR=fmax then
    2 P$ q. J" x' Z+ l* L$ `
  28.                                         RD_PTR <= 0; 1 e9 @5 ?$ h6 t
  29.                                 else RD_PTR <= RD_PTR + 1;
    . `- o6 C9 w9 c: D
  30.                                 end if;* w9 q- ^! e  v' T3 P1 J; i
  31.                         end if;
    . ]) r- L1 ?* E, ?/ Y
  32.                 end if;) o/ u* g% R, o9 p3 c- _' e) W
  33.         end process;
    : x! Z; U( |( c3 z2 Z" Q
  34. end architecture;
複製代碼
5#
 樓主| 發表於 2009-1-10 22:11:05 | 只看該作者
  1. ------------------------------------------------------------------------------------* C% m3 x* h1 J" {8 x! s# s
  2. library IEEE;
    / d8 U" }: I8 q2 l' W
  3. use IEEE.std_logic_1164.all;/ ~: R1 _; }* _; j8 W5 v- s
  4. entity fifo is$ L7 \9 d2 E) [& E" v
  5.         generic (3 N; d% d. [( _. A6 [9 v
  6.                 depth : positive := 16! u8 d6 O% _* x$ Z; K
  7.                 );       
    / G& R+ E& F' p2 U8 z# e1 V
  8.         port(
    5 j" M: j" m! G& o. L8 P
  9.                 CLR   : in  std_logic;0 A' f6 a# F# I) I! a: ?/ j
  10.                 WCLK  : in  std_logic;( I( o6 d- {" c7 s# F
  11.                 WE    : in  std_logic;; i/ k2 t% @& j( G; Y5 ~+ h
  12.                 RCLK  : in  std_logic;
    + d/ Y+ b, G) r0 `
  13.                 RE    : in  std_logic;+ k5 ~! c% ?; X+ ^
  14.                 DATA  : in  std_logic_vector(7 downto 0);3 n% O% c* C% L5 B$ |1 G* Z
  15.                 EMPTY : out std_logic;
    * V( W+ D8 \# M
  16.                 FULL  : out std_logic;" o. K; A1 F+ L' e8 n
  17.                 Q     : out std_logic_vector(7 downto 0)! |7 [# a) u+ f6 @2 H& {
  18.         );
    1 p. N. n' C* R$ [% x
  19. end entity;; t0 Y( m/ P! h; @9 @0 M. F
  20. library IEEE;& Z% y' E. Y" B# g/ \/ F
  21. use IEEE.std_logic_unsigned.all;4 r( h% C5 q$ z! {
  22. architecture behavior of fifo is
    + X* q8 O" u; x% @* R& I( l
  23.         constant fmax : positive := depth-1;       
    : P$ C0 u. W7 I, l8 {$ y
  24.         type fifo_array_type is array (fmax downto 0) of std_logic_vector(7 downto 0);+ E) I  Q- T2 v3 Y/ k# x
  25.         signal fifo_array : fifo_array_type;
    % i8 D; ]5 G+ ?; m& o
  26.         signal WR_PTR : INTEGER range 0 to fmax;
    " U% a' ^* F' F# G
  27.         signal RD_PTR : INTEGER range 0 to fmax;. Q8 y: s( \$ i: r
  28.         signal count  : INTEGER range 0 to depth;
    ) d8 a2 ~) l% H/ g) {
  29. begin- v) e! l. S6 y
  30.         CNT: process(CLR, WR_PTR, RD_PTR)
    # Y# k  B3 D& Q' R# }  k
  31.                 variable change : integer;               
    ( f" ^1 L* m4 n' _% A& N
  32.         begin  7 P5 ~3 ~# s" a" F
  33.                 if CLR = '1' then
    ( L; P! _9 y8 W/ A/ F# I/ X
  34.                         count <= 0;
    ; I! B' x. p* Z1 ?" Z( V
  35.                         change := 0;6 w% i' T8 J: q. g
  36.                 else. c0 A+ k2 z* F/ e9 l: g. n
  37.                         change := 0;
    ' T" p8 r, \5 ]! z% Q
  38.                         if WR_PTR'event then
    9 b: @1 j" K  |! ?# S  h
  39.                                 change := 1;: q9 v8 b4 V! |
  40.                         end if;
    ! R, [% W4 ]' t; C$ k
  41.                         if RD_PTR'event then
    , r5 k! {5 X, n; f  r3 S
  42.                                 change := change - 1;# Q, o1 a) j8 o4 N
  43.                         end if;
    6 m/ R$ S! Y. B) b4 Y! D
  44.                         count <= count + change;
    $ ]+ H( i; r6 r2 `) u1 b5 s5 B
  45.                 end if;
    ! I- L2 Y" g! o" u" u) y( b4 v. R
  46.         end process;       
    " t$ l. i/ f9 S* {
  47.         STATUS: process(count)1 x5 ^6 ~% P  L2 c0 A% p
  48.         begin  
    ' u/ X! ~* t. h+ O2 }
  49.                 if count=0 then: X# X3 f( t: U. ]0 ^0 \
  50.                         FULL   <= '0';+ M6 R/ a0 I' }
  51.                         EMPTY  <= '1';
    + V. v: G* k: P6 W; _8 \
  52.                 elsif count=depth  then
    8 v4 y9 v9 T- |
  53.                         FULL   <= '1';
    - ~+ j( |- x1 |3 h
  54.                         EMPTY  <= '0';
    % B  B2 V1 {# e1 ~) ]; A% }/ t6 ]
  55.                 else       
    6 G: S" ^" T# ?& h# L' i+ C2 r
  56.                         FULL   <= '0'; 8 v7 ^8 O" E: O- }
  57.                         EMPTY  <= '0'; 8 X1 D( {) P: T' _; ^: E1 \
  58.                 end if;                       
    , Z4 P3 ^6 v, ^" P0 p
  59.         end process;       
複製代碼
4#
發表於 2009-1-7 11:42:34 | 只看該作者
1. VHDL clock 語法好像不太對,應該是 if WR_PTR'event and WR_PRT='1' then
1 F/ M- Y: u# m" q2. count 沒有clock!你可能需要把全部貼出來,看是不是漏掉了?" z' s6 G' Y, h
3. 一個process有兩個clock,一般不會這樣寫的。
3#
 樓主| 發表於 2009-1-6 16:31:33 | 只看該作者
这个FIFO程式有CLK的,我这里只是一部分代码,没有将所有代码贴出来,只是希望大家告诉我该怎么写if WR_PTR'event then
2#
發表於 2009-1-5 12:41:03 | 只看該作者
這個fifo程式有問題喔,沒有clock訊號,很奇怪.
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

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

GMT+8, 2024-6-2 06:35 AM , Processed in 0.129016 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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