|
刚接触Verilog不久,需要做个FPGA解二阶微分方程。
# j5 P# R, g! _: k9 a- A我用欧拉法解得,但调用IP核总是出毛病
0 I3 B# g/ Z6 k, ~/ k比如
" O4 o% B) m! S2 U/ J( gError (10170): Verilog HDL syntax error at Eeler.v(22) near text "add_sub_inst"; expecting "<=", or "="/ ]+ T( f: ?5 y; h8 `/ |+ }2 \
Error (10149): Verilog HDL Declaration error at Eeler.v(25): identifier "mult_inst" is already declared in the present scope
( h. `) r$ l* CError (10149): Verilog HDL Declaration error at Eeler.v(26): identifier "add_sub_inst" is already declared in the present scope
2 Z, a) _( d+ k& U3 {/ a! N) o) \Error (10149): Verilog HDL Declaration error at Eeler.v(27): identifier "mult_inst" is already declared in the present scope- ^ A8 H% W8 q; O+ _9 U
Error (10149): Verilog HDL Declaration error at Eeler.v(28): identifier "add_sub_inst" is already declared in the present scope
; y* z5 y4 A7 B( o# D3 y) |( o; d% OError (10170): Verilog HDL syntax error at Eeler.v(30) near text "$display"; expecting "endmodule"5 C# e( w7 r P3 P) O3 c2 t
Error (10759): Verilog HDL error at Eeler.v(30): object x declared in a list of port declarations cannot be redeclared within the module body& a0 J9 O, V3 [# ?9 O
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
7 \4 r/ i) e$ Y6 vError (10759): Verilog HDL error at Eeler.v(30): object z declared in a list of port declarations cannot be redeclared within the module body/ Q, r4 k: F$ I% W8 y K1 H9 V! W
Error (10170): Verilog HDL syntax error at Eeler.v(30) near text ")"; expecting ";"5 H# W' `# c; V( y# o; G4 ~
Error (10112): Ignored design unit "Eeler" at Eeler.v(1) due to previous errors
, a& V( S0 w0 q' K0 c编的源程序这样
1 `9 M. I' t1 Z* z* X, N, v: h s. Emodule Euler" @0 T- q8 `8 Y3 j4 @- o$ S
(
4 j6 J, b, B; s! h7 z4 rinput wire clk,2 _# O( a' I9 P) w
input wire [31:0] x, //定义输入量,单精度32位浮点数6 P& D# m3 ^5 s6 R5 w: w
input wire [31:0] y,
4 ~0 x- t) c0 G9 i8 F( l. \3 `5 ~input wire [31:0] z,0 ]9 v3 z( ^, j# Q4 f' O5 o
input wire [31:0] h,+ C- u2 ]! ~% s7 R0 E J
output wire n1
. _9 a% I4 C6 K);1 C( M. L/ \4 x6 E/ C9 n6 r
; t5 Z, \2 S; k4 f
0 N, W& O' t- a4 i
9 s, |+ h" o1 ^ l8 e; ]- I6 o9 G; x. x3 _5 m7 j
reg[31:0] z11;
K6 ] ^. ?/ c& |# A, o5 jreg[31:0] z1;- C# ^- ~2 S9 p v1 J& `& u
reg[31:0] y11;
( |- R n6 e( Z, ~reg[31:0] y12;# [% k6 k* ^/ m$ S* j
integer n;
3 ~2 p! |1 }1 I$ {
8 S- e) f ]: e. Z* [8 c0 R5 z, L# _4 S" a
initial
7 j9 C$ Z! \$ M$ `' [2 o //开始迭代
. H' ~1 Q; h5 ^" dfor (n = 0; n < 10; n=n+1)
% F% T1 j8 ?3 @7 l( {( v" gadd_sub add_sub_inst( .clock ( clk), .dataa ( x ),.datab ( h ),.result ( x )); " [* e* N" o# n" k {1 p1 s
mult mult_inst( .clock ( clk ), .dataa ( x),.datab ( z ),.result ( z11 )); " F+ ^7 Q$ T F( V# d0 z2 i
add_sub add_sub_inst( .clock ( clk), .dataa ( z11 ),.datab ( y ),.result ( z1 ) ); 8 W5 `" i3 p& ^4 ]* `: C
mult mult_inst( .clock ( clk ), .dataa ( h),.datab ( z),.result ( y11 ) ); - W; d" @* \2 L* s5 U" x
add_sub add_sub_inst( .clock ( clk), .dataa ( y ),.datab ( y11 ),.result ( y ) );
# u* _$ I5 }8 o( vmult mult_inst( .clock ( clk ), .dataa (h),.datab ( z1 ),.result ( z12 ));
) u9 [% I9 L/ Q" ]" e. kadd_sub add_sub_inst( .clock ( clk), .dataa ( z ),.datab ( z12 ),.result ( z ) );
4 x/ r6 i4 r, x
# {$ K9 n' R: Y1 T* \
. t5 x: w S& ?9 z6 B" s$display ("n=%d x=%b y=%b z=%b\n",n,x,y,z );8 {2 d2 F: g3 ]% d8 s# }: i
endmodule1 ~7 s) j5 r4 i+ D2 {9 t" R, \+ z
想问一下,是IP调用有问题吗?还是IP核不能在循环或函数里调用 |
|