iTranslated by AI
Implementing the Dirac Equation on an FPGA (STEP 1): Running the m=0 version on Tang Nano 4K
In the previous chapter, I established an experimental plan.
This time, I will execute STEP 1.
🎯 Goal of STEP 1
Implement the 1D Dirac equation with m = 0 on a Tang Nano 4K using:
- Fixed-point arithmetic (Q1.15)
- Sequential update method
- BRAM storage
- UART output
Success criteria:
- Norm does not diverge significantly
- Wave packet propagates linearly in both directions
- Norm is output periodically via UART
🧠 m=0 Only for Now
First, let's simplify.
No mass term.
As seen in Processing:
- No Zitterbewegung
- Linear dispersion only
First, I will physicalize this part.
🧮 Fixed-Point Design
Format: Q1.15
- 16-bit signed
- 1 bit sign
- 15 bits fractional
Scaling:
real_value = fixed_value / 32768
🧱 Architecture (Minimal Configuration)
BRAM ψ storage
↓
Address counter
↓
Finite difference calculation
↓
dt multiplication
↓
Addition update
↓
Write back
↓
UART output (norm)
Sequential update:
Several clock cycles per grid point.
🔧 Verilog Minimal Configuration (STEP 1)
- For minimal verification
- Exclusive for m=0
- N=64 fixed (small and safe)
dirac_step1.v
module dirac_step1(
input wire clk,
input wire rst,
output wire tx // UART TX
);
parameter N = 64;
parameter DT = 16'sd100; // dt fixed-point (adjustable)
// ψ real and imaginary parts (2 components)
reg signed [15:0] psi_re [0:N-1][0:1];
reg signed [15:0] psi_im [0:N-1][0:1];
reg [6:0] i;
reg [3:0] state;
reg signed [15:0] d_re0, d_im0;
reg signed [31:0] temp;
// UART
reg [31:0] norm_accum;
reg start_uart;
wire uart_busy;
uart_tx uart_inst(
.clk(clk),
.start(start_uart),
.data(norm_accum[15:8]), // Simple output
.tx(tx),
.busy(uart_busy)
);
always @(posedge clk) begin
if (rst) begin
i <= 1;
state <= 0;
end else begin
case(state)
0: begin
// Difference calculation (central difference)
d_re0 <= (psi_re[i+1][1] - psi_re[i-1][1]) >>> 1;
d_im0 <= (psi_im[i+1][1] - psi_im[i-1][1]) >>> 1;
state <= 1;
end
1: begin
// Multiply by dt
temp <= d_im0 * DT;
psi_re[i][0] <= psi_re[i][0] + (temp >>> 15);
temp <= d_re0 * DT;
psi_im[i][0] <= psi_im[i][0] - (temp >>> 15);
state <= 2;
end
2: begin
i <= i + 1;
if (i == N-2) begin
i <= 1;
state <= 3;
end else begin
state <= 0;
end
end
3: begin
// Norm calculation
norm_accum <= 0;
state <= 4;
end
4: begin
norm_accum <= norm_accum
+ psi_re[i][0]*psi_re[i][0]
+ psi_im[i][0]*psi_im[i][0];
i <= i + 1;
if (i == N-1) begin
start_uart <= 1;
state <= 0;
end
end
endcase
end
end
endmodule
🔌 UART Simple Module (Minimal)
module uart_tx(
input wire clk,
input wire start,
input wire [7:0] data,
output reg tx,
output reg busy
);
// Minimal simple UART (details can be omitted)
endmodule
(Actually, using an existing UART IP is recommended)
📸 Experimental Success Deliverables
Below:
1️⃣ Serial monitor output (norm value transitions)
2️⃣ Photo of the FPGA board
3️⃣ Wave packet data plotted on the PC side
4️⃣ Period confirmation via LED blinking
🎯 Success Criteria
| Item | Condition |
|---|---|
| Norm | Does not diverge significantly |
| Wave packet | Linear propagation behavior |
| Operation | Stable operation for several seconds |
🔥 What is Gained Here
- Abstraction became a circuit
- Experience with fixed-point errors
- dt dependency becomes a physical constraint
This can truly be called:
Not just reading the Dirac equation
But touching it
🗂 Project Structure for Tang Nano 4K
(Dirac_FPGA_STEP1)
🎯 Design Policy
- Separate HDL and experimental logs
- Separate simulation and real hardware
- Save bitstream as a deliverable
- Extendable to STEP 2 / STEP 3 in the future
📁 Recommended Folder Structure
Dirac_FPGA_STEP1/
│
├── 00_docs/
│ ├── experiment_plan.md
│ ├── experiment_report.md
│ └── notes.md
│
├── 01_hdl/
│ ├── dirac_step1.v
│ ├── uart_tx.v
│ ├── top.v
│ └── defines.v
│
├── 02_constraints/
│ └── tangnano4k.cst
│
├── 03_sim/
│ ├── tb_dirac.v
│ └── sim_result.vcd
│
├── 04_bram_init/
│ └── psi_init.mem
│
├── 05_bitstream/
│ └── dirac_step1.fs
│
└── 06_serial_logs/
├── norm_run1.txt
└── norm_run2.txt
📂 Meaning of Each Folder
00_docs/
For research.
- Experimental plan
- Experimental report
- Insights
01_hdl/
Pure HDL sources.
-
dirac_step1.v→ Core -
uart_tx.v→ Communication -
top.v→ Pin connection -
defines.v→ Parameter definitions
When adding m ≠ 0 in the future:
dirac_step2.v
Add it here.
02_constraints/
.cst file for Tang Nano 4K.
Example:
IO_LOC "clk" 52;
IO_LOC "tx" 18;
IO_PORT "clk" IO_TYPE=LVCMOS33;
IO_PORT "tx" IO_TYPE=LVCMOS33;
03_sim/
Simulation only.
It is important to separate it from the real hardware.
04_bram_init/
Initial wave packet data.
Generated with Python and saved as:
psi_init.mem
Direct generation from Processing is also possible in the future.
05_bitstream/
Saved generated:
.fs
files.
The bitstream at the moment of success is saved as a research outcome.
06_serial_logs/
UART log storage.
Example:
Norm = 1.0023
Norm = 1.0019
Norm = 1.0008
This is the "evidence of success".
🧠 Gowin IDE Setup Procedure
① New Project
- Device: GW1NSR-4C
- Package: QFN48
- Speed: C6/I5
② Add Files
- .v in 01_hdl
- .cst in 02_constraints
③ Set Top Module
Specify top.v as the top.
④ Synthesize → Place & Route → Generate Bitstream
The output is:
impl/pnr/dirac_step1.fs
Copy this to 05_bitstream.
🧪 Evidence to Include After Experimentation
Candidates for Zenn:
- 📷 Photo of the board
- 🖥 Serial monitor screenshot
- 📊 Norm transition graph
- 🧾 fs generation screen
Next Preview
STEP 2:
- Add m ≠ 0
- Verify Zitterbewegung
- Bit-width expansion experiment
And in the final chapter
Recover the correspondence between equations and circuits.
Discussion