Chip123 科技應用創新平台

 找回密碼
 申請會員

QQ登錄

只需一步,快速開始

Login

用FB帳號登入

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

[問題求助] VHDL转verilog问题

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

  1. ! d& I/ c- |# t, I9 k8 n: m4 _

  2. , I, N. A9 G: d8 n( f4 N0 I7 b) b
  3. CNT: process(CLR, WR_PTR, RD_PTR)
    ! ^# P7 J; z+ M- t7 a5 D+ }- U+ ~: Z* |& S
  4.   variable change : integer;  
    & e& K  T) L/ S2 C4 S1 q) d  j
  5. begin  
    6 t% |/ {* n; t9 ~, l
  6.   if CLR = '1' then& p4 F5 ~; W' K  [9 b6 [0 z
  7.    count <= 0;" N( J# ]* F7 E# X# j, l
  8.    change := 0;
    # t% v7 t+ B3 [* Z
  9.   else
    . {; U2 g( B1 [
  10.    change := 0;; x- j" K. s1 \" K. a: L2 t; ?
  11.    if WR_PTR'event then, n7 s7 w3 r* n2 `6 D
  12.     change := 1;' m. ^8 O% s7 T' l+ o$ e% p
  13.    end if;
    6 w0 d  @1 A9 I8 N) B( ?7 u. y* u' C0 a
  14.    if RD_PTR'event then
    % B  J! H  Q5 D
  15.     change := change - 1;
    6 Z! Y$ [7 I; E9 P3 ^% Z
  16.    end if;9 z$ z7 y! g$ ?9 p9 X) U( C
  17.    count <= count + change;
    1 L4 H6 f- n5 k
  18.   end if;  \4 I0 g7 V: `0 r0 Z* S% b
  19. end process;
複製代碼
不知道改为Verilog该怎么写红色部分。
: m* n; y1 t* u( M4 U9 }0 m我想是用always@( WR_PTR)+ y* z% F' @/ I5 Z4 e
但是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  U" N. K, G( M# X" F4 _- p
2. count 沒有clock!你可能需要把全部貼出來,看是不是漏掉了?) M; c, y) ^, h# k0 D# w. [  q
3. 一個process有兩個clock,一般不會這樣寫的。
5#
 樓主| 發表於 2009-1-10 22:11:05 | 只看該作者
  1. ------------------------------------------------------------------------------------
    ( J. C" B1 `, V5 ]
  2. library IEEE;1 _$ a$ i( u, A1 I
  3. use IEEE.std_logic_1164.all;0 E* X. k, J) ^3 K& \
  4. entity fifo is
    4 f& a! l. b8 Q6 D6 P
  5.         generic (# W0 e6 F' z. M2 P( k" P6 B6 N
  6.                 depth : positive := 16( H+ |( g2 @& b; J. n- `) u
  7.                 );        3 G8 A0 A4 J' p, [! m# y1 A, o
  8.         port(
    - @- o( Q$ f/ g5 b- d
  9.                 CLR   : in  std_logic;- K% q' |+ X- c
  10.                 WCLK  : in  std_logic;- m1 {" ]# x/ K& g% N
  11.                 WE    : in  std_logic;
    ) `  D, a, w1 }0 |1 `" m
  12.                 RCLK  : in  std_logic;; r* x; w: S4 V( B
  13.                 RE    : in  std_logic;
    ; t/ s9 [1 v1 [* w# N
  14.                 DATA  : in  std_logic_vector(7 downto 0);) j2 b  a* B7 U7 `! a; u- h
  15.                 EMPTY : out std_logic;8 @# R; Q; Z" c7 l
  16.                 FULL  : out std_logic;$ w2 D0 g3 u- X( M+ F, B) ~
  17.                 Q     : out std_logic_vector(7 downto 0)( `) A5 d/ S+ ?
  18.         );: Y- c0 p( Z+ ?
  19. end entity;
    " \# Q9 K% Z9 X+ f6 h3 {6 @% |0 U
  20. library IEEE;
    7 J; S# M; K1 c  j. J8 P0 D
  21. use IEEE.std_logic_unsigned.all;" }" T3 E% L# _( P; H
  22. architecture behavior of fifo is7 z+ O1 ?) F& @
  23.         constant fmax : positive := depth-1;        8 q7 F/ l* ]& m+ T  c
  24.         type fifo_array_type is array (fmax downto 0) of std_logic_vector(7 downto 0);
    # ?1 @5 k# U9 i" r$ U' A
  25.         signal fifo_array : fifo_array_type;
    3 I, N5 r) G. q7 [. P( c$ x2 G
  26.         signal WR_PTR : INTEGER range 0 to fmax;
    0 C/ L5 l0 h# v
  27.         signal RD_PTR : INTEGER range 0 to fmax;
    1 l; @0 h, x$ z/ p4 u+ o  d5 P
  28.         signal count  : INTEGER range 0 to depth;
      t! M" Q7 c% G9 Y2 `; x. D
  29. begin( m9 d* ?' G7 E
  30.         CNT: process(CLR, WR_PTR, RD_PTR)4 j: y" P& C3 e. @
  31.                 variable change : integer;               
    . {1 l6 b% l3 |0 E; s/ y/ q) r: m
  32.         begin  
    : {6 P" \; ]! ^+ w
  33.                 if CLR = '1' then
    3 m7 p. d2 k% {+ L: j5 b5 m
  34.                         count <= 0;6 w& N3 |# S0 S; M( Z* \
  35.                         change := 0;
    . K4 b3 U4 g3 M% ?2 E
  36.                 else- ^8 a' h) z' W. |9 d' C$ R% H
  37.                         change := 0;
    & _# x' b! [: G' H. L9 D
  38.                         if WR_PTR'event then
    - z2 Y( T# d. f- p1 f
  39.                                 change := 1;% X5 r, d/ G! S  E
  40.                         end if;
    % O$ v1 @0 ^6 @% y1 |8 I' p5 G
  41.                         if RD_PTR'event then
    0 V/ t! q& f2 }: G& h' b
  42.                                 change := change - 1;, }7 |- v3 L6 f4 V/ r( I7 |7 R
  43.                         end if;5 @  G+ ^, C0 |1 V- K
  44.                         count <= count + change;
    8 ?) [7 ?! Q' a$ b& h9 A' o3 c
  45.                 end if;
    # I, G  y& r; ^1 U1 E% A
  46.         end process;        3 b% C: {) n/ x7 ?6 ^
  47.         STATUS: process(count)
    & r  Q1 f3 t% D
  48.         begin  
    # b2 |& O+ W% `
  49.                 if count=0 then* j$ |- D' c4 V$ K& i& Q
  50.                         FULL   <= '0';
    : N/ B, s7 o& S8 m( W3 g
  51.                         EMPTY  <= '1';
    # _5 ~8 g2 F3 z+ y3 @' M0 y
  52.                 elsif count=depth  then" r& z, A. l8 t5 O" ~' i; l& C
  53.                         FULL   <= '1'; 3 {- I, U9 i& i: ]/ V
  54.                         EMPTY  <= '0';
    9 ]/ e" W7 Q- s# j7 R. {
  55.                 else       
    9 `* }& G3 i" o9 y1 R3 r
  56.                         FULL   <= '0';
    5 V, @+ m; O$ A: v1 X4 Z8 U7 c
  57.                         EMPTY  <= '0'; " N" n4 u+ I$ Q3 g4 g+ V
  58.                 end if;                        ; E0 G/ N1 f/ N
  59.         end process;       
複製代碼
6#
 樓主| 發表於 2009-1-10 22:13:00 | 只看該作者
  1.         FWRITE: process (CLR, WCLK)
    9 S+ A1 `! k. U+ A+ x" v% u( Q
  2.         begin
    8 h7 G  S# K  _, T2 t: y& L5 e
  3.                 if CLR = '1' then
    8 l4 p0 ^' @* G% d9 l6 ?  ]. s
  4.                         for INDEX in fmax downto 0 loop
    , ?2 g2 R. S, T$ K% a4 p
  5.                                 fifo_array(INDEX) <= (others => '0');4 Z- I3 O  B8 k
  6.                         end loop;
      X1 V1 V9 e: }
  7.                         WR_PTR <= 0;+ _, K% D, E& r( ~# h$ s
  8.                 elsif rising_edge(WCLK) then
    7 b- N  [3 {, b( F, K; C* G
  9.                         if WE = '1' and count<depth then
    ! _8 O% p  z" O$ n5 l/ C! M- A5 V. P& g
  10.                                 fifo_array(WR_PTR) <= DATA;
    # P( d) _/ r8 S$ E6 ^6 ^
  11.                                 -- move pointer
    . w: n3 j3 ^7 M' r  ^" n
  12.                                 if WR_PTR=fmax then
    ! ]) Y- D+ ~) W$ o/ [
  13.                                         WR_PTR <= 0;
    , i7 A# _8 w% u8 u9 m- f1 s# J0 j
  14.                                 else WR_PTR <= WR_PTR + 1;
    / {. q2 o8 h2 G0 P
  15.                                 end if;, }7 _7 o) ?/ S4 |& a! a4 o7 T& N! D0 X
  16.                         end if;
    % L9 J6 W* |+ K$ S
  17.                 end if;& Z* R3 P- l# m) p8 q! v4 F
  18.         end process;
    - _7 o8 U" w" ^) X8 h( D1 ~
  19.         FREAD: process (CLR, RCLK)
    " D: L' M! q" O: ]
  20.         begin
    ' b" M# Q$ ]& f! T! c  u1 B1 u
  21.                 if CLR = '1' then
    - s( @8 B" x" M0 b3 `
  22.                         RD_PTR <= 0;# B  f7 B. S+ z9 B, k/ i
  23.                 elsif falling_edge(RCLK) then
    & ]. q0 u; m. u7 X( q) ~
  24.                         if RE = '1' and count>0 then- `8 r9 |, p) Z7 A
  25.                                 Q <= fifo_array(RD_PTR);: x: }7 t9 T$ L
  26.                                 -- move pointer ( o$ g: i! _7 v2 z
  27.                                 if RD_PTR=fmax then 5 \2 E7 P: }  n9 ^3 f
  28.                                         RD_PTR <= 0; 9 c  d  H: w% ^, j! I$ W) r" K
  29.                                 else RD_PTR <= RD_PTR + 1;
    8 c$ n9 v/ O' D4 S! r) ~) H
  30.                                 end if;! t) B- b% Y# i8 v) X) V8 P
  31.                         end if;
    5 c' j3 b* n# `4 J
  32.                 end if;$ p  k. K6 }5 D8 L( ]
  33.         end process;
    , `) d0 u1 s+ v1 L" G7 S5 }
  34. end architecture;
複製代碼
7#
發表於 2009-7-4 00:42:31 | 只看該作者
印象中有个工具可以转vhdl 为 verilog,可以看看,或许有用
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

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

GMT+8, 2024-9-27 09:16 PM , Processed in 0.161009 second(s), 18 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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