|
module A2(/ F% }7 V, W! B% m8 f2 r2 ^) Q$ }
input clk,
+ y. }; J$ y7 b+ P input [7:0] A,
6 c7 ]0 f& J. ]6 K/ ?; T8 v input [7:0] B,% `% @! w9 ]4 _' S7 ?
output reg [15:0] F
+ m) z: T2 p. e+ I$ ?/ `9 c) D );
+ J) E' Q) v5 X; y reg [7:0] P;0 Z: M2 {& @& G4 ^5 }! F" }* o
reg [3:0] Cn=4'b1000;
" b% V4 r# C$ T# E3 }4 a% H* Z reg [7:0] Y;; \- r2 g. d+ R2 {: P# A+ ]
reg C;9 N) Y( \# T( u+ d2 G: b+ s
always @(posedge clk)begin
" a5 C$ w% J- [ if(Cn==4'b1000)# S* w2 O1 c4 _2 P+ n
begin
( d: B( P( ?) t2 Y* t& @% _- q P<=4'b0000;
8 O( c$ B! ~" p, X8 _' T$ { Y<=B;' x1 L/ V5 E/ v# v4 ]7 o/ S O4 P
Cn<=Cn-1;
& l3 }3 n( j# P' ], L0 A end
# ]' s; x" s- k+ C# G else if(Cn>=4'b0000)
( P) t5 B4 J& R0 V# d2 Y2 k: I$ b* ^ begin
* ~2 \$ m# `; P; n, d if(Y[0]==0)
; w! Y1 f8 y, j begin
( J# [* m2 Y* k' l" m {P,Y}<={P,Y}>>1;
# n0 q$ W! x1 F& ^, ?5 _+ D end
# Z- e6 X7 f: x4 s8 U( o/ l else if(Y[0]==1)
' z: l f1 u0 P) ^7 V3 i2 L begin& a5 V, E! g/ i0 t, v
{C,P}<={C,P}+A;% }& T! F9 P' P- {
{C,P,Y}<={C,P,Y}>>1;- x- | p G8 c* a! d- b9 p4 g' N
end
8 R0 Y; N% D3 o' ]+ k: I* \7 I Cn<=Cn-1;
$ ]& B9 v9 z6 P/ N/ y end
, b7 G+ Y) n6 F% S2 @ else
& \8 _* A8 n' i3 G5 r& O _5 Z. h8 j begin
, g( q7 l9 l5 }( `& f2 A9 j. B F<={P,Y};
1 y( b4 E: `& E6 A) u Cn<=4'b1000;
1 @7 ~# w: U& y. p" w' x end- K8 D! ~$ ^$ z7 z+ c) l# c; p
end
, e# A4 F* m- J" t! H! _" _endmodule |
|