|
module A2(- o6 t# a# p; ~
input clk,
0 O$ `; }0 Y; O+ j( { input [7:0] A,
+ Y% S/ t/ u( z input [7:0] B,# ]+ F6 T6 t7 _; X9 u5 v9 B- b' m
output reg [15:0] F6 \ ?3 X [# G5 A1 f& i+ A3 p
);
$ }; u+ f( Y( k: x* R! L$ X5 q4 l reg [7:0] P;! N/ G y# p' O
reg [3:0] Cn=4'b1000;
$ a2 X. n# v6 \: s+ a) r reg [7:0] Y;
" b1 K4 L8 W- @6 r( P reg C;
9 h5 F' P% V. E6 z always @(posedge clk)begin e( C& ?3 R( h
if(Cn==4'b1000)
$ y3 V. t* v8 Y" Q z% |' k8 O begin5 T# ?1 G8 W4 k- T$ ?# }9 k, `# t
P<=4'b0000;
) d- k2 K3 u; w4 U Y<=B;
7 H- Q1 J6 ~# U6 D( L7 |, w Cn<=Cn-1;
" }( G/ o: v; d: G' `: Q end9 \8 c* S3 S! S, N0 P
else if(Cn>=4'b0000)
3 [+ g& Y% P" U, p0 ^7 ^ Y begin+ p9 T J @- n$ f2 p( z/ B; N
if(Y[0]==0)6 ^* R7 {, L! _" ~8 `, B! X, W" @
begin, X# Z) |; q; P% ~
{P,Y}<={P,Y}>>1;
1 Z9 Z- z: J8 H! f end! r" R# g, U7 Y
else if(Y[0]==1): @3 x0 ]8 s, P
begin1 e3 t: B5 C, ~0 c* W
{C,P}<={C,P}+A;
/ d! ?% ~7 V, A! e! X& X {C,P,Y}<={C,P,Y}>>1;. i6 s6 k' a) Q; p# X& s
end1 A5 o1 p) q3 ]+ L3 m% D# C
Cn<=Cn-1;0 l- M, g2 p6 G) H5 l
end
3 N3 q4 q8 F+ i1 H else : b, h* o2 l0 w: U! ^( k( D
begin" w: f; v; o8 {' m! [
F<={P,Y};0 G/ U N+ S* f: \, F8 c
Cn<=4'b1000;7 g7 Y2 M3 s' F& `2 }$ C" z
end
; l; B# r$ {; a end' d+ C* Z' y1 z
endmodule |
|