-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMul.v
99 lines (77 loc) · 1.6 KB
/
Mul.v
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
module Mul(out,a,b);
input [7:0] a;
input [7:0] b;
output [7:0] out;
reg [7:0] temp0;
reg [7:0] temp1;
reg [7:0] temp2;
reg [7:0] temp3;
reg [7:0] temp4;
reg [7:0] temp5;
reg [7:0] temp6;
reg [7:0] temp7;
wire [7:0] temp_x01;
wire [7:0] temp_x02;
wire [7:0] temp_x04;
wire [7:0] temp_x08;
wire [7:0] temp_x10;
wire [7:0] temp_x20;
wire [7:0] temp_x40;
wire [7:0] temp_x80;
wire [7:0] temp_x0;
wire [7:0] temp_x1;
wire [7:0] temp_x2;
wire [7:0] temp_x3;
wire [7:0] temp_x4;
wire [7:0] temp_x5;
assign temp_x01 = a;
xtime x02 (a, temp_x02);
xtime x04 (temp_x02, temp_x04);
xtime x08 (temp_x04, temp_x08);
xtime x10 (temp_x08, temp_x10);
xtime x20 (temp_x10, temp_x20);
xtime x40 (temp_x20, temp_x40);
xtime x80 (temp_x40, temp_x80);
always @(a or b or temp_x01 or temp_x02 or temp_x04 or temp_x08 or temp_x10 or temp_x20 or temp_x40 or temp_x80)
begin
if( b[0] == 1'b0 )
temp0 = 8'b0;
else
temp0 = temp_x01;
if( b[1] == 1'b0 )
temp1 = 8'b0;
else
temp1 = temp_x02;
if( b[2] == 1'b0 )
temp2 = 8'b0;
else
temp2 = temp_x04;
if( b[3] == 1'b0 )
temp3 = 8'b0;
else
temp3 = temp_x08;
if( b[4] == 1'b0 )
temp4 = 8'b0;
else
temp4 = temp_x10;
if( b[5] == 1'b0 )
temp5 = 8'b0;
else
temp5 = temp_x20;
if( b[6] == 1'b0 )
temp6 = 8'b0;
else
temp6 = temp_x40;
if( b[7] == 1'b0 )
temp7 = 8'b0;
else
temp7 = temp_x80;
end
eightbitxor x0 (temp_x0, temp0, temp1);
eightbitxor x1 (temp_x1, temp2, temp3);
eightbitxor x2 (temp_x2, temp4, temp5);
eightbitxor x3 (temp_x3, temp6, temp7);
eightbitxor x4 (temp_x4, temp_x0, temp_x1);
eightbitxor x5 (temp_x5, temp_x2, temp_x3);
eightbitxor x6 (out, temp_x4, temp_x5);
endmodule