-
Notifications
You must be signed in to change notification settings - Fork 0
/
mult.v
50 lines (47 loc) · 1.16 KB
/
mult.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2022/01/03 03:16:48
// Design Name:
// Module Name: mult
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mult(
input wire signed_mult_i,
input wire[31:0] opdata1_i,
input wire[31:0] opdata2_i,
input wire start,
output reg[63:0] result_o,
output reg ready_o
);
reg s;
reg temp;
always@(*)begin
if(start)begin
// signed mult
if(~signed_mult_i)begin
result_o = {32'b0, opdata1_i} * {32'b0, opdata2_i};
ready_o = 1'b1;
end
// unsigned mult
else begin
s = opdata1_i[31] ^ opdata2_i[31];
temp = opdata1_i[30:0] * opdata2_i[30:0];
result_o = {s, 1'b0, temp};
ready_o = 1'b1;
end
end
end
endmodule