|
刚接触Verilog不久,需要做个FPGA解二阶微分方程。
! Y0 y( \+ z7 r# y" e2 e2 c我用欧拉法解得,但调用IP核总是出毛病# P" ]! O w V/ f
比如2 E1 l) H! E& K) Q2 I, D0 H2 p
Error (10170): Verilog HDL syntax error at Eeler.v(22) near text "add_sub_inst"; expecting "<=", or "="
" ]" _/ p: J) a# J+ e0 r: a: kError (10149): Verilog HDL Declaration error at Eeler.v(25): identifier "mult_inst" is already declared in the present scope4 o) a7 X7 \1 R* \' K
Error (10149): Verilog HDL Declaration error at Eeler.v(26): identifier "add_sub_inst" is already declared in the present scope
5 w3 T) \9 x& v9 _9 NError (10149): Verilog HDL Declaration error at Eeler.v(27): identifier "mult_inst" is already declared in the present scope! j1 F/ j+ D( j6 k
Error (10149): Verilog HDL Declaration error at Eeler.v(28): identifier "add_sub_inst" is already declared in the present scope
! w1 u- T0 c1 |% H7 v! dError (10170): Verilog HDL syntax error at Eeler.v(30) near text "$display"; expecting "endmodule"
/ ]5 y1 h( Z- 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
' D+ i: {% J! kError (10759): Verilog HDL error at Eeler.v(30): object y declared in a list of port declarations cannot be redeclared within the module body
/ z) W# G4 j! tError (10759): Verilog HDL error at Eeler.v(30): object z declared in a list of port declarations cannot be redeclared within the module body
0 l" a8 r8 m; CError (10170): Verilog HDL syntax error at Eeler.v(30) near text ")"; expecting ";", H3 T5 Y) R; i$ }( w6 t
Error (10112): Ignored design unit "Eeler" at Eeler.v(1) due to previous errors
/ T2 B3 b7 {0 k6 y编的源程序这样
0 y. s- q9 }5 A4 O t& qmodule Euler& f9 V% }0 H: \5 X ~
(
+ { `/ ]5 a' x! x) M Pinput wire clk,* j( A5 g) [9 k7 x" s6 Z- \
input wire [31:0] x, //定义输入量,单精度32位浮点数
: X0 Y' m6 e* _0 M# U* ?input wire [31:0] y,
* }- L/ M1 L8 t _8 g: t2 oinput wire [31:0] z,+ y2 I9 J9 t/ Q# l& m
input wire [31:0] h,
7 L5 k8 m* @. j9 v2 B) d5 youtput wire n1! h! [! G9 a( \0 P3 H* I, E3 j6 F
);5 R' }; I% u k8 Y* X: K: l2 y$ a
1 Z! y2 b& m/ A# Q
4 R5 R4 O6 p6 S s0 Q' V: q
4 N @6 A. _: ~5 C5 N
6 x0 A. S( A3 R0 Yreg[31:0] z11;# x0 N1 }4 e, K* l* o$ r
reg[31:0] z1;, c8 H' d- Y8 A, ^
reg[31:0] y11;
! p2 A( f3 [3 _! n6 J% preg[31:0] y12;9 F0 S8 G% d& @; ]
integer n;
6 J7 s' e- \0 J
9 @4 ]% p9 ]% S' D) E& k$ y0 H+ ~ K6 n- c- T/ [
initial
1 D, Y2 W. q7 L //开始迭代
9 u* r( C% _1 o7 \$ Cfor (n = 0; n < 10; n=n+1) 7 }+ Q# W, U( d x) N( V
add_sub add_sub_inst( .clock ( clk), .dataa ( x ),.datab ( h ),.result ( x ));
6 [* O. Y8 y" X; w- Xmult mult_inst( .clock ( clk ), .dataa ( x),.datab ( z ),.result ( z11 )); / W, \9 ]5 t/ i$ l
add_sub add_sub_inst( .clock ( clk), .dataa ( z11 ),.datab ( y ),.result ( z1 ) );
+ _6 }( E2 K" v( M7 @mult mult_inst( .clock ( clk ), .dataa ( h),.datab ( z),.result ( y11 ) );
7 f; M$ A- g2 q5 [6 O# ]3 u1 iadd_sub add_sub_inst( .clock ( clk), .dataa ( y ),.datab ( y11 ),.result ( y ) ); 3 N) f" ?, M1 B* a: P5 J
mult mult_inst( .clock ( clk ), .dataa (h),.datab ( z1 ),.result ( z12 )); " I' B, ]" O; e
add_sub add_sub_inst( .clock ( clk), .dataa ( z ),.datab ( z12 ),.result ( z ) );
0 \$ W- y7 u6 }0 p6 @9 x* x) M: U, v: t+ k7 i- y
$ r( A5 e) K: E( p: s4 E$display ("n=%d x=%b y=%b z=%b\n",n,x,y,z );
! P/ J6 f7 b9 r. a* z; f Lendmodule- y. p+ s3 R7 [* n0 H( t
想问一下,是IP调用有问题吗?还是IP核不能在循环或函数里调用 |
|