-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResonant_Pulse_Controller.sv
More file actions
52 lines (45 loc) · 1.65 KB
/
Copy pathResonant_Pulse_Controller.sv
File metadata and controls
52 lines (45 loc) · 1.65 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
// Resonant_Pulse_Controller.sv
// License: CC-BY-NC 4.0
// Author: Jonathan Alan Reed
`timescale 1ns/1ps
module n2_mfc_core #(
// 1768.94 fs expressed as an integer count of 10-attosecond steps
parameter [31:0] TARGET_STEPS = 32'd176_894
)(
input logic clk, // 10-attosecond clock
input logic rst_n,
input logic trigger,
output logic [63:0] out_freq,
output logic snap_done
);
localparam [63:0] START_FREQ = 64'd70_700_000_000_000;
// Chirp: -4.73e24 Hz/s. In 10as, that's exactly 47,300 Hz.
localparam [63:0] CHIRP_STEP = 64'd47_300;
logic [63:0] freq_reg;
logic [31:0] step_counter;
enum {IDLE, CHIRP, DONE} state;
assign out_freq = (state == CHIRP) ? freq_reg : 64'd0;
assign snap_done = (state == DONE);
always_ff @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
state <= IDLE;
freq_reg <= START_FREQ;
step_counter <= 0;
end else begin
case (state)
IDLE: begin
if (trigger) state <= CHIRP;
freq_reg <= START_FREQ;
step_counter <= 0;
end
CHIRP: begin
freq_reg <= freq_reg - CHIRP_STEP;
step_counter <= step_counter + 1;
// Trigger exactly at step 176,894
if (step_counter >= TARGET_STEPS - 1) state <= DONE;
end
DONE: if (!trigger) state <= IDLE;
endcase
end
end
endmodule