-
Notifications
You must be signed in to change notification settings - Fork 1
/
booth_step_mult.v
58 lines (50 loc) · 1.16 KB
/
booth_step_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
51
52
53
54
55
56
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:09:29 10/29/2016
// Design Name:
// Module Name: booth_step_mult
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module booth_step_mult(
input wire [7:0] A_in,
input wire [7:0] M,
input wire [8:0] Q_in,
output wire [7:0] A_out,
output wire [8:0] Q_out
);
reg [7:0] A_temp;
reg [8:0] Q_temp;
wire [7:0] A_sum = A_in + M;
wire [7:0] A_sub = A_in + ~M +1;
always@(A_in, M, Q_in, A_sum, A_sub)begin
case(Q_in[1:0])
2'b00, 2'b11: begin
A_temp ={A_in[7], A_in[7:1]};
Q_temp = {A_in[0], Q_in[8:1]};
end
2'b01:begin
A_temp={A_sum[7], A_sum[7:1]};
Q_temp={A_sum[0], Q_in[8:1]};
end
2'b10:begin
A_temp ={A_sub[7], A_sub[7:1]};
Q_temp = {A_sub[0], Q_in[8:1]};
end
endcase
end
assign A_out=A_temp;
assign Q_out=Q_temp;
endmodule