module A2(: O) t2 y& s8 m* Q6 M7 u
input clk,
% L% B+ A( T) x input [7:0] A,
( R6 B7 O$ w7 q0 } input [7:0] B,6 v- B* ^% Z0 S+ Y- ?
output reg [15:0] F
* q" ~8 a9 v% W Y* f2 `0 A3 ^7 W );7 O+ A/ j2 e* Y1 L
reg [7:0] P;& F( T- k8 Q& C1 V
reg [3:0] Cn=4'b1000;3 d% M, {9 Q+ p3 b$ m& W
reg [7:0] Y;
4 l f* D" w* y& f' A" P reg C;
9 R; D2 h7 s5 S0 S! s always @(posedge clk)begin' B& e3 b: H: n" k( J3 d
if(Cn==4'b1000)7 ?4 S8 |. ?* m1 F
begin. f Q$ l. M) a3 ?/ ~
P<=4'b0000;
7 v C3 }: l% @9 x Y<=B;
" k# P; N& B& v5 S3 X" G9 _ Cn<=Cn-1;( `5 V7 p8 |% w4 \. y5 A3 i
end: Y9 ^0 n9 \; T( y# l
else if(Cn>=4'b0000)% o0 e+ y2 |. M. a6 F
begin4 n# C& i& |, _
if(Y[0]==0)
% [; Z! h" w5 p; _4 _: A& J begin
+ T) I1 Z- M& U& W! e {P,Y}<={P,Y}>>1;
7 u- v3 L# q8 @. f end
$ Z1 t7 Z3 C% s; K else if(Y[0]==1)7 H4 S2 F" F: m6 t; v
begin& G* Y; R4 T" h1 g4 F
{C,P}<={C,P}+A;
2 Z* H% _" m0 ?- G1 u! j. E3 P {C,P,Y}<={C,P,Y}>>1;
1 U/ P4 V' v, A, X+ `3 n3 F5 G end
. n6 g n2 j8 C Cn<=Cn-1;
0 v$ k1 z/ O" Z1 h$ s end
& m, G* I2 m, @- [ else
( ^% X8 R. q4 l* n. _8 T, s begin
' i* s# x6 K! C F<={P,Y};
5 f- ~+ n0 [* @8 G0 z) y# x1 G% J Cn<=4'b1000;# A% i5 f l% ~8 n! ^) _
end, f9 J9 \& k$ x* s6 }
end% U' u' O B5 q, l% s. y+ m. }$ G
endmodule |