-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpe.v
64 lines (57 loc) · 1.51 KB
/
pe.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
//
// Verilog Module lab1_lib.PE
//
// Created:
// by - pelegse.UNKNOWN (SHOHAM)
// at - 14:57:07 01/24/2024
//
// using Mentor Graphics HDL Designer(TM) 2019.2 (Build 5)
//
`resetall
`timescale 1ns/10ps
module pe#(
parameter DW = 8,
parameter BW = 32
)
(
input clk_i,
input reset_ni,
input start_bit_i,
input [DW -1:0] input_a,
input [DW -1:0] input_b,
output reg [DW-1:0] out_a,
output reg [DW-1:0] out_b,
output reg [BW -1:0] out_accumulator,
output reg out_of
);
// Temporary variables to hold in module information
wire [2*DW -1:0] mult_result;
reg [BW-1:0] accum_sig;
reg of_sig;
assign mult_result = (input_a * input_b);
always @(posedge clk_i , negedge reset_ni) begin : seq_mul_oper
if (!reset_ni) begin
// Reset the accumulator to 0
of_sig <= 0;
accum_sig <= 0;
out_a <= 0;
out_b <= 0;
out_of <= 0;
out_accumulator <= 0;
end else if (start_bit_i) begin
// Multiply the inputs
{of_sig,accum_sig} <= accum_sig + mult_result;
out_a <= input_a;
out_b <= input_b;
out_accumulator <= accum_sig;
out_of <= of_sig | out_of;
end else begin
of_sig <= 0;
accum_sig <= 0;
out_a <= 0;
out_b <= 0;
out_of <= 0;
out_accumulator <= 0;
end
end
endmodule