|
刚接触Verilog不久,需要做个FPGA解二阶微分方程。& E! w( V2 Z4 o9 t8 r
我用欧拉法解得,但调用IP核总是出毛病+ B7 y2 C# ^* Y1 R' ]# N2 V' A, x! l- e& z
比如
+ z1 j3 D6 [, c% [ M/ lError (10170): Verilog HDL syntax error at Eeler.v(22) near text "add_sub_inst"; expecting "<=", or "="
7 |. X% i/ E4 K/ w' [9 y$ mError (10149): Verilog HDL Declaration error at Eeler.v(25): identifier "mult_inst" is already declared in the present scope X% z, c2 a/ V7 \" S1 n
Error (10149): Verilog HDL Declaration error at Eeler.v(26): identifier "add_sub_inst" is already declared in the present scope
8 B, h# m* q4 w6 t/ S: P" SError (10149): Verilog HDL Declaration error at Eeler.v(27): identifier "mult_inst" is already declared in the present scope
7 Y; u' h9 G/ o& C- [3 v D% nError (10149): Verilog HDL Declaration error at Eeler.v(28): identifier "add_sub_inst" is already declared in the present scope
9 [0 y% `4 M. T4 J% a5 n- v/ AError (10170): Verilog HDL syntax error at Eeler.v(30) near text "$display"; expecting "endmodule"
) B2 w9 `) k+ I) x3 @1 MError (10759): Verilog HDL error at Eeler.v(30): object x declared in a list of port declarations cannot be redeclared within the module body
6 o$ b6 e! r- @( t) N1 ~Error (10759): Verilog HDL error at Eeler.v(30): object y declared in a list of port declarations cannot be redeclared within the module body
- o B0 p( H8 X" }" DError (10759): Verilog HDL error at Eeler.v(30): object z declared in a list of port declarations cannot be redeclared within the module body# L8 a# z9 {' x. K+ I4 x6 k
Error (10170): Verilog HDL syntax error at Eeler.v(30) near text ")"; expecting ";"9 S" W8 M8 V# G; }# P7 r& ^) V0 h
Error (10112): Ignored design unit "Eeler" at Eeler.v(1) due to previous errors; f4 `7 R% @% {# t
编的源程序这样" R k! y( L0 o/ h+ L/ J. ?
module Euler2 Q0 B# d+ _0 E, s1 l$ {
(1 g% t. X; D1 j6 C; Y1 Y1 H) p
input wire clk,
o7 E- r' Z2 }; a) K* x; y, ^input wire [31:0] x, //定义输入量,单精度32位浮点数
7 X# j; Z+ C$ q0 [4 b+ u3 U% L k, Iinput wire [31:0] y, 7 r+ b" ?! c% `# q/ B
input wire [31:0] z,
, w# M4 A, P; n# y1 j4 Q. M3 J- Sinput wire [31:0] h,
$ I8 l- U# P( v0 L9 g9 ]) Loutput wire n1
8 ]! ?9 f6 m; Q( J& L1 e5 D" ^( e);
% v9 m5 l* @) Q1 H! l, \( F$ V1 G# `) e- u/ w: N
* t- l! j- S# r
. [" _* L4 ]( Y1 {6 @3 v" j( G0 e1 Y' K& N1 N* k" \; y' `3 D0 n9 w
reg[31:0] z11;- y0 `. p! B1 k3 w5 U
reg[31:0] z1;
7 i# t9 L) i% n/ p% Q' areg[31:0] y11;4 p" _, {$ s' `/ m5 f; F
reg[31:0] y12;
1 X; I9 P0 d6 a' Zinteger n;
f0 q; R3 y- ~# B- V3 u3 t( z. L1 a+ H# b7 r q: y; I
$ Z0 V. w+ i& Q. z0 d0 P4 w
initial
6 A- o3 Z9 i3 b X //开始迭代# {/ ^1 p, T: n* Z/ P
for (n = 0; n < 10; n=n+1) 5 s2 L7 m0 i# w% E A( V8 ?' h
add_sub add_sub_inst( .clock ( clk), .dataa ( x ),.datab ( h ),.result ( x )); * R& {( {( F6 h9 V4 ]) p5 c
mult mult_inst( .clock ( clk ), .dataa ( x),.datab ( z ),.result ( z11 )); 7 w6 } z' C) Y8 p9 w# L
add_sub add_sub_inst( .clock ( clk), .dataa ( z11 ),.datab ( y ),.result ( z1 ) );
' h$ \1 R3 _9 Z" z B8 mmult mult_inst( .clock ( clk ), .dataa ( h),.datab ( z),.result ( y11 ) ); " v0 U- B. l0 z$ J
add_sub add_sub_inst( .clock ( clk), .dataa ( y ),.datab ( y11 ),.result ( y ) ); 3 e7 y4 I+ F! Q" \9 `
mult mult_inst( .clock ( clk ), .dataa (h),.datab ( z1 ),.result ( z12 )); 9 ]( w; Q) O7 {+ n8 \: i& P; D. |
add_sub add_sub_inst( .clock ( clk), .dataa ( z ),.datab ( z12 ),.result ( z ) );
4 O- G& j) X$ a! m) W$ a- H
, f8 ^ O* h$ J; `, Q: s& k5 t' N9 U& [# F
$display ("n=%d x=%b y=%b z=%b\n",n,x,y,z );
; n! x6 X5 x X8 G* }0 [) G+ b! u6 dendmodule" Z2 `0 s8 z4 ^2 {2 M% Y! k- U. ?
想问一下,是IP调用有问题吗?还是IP核不能在循环或函数里调用 |
|