|
module sh(a,division,out);
% G4 n0 l; R# ^2 k3 S! s4 \
8 j( n& ^# i) r# J, ~; Finput [7:0] a;+ W1 I# s5 q/ k3 e0 y' D# t
input division;& f& w$ Q3 N* R. h6 | {" Y
output [10:0] out;9 Y1 x, `% ~) _% ?, J( ^
reg [10:0] out;( {2 p* |2 u6 _2 i
wire [4:0] div_8_out;
( S/ N4 ]; I& `3 dwire [10:0] mult_8_out ;. J% A5 s g7 o+ e. T/ p4 o2 _
2 v, T# m( V( R3 C' C0 \1 G jassign div_8_out = a>>4'b0011;' ~/ g i" j# R p
assign mult_8_out = a<<4'b0011;* K; O y# \8 e6 s
0 j4 X# [1 x$ R4 \. E7 xalways@(*)
: J$ i( p9 I- @1 Obegin X, U: _$ C5 j. h. ?$ h
if(division)& Y, `$ D1 V2 q- [) Z( k% ]$ @- R
begin5 q9 c2 i0 x" k3 V/ }) |; r, ~/ |
out ={6'b0,div_8_out};- c2 m0 l; G+ L
end
# i5 j9 H; R0 G8 Z; Felse' k% O( M p# a y+ N4 { Y
begin7 n* V8 G C _# D+ s
out =mult_8_out ;
4 N0 o1 B7 y8 a; F end
1 H3 T( z2 m- A" Vend
7 S5 L. Z8 P4 b' y1 @5 e+ E3 N* [ I% T, A- E& b5 N
endmodule- Z- w, M& v5 V* k/ E& R
; @0 |+ a' C' H: w6 m& s
[ 本帖最後由 masonchung 於 2008-12-22 02:22 PM 編輯 ] |
|