[Homemade Quantum Computer NMRQCP] The World of FPGA
Hello! I'm a KOSEN student taking on the challenge of developing a quantum computer using a homemade Earth's Field NMR (EFNMR) system.
So far, I've talked about analog circuits like "soldering" and FFT analysis in Python, but this time, it's about the "digital brain" used to precisely control the quantum world.
To output accurate pulses for manipulating nuclear spins, this time I'm tackling the technologies of "FPGA" and "Hardware Description Language (HDL)"!
All Circuits Running Simultaneously!? The World of FPGA
Standard computer programs are executed sequentially from top to bottom (line by line). However, inside a special chip called an FPGA, "all circuits are constantly operating at the same time."
To program this FPGA, instead of a standard programming language, we use HDL (Hardware Description Language), which is "a language for writing the circuit structure itself."
The one I am using this time is "Verilog HDL," which looks a bit like C and is the most widely used in the world. The way of writing this Verilog code is called "RTL (Register Transfer Level)."
How to Create Sequence in a "Simultaneous" World?
In an FPGA where everything moves simultaneously, how do we create a sequence like "do B after A"?
First, to create a standard for the passage of time, we use a "frequency divider." This is essentially a counter mechanism that divides the original fast clock to create a slower clock (Hz).
Then, the only way to create a sequence is through a "State Machine (FSM: Finite State Machine)." This is a mechanism that says, "Remember your current state, and if something happens, move to the next state." With this, we can accurately execute the complex procedures of applying pulses to qubits.
The Magic of Turning Digital Numbers into "Waves"
To create the pulse waveforms that manipulate quanta, calculations are also performed inside the FPGA.
First, we calculate angles using a mechanism called an "NCO (Numerically Controlled Oscillator)" (for example, representing 360° with a 16-bit number).
Next, using a technology called "DDS (Direct Digital Synthesis)," we convert the numbers calculated by the NCO into "actual voltage waves." This allows us to freely create waves of our target frequency.
Actual Code and the Unforgettable "Golden Rule"
Verilog code is defined as a module like this.
input clk, // Clock
input rst_n, // Reset button
output led
);
endmodule
There are two types of "signals" to handle data: wire, which acts just like a physical wire, and reg (register), which can record values like a box. We use them appropriately based on the situation.
Assigning values is also unique. If you write assign a = b;, it means "always linked (physically connected)," and if you write a <= b;, it means "copy the value of b to a at the timing of the clock."
⚠️ Finally, about the most critical trap.
Immediately after turning on the power, the inside of an FPGA circuit has random garbage values. Therefore, you must write a reset process like if(!rst_n), otherwise it will cause unexpected malfunctions. The importance of the reset is the lifeblood of hardware development.
It's very difficult because it requires a completely different way of thinking compared to normal programming. However, since FPGAs are often used in signal processing for quantum computers, I'll do my best to master it going forward.
- Daily experiment notes and code: Available on my GitHub repository (nmr-qc-project)
- Real-time development scenes and oscilloscope waveforms: Posting on X (formerly Twitter)
If you are wondering things like "Will it really work?" or "How do you generate waveforms?", please bookmark this blog and follow me on X!

コメント
コメントを投稿