|
module A2(& c0 I1 _; O+ q- c! h
input clk,
% c6 R% d* o- N$ m input [7:0] A, f. A+ m$ M( x: W- Y" k
input [7:0] B,
* J4 B* Z3 n7 b( `: c7 y! A+ S output reg [15:0] F5 f- c- C$ v* j( C9 {( Y
);4 k. f" \3 f4 `% w
reg [7:0] P;& X8 V; k5 ?7 o; t3 U1 X
reg [3:0] Cn=4'b1000; s4 y9 K d) ?1 y
reg [7:0] Y;4 I3 o; |7 ` R- b
reg C;
J+ P% D9 V F/ Y always @(posedge clk)begin
: p# | U- W& Z7 P9 m" p: H if(Cn==4'b1000)
& p5 E$ d) }$ ^( [1 k; @0 e4 h/ [2 u begin
0 o2 W* p! X9 a3 v P<=4'b0000;! Q* j) u9 X# x. [
Y<=B;8 b4 M) i9 f& c* A
Cn<=Cn-1;$ H0 D5 z Z+ l8 X
end+ x5 ~- i/ l5 g/ Z$ L' N
else if(Cn>=4'b0000)
6 N3 m; o6 {8 c7 V8 c( S8 X$ b! f begin
- w, l/ b5 I0 F$ }" F if(Y[0]==0)5 c4 w+ ?( c' Z2 n7 m# L
begin
. Z% F# u0 `6 K7 ? {P,Y}<={P,Y}>>1;, f" [4 K) ?, [( }* `; ^* @$ N' c
end X4 f. W4 S. g' G
else if(Y[0]==1)' A+ Y5 [" s+ _" C, |: M% Y P, G
begin" F, S' Q( p3 U6 C! H6 r: S% M7 ^
{C,P}<={C,P}+A;. l+ }# a5 d4 n+ R5 A/ b
{C,P,Y}<={C,P,Y}>>1;4 { y- l" e) z6 M) M' ^0 ]2 }$ M) x
end
: l% C' x) o6 w/ m, U Cn<=Cn-1;
8 a: ]% I7 F/ \; X( s0 v end3 M% q8 y) p* j3 r6 q* O
else . @5 w2 g) ]$ Z7 F7 f
begin9 w+ Y0 z7 B% m' @- \0 D- h5 K) E/ l
F<={P,Y};# E/ S) X" g% g: Y) i1 i
Cn<=4'b1000;2 U( i9 A. e: M, S. e* B
end
3 B: N; ~7 L3 G. w z end
+ [9 m; d2 I7 Q! H9 S( X) M/ n2 {endmodule |
|