-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphi_arithmetic.v
More file actions
54 lines (46 loc) · 1.57 KB
/
phi_arithmetic.v
File metadata and controls
54 lines (46 loc) · 1.57 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
// ============================================================================
// φ-ARITHMETIC UNIT — Zero-DSP48 Multiplication using φ² = φ + 1
// ============================================================================
//
// Key identities:
// φ × x = x + x_prev (ONE ADDER, 0 DSP48!)
// φ² × x = x + φ×x (TWO ADDERS, 0 DSP48!)
// φⁿ × x = n adders (ZERO DSP48 for any power!)
//
// Generated by TRI sacred-const phi-arith
// φ² + 1/φ² = 3 = TRINITY
//
// ============================================================================
`default_nettype none
module phi_arithmetic_unit #(
parameter WIDTH = 25
)(
input wire clk,
input wire rst,
input wire [WIDTH-1:0] x_in,
input wire [WIDTH-1:0] x_prev, // Previous value (Fibonacci sequence)
input wire valid_in,
output wire [WIDTH-1:0] phi_x, // φ × x
output wire [WIDTH-1:0] phi2_x, // φ² × x
output reg valid_out
);
// φ × x = x + x_prev (ONE ADDER!)
wire [WIDTH-1:0] phi_x_wire = x_in + x_prev;
// φ² × x = x + φ×x (TWO ADDERS!)
reg [WIDTH-1:0] phi_x_reg;
reg [WIDTH-1:0] phi2_x_reg;
always @(posedge clk) begin
if (rst) begin
phi_x_reg <= 0;
phi2_x_reg <= 0;
valid_out <= 1'b0;
end else begin
phi_x_reg <= phi_x_wire;
phi2_x_reg <= x_in + phi_x_wire; // x + (x + x_prev) = 2x + x_prev
valid_out <= valid_in;
end
end
assign phi_x = phi_x_reg;
assign phi2_x = phi2_x_reg;
endmodule
`default_nettype wire