Chip123 科技應用創新平台

 找回密碼
 申請會員

QQ登錄

只需一步,快速開始

Login

用FB帳號登入

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

[問題求助] VHDL转verilog问题

[複製鏈接]
跳轉到指定樓層
1#
發表於 2008-12-29 14:16:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
手里面有个VHDL写的FIFO,现在想转换成VERILOG的" M; _  d+ R" o3 B& j! x
原代码如下

  1. 8 D* a; [; [1 r, h

  2. % \+ d2 R& ]" M5 Y
  3. CNT: process(CLR, WR_PTR, RD_PTR)# E; o2 c$ t) w/ K8 A/ I
  4.   variable change : integer;  
    6 x  F. e, \9 E' a  v! ?" Z; v
  5. begin  
    ; B( y* u  B8 [2 Z* u7 }# ?7 a
  6.   if CLR = '1' then3 |* v( N4 \' r7 }
  7.    count <= 0;* ~* r: n9 U8 r* R! k; e7 B1 {
  8.    change := 0;
    " q+ H% Y5 M; h! i1 _2 ^( p
  9.   else
    7 h4 f( U5 K* K! I0 E" I/ _3 w
  10.    change := 0;
    2 \0 j8 _9 E3 Y1 p' i( \, ^% H
  11.    if WR_PTR'event then* q; F" N; g  Q
  12.     change := 1;2 t* Q9 S: V2 d! d8 W3 G" n
  13.    end if;
    5 M  {, v* l; R' h( }& R- ]! v
  14.    if RD_PTR'event then
      z+ p- U3 R- G
  15.     change := change - 1;
    1 j) Q# Y" ]6 R! g. E
  16.    end if;3 O+ B" O2 R1 \+ o! ?% i
  17.    count <= count + change;- ^  E* j3 o7 w
  18.   end if;
    ; N  z3 K$ P9 }
  19. end process;
複製代碼
不知道改为Verilog该怎么写红色部分。
% y; d# x3 x. b+ \我想是用always@( WR_PTR)/ T7 E3 e  j6 n4 j3 O4 g- |
但是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
8 Q, ]9 V6 e1 V  x1 t* R3 y; D2. count 沒有clock!你可能需要把全部貼出來,看是不是漏掉了?
6 K" S5 x! r# O# S  V6 S6 Q3. 一個process有兩個clock,一般不會這樣寫的。
5#
 樓主| 發表於 2009-1-10 22:11:05 | 只看該作者
  1. ------------------------------------------------------------------------------------
    % j8 |7 A; K) ^3 U& E$ z' `
  2. library IEEE;: v% }( Y5 m0 s$ E) e/ J( Z1 I
  3. use IEEE.std_logic_1164.all;
    - L$ ]- n9 O$ K* S, }5 W0 f' w
  4. entity fifo is
    * [$ X0 K9 d' g
  5.         generic (
    3 Z4 K! |- p' z$ D5 `' O
  6.                 depth : positive := 16
    + `4 x; i, E  {# @9 Z8 n
  7.                 );       
    / X  a; @4 o. [2 V1 V
  8.         port(
    ) t1 M+ p/ E" \  [( y, a
  9.                 CLR   : in  std_logic;  I- @3 D( r' \1 g
  10.                 WCLK  : in  std_logic;
    4 l$ J3 B7 j) X& g
  11.                 WE    : in  std_logic;0 X/ ~& r0 \0 F! j! d- q6 ]1 i% I
  12.                 RCLK  : in  std_logic;; R. r# R% |& r# G% \
  13.                 RE    : in  std_logic;( _* ?0 g1 k2 ]: K% q4 \4 \
  14.                 DATA  : in  std_logic_vector(7 downto 0);
    0 M7 p9 s' I' R3 X) f0 h
  15.                 EMPTY : out std_logic;1 _3 R2 r! O) B5 ?
  16.                 FULL  : out std_logic;
    ! [/ j1 d. u! `2 r
  17.                 Q     : out std_logic_vector(7 downto 0)+ W3 b2 G  c) j  S% ~
  18.         );
    ! ^( V% N% J% n2 g) s0 V4 _7 ]
  19. end entity;# s2 P6 A* _& {" m  u9 M) D
  20. library IEEE;3 b4 N3 z& n6 z9 h* G9 L% W
  21. use IEEE.std_logic_unsigned.all;, A. r% n( ^- I6 T$ ?
  22. architecture behavior of fifo is' I" ]( l5 b. m% z! @/ |
  23.         constant fmax : positive := depth-1;       
    9 T3 P: @8 z& m1 d1 a& d
  24.         type fifo_array_type is array (fmax downto 0) of std_logic_vector(7 downto 0);
    / G: Z+ G: Z' F: W2 g) ^
  25.         signal fifo_array : fifo_array_type;
    ! L+ l/ t0 \% C/ {5 f! k* k  @
  26.         signal WR_PTR : INTEGER range 0 to fmax;
    " K- S4 q- w# X4 {0 Q
  27.         signal RD_PTR : INTEGER range 0 to fmax;# n# W* k/ E$ t% B0 c2 l
  28.         signal count  : INTEGER range 0 to depth;. i4 n# i- N! |& j" ?) y  K
  29. begin
    " E" j1 T2 F& P2 D6 y2 g
  30.         CNT: process(CLR, WR_PTR, RD_PTR)
    8 U) f2 g6 d  O: L7 E
  31.                 variable change : integer;               
    " s* a( G! i2 t; p8 P1 d
  32.         begin  
    ! w: H' P1 j4 T* e. q8 s
  33.                 if CLR = '1' then& S; N. Z3 ^5 [! b& O
  34.                         count <= 0;6 u7 z4 [3 L7 J9 ~% N
  35.                         change := 0;3 O/ C" O  B9 ~. ~; v, q7 ]
  36.                 else
    ; D  z, C- `2 Q2 }5 y
  37.                         change := 0;8 r$ V7 X" E5 l4 r6 l
  38.                         if WR_PTR'event then
    0 T, y- J7 S, f- y1 L9 a* a
  39.                                 change := 1;4 K" H# t2 g2 I' S, |* v
  40.                         end if;
    ) \& ~- M% U0 a5 t$ H
  41.                         if RD_PTR'event then
      p/ R% s5 ?& \7 I% _
  42.                                 change := change - 1;" X" z6 N2 j. j6 p% c
  43.                         end if;  C/ X! Z% @3 h  f* O1 |
  44.                         count <= count + change;" i0 `9 B. I6 E- C+ N8 Z' o
  45.                 end if;
    4 I4 q1 b5 i# A3 o
  46.         end process;       
    ) V1 F: ~& j8 p. Q
  47.         STATUS: process(count)
    ) p' c% m, \& U0 Y& y$ G* R
  48.         begin  : O$ H. d" c7 f, K' F$ E% B5 ?
  49.                 if count=0 then
    6 ?: ]9 a* E$ R) p+ R
  50.                         FULL   <= '0';0 s% [$ @+ l% e1 T
  51.                         EMPTY  <= '1';
    9 m" E! s. q5 ^
  52.                 elsif count=depth  then
    , h0 j1 _6 d. F" t
  53.                         FULL   <= '1'; . c/ R( W2 u" Q4 e/ x& X
  54.                         EMPTY  <= '0'; 5 X- g) S) A8 x+ t' G1 S$ ]3 D
  55.                 else        9 U( k# E# g8 V! J# U' k* `
  56.                         FULL   <= '0';
    ; f& T2 ~8 t3 o5 W# P. @4 l
  57.                         EMPTY  <= '0'; 6 _! n5 B; ?% ~3 D# c
  58.                 end if;                       
    ' a7 ~, U+ i# ?( C* r
  59.         end process;       
複製代碼
6#
 樓主| 發表於 2009-1-10 22:13:00 | 只看該作者
  1.         FWRITE: process (CLR, WCLK)
    6 i( S0 x. F6 S# r3 o0 ]
  2.         begin% h. M& L6 f5 m
  3.                 if CLR = '1' then8 _$ b4 V) T- v/ @9 q
  4.                         for INDEX in fmax downto 0 loop; [, W$ G8 M, k
  5.                                 fifo_array(INDEX) <= (others => '0');
    9 J' i" H$ ^! Q' T
  6.                         end loop;
      O1 Y/ X4 X7 X: X( c; y
  7.                         WR_PTR <= 0;) P, ?) V7 |0 \# W  ~
  8.                 elsif rising_edge(WCLK) then
    / Z2 ^+ N# P* E- T, `# e9 g1 a9 f' }
  9.                         if WE = '1' and count<depth then
    / W2 |* ]2 j, x/ V
  10.                                 fifo_array(WR_PTR) <= DATA;
    5 }  t& Q( a3 t7 o
  11.                                 -- move pointer) C5 n% H% ?! |$ `2 h
  12.                                 if WR_PTR=fmax then
    , N# r4 Q1 I! s1 Z5 h: C# ]0 e7 [
  13.                                         WR_PTR <= 0;
    ( {) R& t* F' e8 ~
  14.                                 else WR_PTR <= WR_PTR + 1;
    - j# [0 q0 X) E% }  E  N
  15.                                 end if;
    6 @5 ^5 j1 n# E9 N, q8 k( D
  16.                         end if;( Q' Y4 t4 s/ b8 Z' k$ a
  17.                 end if;! A- i/ ^4 Q$ t4 q7 z/ ^
  18.         end process;  J! e6 n9 l! N3 H, t9 i2 F
  19.         FREAD: process (CLR, RCLK)' l, R. w) Z: f$ ^" G9 o0 }
  20.         begin' ~% K8 ?* ]- u- v
  21.                 if CLR = '1' then7 X: @. J: K5 T; X
  22.                         RD_PTR <= 0;+ D- n- j$ f" R# {  i
  23.                 elsif falling_edge(RCLK) then
    & G6 b& q" R" E2 F) Q' j. h/ i9 N
  24.                         if RE = '1' and count>0 then7 G% }# Y5 j' v. M, ?! X7 a6 B
  25.                                 Q <= fifo_array(RD_PTR);
    2 @5 [  H4 S8 j/ T
  26.                                 -- move pointer 5 N! Y9 g4 B8 y* x0 r! t) u
  27.                                 if RD_PTR=fmax then : p+ Y  p# \% g$ x$ J3 J9 @
  28.                                         RD_PTR <= 0; 6 f2 n0 c, N1 ]- W
  29.                                 else RD_PTR <= RD_PTR + 1;
    ! u. O  s5 @+ {$ Q1 [7 O
  30.                                 end if;
    1 N4 R3 f) H& K+ P: d% a
  31.                         end if;8 @6 I" S6 ^% c6 P8 F
  32.                 end if;
    ' y% {- k3 g3 a. V0 b& |
  33.         end process;' U$ O' I) ?: i. v! ^" Q- v
  34. end architecture;
複製代碼
7#
發表於 2009-7-4 00:42:31 | 只看該作者
印象中有个工具可以转vhdl 为 verilog,可以看看,或许有用
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

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

GMT+8, 2024-6-7 06:16 PM , Processed in 0.132017 second(s), 18 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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