Chip123 科技應用創新平台

 找回密碼
 申請會員

QQ登錄

只需一步,快速開始

Login

用FB帳號登入

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

[問題求助] VHDL转verilog问题

[複製鏈接]
跳轉到指定樓層
1#
發表於 2008-12-29 14:16:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
手里面有个VHDL写的FIFO,现在想转换成VERILOG的
& n0 Y7 Z! Q2 }原代码如下
  1. 7 s) s$ {# d6 N0 X
  2. ( u3 q- q* G9 n4 i, X, k
  3. CNT: process(CLR, WR_PTR, RD_PTR)
    0 @  o+ q' B! c' i  A! _
  4.   variable change : integer;  : |5 [* q  a, t. U4 p7 c* W! g6 M
  5. begin  0 @: b" l( j" q
  6.   if CLR = '1' then5 E! i2 m3 J+ M3 E; @0 T
  7.    count <= 0;
    ! [" @- h/ V* N, l' D2 G5 z
  8.    change := 0;
    4 U: N! U1 r9 t( @' P4 f: A$ p
  9.   else( w" }4 k. ^. S/ \, j7 ^8 h
  10.    change := 0;5 l2 S# C' L3 D2 M7 E3 c' q
  11.    if WR_PTR'event then) Q) T1 o& s3 J
  12.     change := 1;2 o- u  ^7 g( z; R* f: K- C/ |
  13.    end if;4 F$ @' N7 k& z; r
  14.    if RD_PTR'event then
    4 C' Q+ h& B1 G7 x& W
  15.     change := change - 1;
    3 i/ T8 V' V- |* L+ L
  16.    end if;
    : m0 z/ \, j: U- Q
  17.    count <= count + change;
      c, G! I7 y4 J" Y* p
  18.   end if;( l2 c4 A1 n) ~& z
  19. end process;
複製代碼
不知道改为Verilog该怎么写红色部分。/ Z) n! ]; ]( d# p
我想是用always@( WR_PTR), I- A$ R3 s8 f- \, h9 p
但是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
, _. J/ H$ y$ ]) U0 t) H3 Y2. count 沒有clock!你可能需要把全部貼出來,看是不是漏掉了?9 k( m" W) J4 u# r8 i
3. 一個process有兩個clock,一般不會這樣寫的。
5#
 樓主| 發表於 2009-1-10 22:11:05 | 只看該作者
  1. ------------------------------------------------------------------------------------
    4 R7 J! R4 H( E
  2. library IEEE;
    * ]- N$ @/ w) M  {4 i2 ^
  3. use IEEE.std_logic_1164.all;
    ! b- i! [; _1 ]3 K
  4. entity fifo is1 e, X3 T4 z$ ~
  5.         generic (
    ) c% U2 R  `) O; ~# S2 m& Z
  6.                 depth : positive := 16
    + s0 i: I' q2 g; d' d
  7.                 );       
    9 L6 f5 l) Y6 G8 l
  8.         port(
      L6 J2 |7 A- |. J1 O' `
  9.                 CLR   : in  std_logic;7 V) g  p" D7 k1 D+ k. Q' M) X
  10.                 WCLK  : in  std_logic;' S3 j9 r! k( R; z
  11.                 WE    : in  std_logic;  y4 Y, k! ^/ n; E  d0 O
  12.                 RCLK  : in  std_logic;& K! [/ z" ?8 }; O" r
  13.                 RE    : in  std_logic;1 {/ `  S' X  I' h
  14.                 DATA  : in  std_logic_vector(7 downto 0);
    & ^4 }9 n9 F3 ?; o( a
  15.                 EMPTY : out std_logic;
    " d1 {7 \& j% p! k+ A0 M- S& \
  16.                 FULL  : out std_logic;
    ; a7 `# I: t  l: v" [
  17.                 Q     : out std_logic_vector(7 downto 0)
    % ?# W+ k: D( H! z
  18.         );
    , i4 p% V5 O3 M2 k
  19. end entity;: D( ^+ j) Y  N8 W7 P$ F: r
  20. library IEEE;3 H$ x7 r; X0 p0 m
  21. use IEEE.std_logic_unsigned.all;8 {, D% C$ n( N; p( z
  22. architecture behavior of fifo is" T, T8 n: y  p4 y, d9 K) [9 _
  23.         constant fmax : positive := depth-1;       
    5 |! `# L8 g: E4 m2 [+ |
  24.         type fifo_array_type is array (fmax downto 0) of std_logic_vector(7 downto 0);
    2 T! _0 B- z% s& ~* Y
  25.         signal fifo_array : fifo_array_type;
    ) G7 R! i4 C3 L$ Z5 {% [' J: s
  26.         signal WR_PTR : INTEGER range 0 to fmax;/ t5 e* C  R  \" P4 L: a( @
  27.         signal RD_PTR : INTEGER range 0 to fmax;
    1 _* C( X/ I- n* s6 n
  28.         signal count  : INTEGER range 0 to depth;
    : `3 N  B. Y2 g4 A; Z% ^8 M" [' f
  29. begin1 a$ D, c3 e: F( G7 v
  30.         CNT: process(CLR, WR_PTR, RD_PTR)
    5 W) X5 t* }& A: w( ], a+ {
  31.                 variable change : integer;                  @3 _, g& i: h8 x% @/ r$ `
  32.         begin  
    7 }' Z  m3 g# e4 c) D; w
  33.                 if CLR = '1' then1 U9 s  U# E: D' c
  34.                         count <= 0;! s+ g* J( |7 a8 u
  35.                         change := 0;  K( H1 w- X/ @- ~: _
  36.                 else- D  X$ O# R) W+ T( Q2 z- m7 F
  37.                         change := 0;5 `' G# J' W: h# z
  38.                         if WR_PTR'event then
    ! F) M4 u3 c  n- S! F6 p
  39.                                 change := 1;! O! Q" S/ p3 q7 ~) t- v- i' j
  40.                         end if;# e  D! Z/ Q. V0 Q2 o! A
  41.                         if RD_PTR'event then7 Z3 f# b) Q9 R9 ^4 c0 B
  42.                                 change := change - 1;
      o9 E" l2 F2 R. S1 B& B6 u$ I
  43.                         end if;, [+ G! O3 Q" ~5 c  O
  44.                         count <= count + change;
    ) {9 D4 L% R, p9 L
  45.                 end if;
    / f- K2 P& s+ z+ Y' @, ^5 D
  46.         end process;        $ g, H; C! v7 `
  47.         STATUS: process(count)0 J( Z$ o* ^: V
  48.         begin  
    & H$ C6 S. v$ b) m1 E" O9 c
  49.                 if count=0 then
    ! W$ {6 C1 ~- @, F3 g
  50.                         FULL   <= '0';" d( P& Y! D: ?( I- o
  51.                         EMPTY  <= '1';1 t1 z; N, K" S( l8 I+ D1 ?  w
  52.                 elsif count=depth  then
      }' f/ ^+ q: Y, T. i; {; h
  53.                         FULL   <= '1'; 8 E: k5 Q7 w- e8 D9 M% I
  54.                         EMPTY  <= '0';
    ( z8 m5 t; Q  R7 m5 q* X& P
  55.                 else       
    ! W/ c# ~( S/ U% Q5 O1 j
  56.                         FULL   <= '0';
    2 p: V0 m" s6 j& W5 u# e
  57.                         EMPTY  <= '0'; 8 l" z$ o0 }( R! O  ~* U
  58.                 end if;                       
    2 c3 h" }5 m3 r) D4 d3 d
  59.         end process;       
複製代碼
6#
 樓主| 發表於 2009-1-10 22:13:00 | 只看該作者
  1.         FWRITE: process (CLR, WCLK); j6 N: ^6 e( m; d
  2.         begin& h: G$ C. M) G5 ?+ `
  3.                 if CLR = '1' then
    ) ]) k& I' K* c  L
  4.                         for INDEX in fmax downto 0 loop; ?) R/ w, I2 f
  5.                                 fifo_array(INDEX) <= (others => '0');
    5 j! n' s& O2 Q9 V9 @  f' k
  6.                         end loop;
    ; U6 G# r# U' l& j6 ]3 S
  7.                         WR_PTR <= 0;
    + L; `* M; b. X! j7 I6 Q; z
  8.                 elsif rising_edge(WCLK) then5 y  {- D  M! X4 y: i
  9.                         if WE = '1' and count<depth then
    - ^, J  v, A" B' g1 G
  10.                                 fifo_array(WR_PTR) <= DATA;: y: S6 h% G$ z; [& }3 E2 c. q
  11.                                 -- move pointer
    $ f" N; T8 t1 m/ o% V3 C, w
  12.                                 if WR_PTR=fmax then . B6 v0 f! V6 }8 Q! K" }" ~! d+ T  l' ~
  13.                                         WR_PTR <= 0;
    ; {- `0 U0 P' l
  14.                                 else WR_PTR <= WR_PTR + 1;
    - K" ~5 M: U2 k; s: A6 T! c
  15.                                 end if;
    ( P3 O: `9 z2 O! l" V$ J* P
  16.                         end if;. N4 r1 y8 g6 i" D, V" L+ @0 [5 W3 C
  17.                 end if;
    , V5 D' @$ c9 @
  18.         end process;
    # P+ o0 \9 V) @: g1 y2 Q
  19.         FREAD: process (CLR, RCLK)
    . D' l3 o$ x6 G# V" h; U/ z
  20.         begin1 V8 a, f- x1 l, W2 c- c
  21.                 if CLR = '1' then
    & r) u* k- l, u! f8 H
  22.                         RD_PTR <= 0;
    : G8 `0 N: h3 z& ?% {4 n
  23.                 elsif falling_edge(RCLK) then+ Z- N. h! C" h! j
  24.                         if RE = '1' and count>0 then
    $ b) a2 m" y7 E) h5 R  I* B5 o
  25.                                 Q <= fifo_array(RD_PTR);
    1 p- f2 W) b+ |+ ~( U0 P
  26.                                 -- move pointer 1 z: U. U3 ]5 J- J  g+ s
  27.                                 if RD_PTR=fmax then   F5 Y! Y8 Z" Q2 X8 Z) a" z7 `
  28.                                         RD_PTR <= 0; ! Z9 j& |6 [9 a! M; i& |1 d
  29.                                 else RD_PTR <= RD_PTR + 1;
    4 K! G0 u* S; p1 f' Y1 m+ Q* s; y
  30.                                 end if;& F# V! U% u" ]% g% s
  31.                         end if;
    ) k5 f7 P3 N! O9 G& G. _
  32.                 end if;2 g) E' r+ b. n" I
  33.         end process;
    , v6 D' n& ^! v4 R& I8 F$ Z
  34. end architecture;
複製代碼
7#
發表於 2009-7-4 00:42:31 | 只看該作者
印象中有个工具可以转vhdl 为 verilog,可以看看,或许有用
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

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

GMT+8, 2024-5-21 01:34 AM , Processed in 0.114515 second(s), 18 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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