|
小弟我是新手 想把呼叫function函數改成呼叫task 但不知道是哪邊有問題會一值出現 希望高手們能幫我一下
2 J, c. C2 N K我猜應該是在always和呼叫連結不起來的問題 卻不知道如何下手) k, |9 l7 G9 A7 g$ b3 F: n( I# H& ?
ncvlog: *W,FAAOP1 (shift.v,49|7): task or function call does not specify all formal output arguments [10.2.2][10.3(IEEE)].
* d1 r5 B* s% W' y1 ooutput [7:0] mout;( F& d( @/ I$ g/ E6 D
|8 }+ _ X4 Q; X1 h
ncvlog: *W,FAAOP2 (shift.v,60|16): Formal output argument 'mout' is absent in the task or function call identified by the previous error message [10.2.2][10.3(IEEE)].0 s" n7 p2 t' c! e$ H9 a) K1 e+ x% ]
multdiv8(right,indata,mout);
: j( t" g( ~. a0 \) \* Z |5 K# Y( G5 r- W
ncvlog: *W,FAAOP1 (shift.v,51|7): task or function call does not specify all formal output arguments [10.2.2][10.3(IEEE)].4 Z; F/ ^1 H& k
output [7:0] mout;
7 t6 Y5 Q6 q/ E1 g# b9 u0 c& F8 o
5 e- V3 f) q( n4 S8 G6 a3 h2 A
5 |& j S0 t* {, r2 Q1 ]原本的code:
9 c6 K8 [# W; f1 A/ {/ j( D1 `) H" q1 l u: x. E
module shift(indata,qout,mout);
/ P9 z, J) _5 J6 T" ?( V# R7 s( m4 w; Y. ~% j+ Q, Z4 ^: j
output [7:0] qout;
. ~; |; ?2 O+ d! _) `, Doutput [7:0] mout;
" T5 h1 O. I9 S L& sinput [7:0] indata;
+ P; G- z' @! }! p9 F
( O1 `. R+ ?% o% b( h) v; Ureg [7:0] qout;
% i/ b; F+ p) f0 u( r3 Breg [7:0] mout;$ S8 u: \2 g7 S' X" s, i' }! {: f
parameter left=1;
5 p2 w9 e, }$ F5 _/ r0 v) oparameter right=0;( B0 D7 z" h! c O: V' J
) M3 V& q8 M. r6 w& walways@(indata)+ y; P! ]4 R( z) k0 @4 i3 W. j6 d
0 b+ ]( r# I" p T U6 [begin% K0 p/ R2 @& T8 F8 G1 o; A
4 ^ V, u" R5 ~. f, d' k8 D9 [
mout=multdiv8 (left,indata);2 E' n* U# Z, E0 U* j! t2 d' J
qout=multdiv8 (right,indata);% \0 x. V7 `% ? J5 |& h
: ]: H# }6 o& O( \9 J0 `
end/ M0 d4 s. s* ~0 k* Q- \
$ `7 Q, Z2 l& a: m q+ }7 Hfunction [7:0] multdiv8;/ l6 e7 t: |& m' z- q
8 h" _* h6 k) ?! p& w' Q8 F
input fcn_left :
$ s2 T; [1 k. e5 V9 _( c. Einput[7:0] fcn_in;6 V1 |! Q+ [) E! V8 v |
begin
8 v u8 D/ }' t- X multdiv8=(fcn_left==1)?(fcn_in<<3): (fcn_in>>3);0 \% S P! w, I. L6 o" u) n
end' m* U1 y1 p6 P1 }
endfunction& ]- z/ v$ w* w
) p6 \4 ], |3 ^0 M
endmodule
: t. v; T1 |5 v: i0 X9 e4 T4 f" ^& D9 ]1 G- H/ v0 I3 v
以下是我自己寫的
. q6 i8 n9 |: W- w$ Y6 }. Z% |
9 P2 B; t, V6 m% U- _0 s- v% Fmodule (qout, mout,indata);/ | u( l; X$ |6 Z+ h9 _/ r
; t8 T) ~# A6 A; `; n% D$ P: Koutput [7:0] qout;
# M/ d+ {$ k8 Y' s9 t& loutput [7:0] mout;' r" p" C- P5 U4 q4 h& X* P7 u; Y
input [7:0] indata;+ m, p$ C& t% u
reg [7:0] qout;
) b( `* ]& Q0 y# y5 Sreg [7:0] mout;
+ D+ ^, Y3 d B8 C8 s0 w$ [parameter left=1;/ e5 p8 J8 R! h, n( }
parameter right=0;
& I# S* [& B( T8 }+ h2 G# O2 }
3 A( g) g" b0 b- l5 L- |always@(indata) begin
$ q7 P1 O* C6 e( M, Q8 K/ d3 F! C( F0 I2 f/ W& i1 p/ o0 X
multdiv8 (left,indata,qout); P# M: o: A! d7 V$ V
multdiv8 (right,indata,mout);
. k' Q/ A( t! [* ?- n N# U" @! O# r$ x' E* ^0 m5 Z: _) [
end* E) B) d5 O8 r! n$ Z
3 t4 L) L( t$ B, j( I- k6 wtask multdiv8;7 n( y% w6 N5 W9 I. g, Y
+ w8 i3 D. a. C9 S1 f; T7 K
input fcn_left;( y, S* p" K: S, T& S
input [7:0] fcn_in;4 ~5 \2 s$ q- ]9 B3 B
output [7:0] qout;3 ]8 {1 Y/ c( a% w
output [7:0] mout;1 r5 l; A3 e, \' K+ Y9 I( X0 F6 ~
3 Q7 ~9 p4 o1 M" ?$ b9 m: q$ V6 D- Z
if (fcn_left==1)/ V0 u8 x9 l2 j/ N$ N5 I& U' `
qout=fcn_in<<3;
$ a& ~; p$ j1 z+ Felse% b3 L3 J( e7 d$ n+ m, Z
mout=fcn_in>>3;
3 t% u2 C/ p% E( C. N! ?: @! b. k Y: E: |( d% w) Q
endtask & [0 z8 i; K0 n# u6 ^2 H
endmodule |
|