dpbsh003h.vmd
2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**************************************************************/
/* Verilog module of datapath cell DPBSH003H */
/* Designed by Lin Yang VLSI Technology Oct. 20, 90 */
/* Designed by Linda J. Xu Feb. 11, 93 */
/* */
/* The following is the port description */
/* Data ports */
/* A : the input port */
/* B : the input port */
/* SEL : the input port */
/* Z : the output port */
/* Control ports */
/* INST_S : the switch A/B control signal */
/* Parameters */
/* WORDSIZE : the word size of the datapath cell */
/* NUMBER_OF_SHIFTS : the number of shift bits */
/* DELAY : the delay time from input to output */
/* BF : the with/without buffer flag */
/* 0 for without buffer; 1 for with buffer */
/**************************************************************/
module dpbsh003h(A, B, SEL, Z, INST_S);
parameter WORDSIZE = 8, NUMBER_OF_SHIFTS = 8, DELAY = 5, BF = 1;
input [WORDSIZE-1:0] A, B, SEL;
output [WORDSIZE-1:0] Z;
input INST_S;
reg [2*WORDSIZE-1:0] ZZ;
function [WORDSIZE-1:0] bsh;
input [WORDSIZE-1:0] A, B, SEL;
input switch;
integer i, shift, num_1, size;
begin
i = WORDSIZE;
shift = 0;
num_1 = 0;
if (WORDSIZE > NUMBER_OF_SHIFTS)
size = WORDSIZE - NUMBER_OF_SHIFTS - 1;
else if (WORDSIZE == NUMBER_OF_SHIFTS)
size = 0;
while (i>size)
begin
i = i - 1;
case (SEL[i])
'b1: num_1 = num_1 + 1;
'b0: if (num_1 < 1) shift = shift + 1;
default
begin
i = 0;
num_1 = 2;
end
endcase
end
if (WORDSIZE == NUMBER_OF_SHIFTS)
case (switch)
'b1: num_1 = num_1 + 1;
'b0: ;
default num_1 = 2;
endcase
if (num_1 < 1)
begin
bsh = ZZ[2*WORDSIZE-1:WORDSIZE];
end
else if (num_1 > 1)
begin
bsh = {WORDSIZE{1'b x}};
end
else
begin
ZZ = ({A,B} << shift);
bsh = ZZ[2*WORDSIZE-1:WORDSIZE];
end
end
endfunction
assign #DELAY Z = bsh(A, B, SEL, INST_S);
endmodule