FPGAとは何か
FPGA(Field-Programmable Gate Array)は、購入後にユーザーが回路構成を書き換えられる半導体デバイスです。ASICより低コスト・短納期で、高速並列処理が必要な通信・画像処理・金融HFTなどで活躍しています。
FPGA・ASIC・CPUの比較
| 項目 | CPU | FPGA | ASIC |
|---|---|---|---|
| 柔軟性 | 高 | 中 | 低 |
| 開発コスト | 低 | 中 | 非常に高い |
| 処理速度 | 中 | 高(並列) | 最高 |
| 消費電力 | 中 | 高め | 最低 |
| 用途 | 汎用 | 試作・特殊処理 | 量産製品 |
ハードウェア記述言語(HDL)
FPGAのプログラムは、ソフトウェアではなく回路の動作を記述する言語で書きます。
Verilog(C言語に近い書き方)
// 4ビットカウンター
module counter(
input wire clk,
input wire rst_n,
output reg [3:0] count
);
always @(posedge clk or negedge rst_n) begin
if (!rst_n)
count <= 4'b0000;
else
count <= count + 1;
end
endmodule
VHDL(より厳密・欧州で普及)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity counter is
Port (
clk : in STD_LOGIC;
rst_n : in STD_LOGIC;
count : out STD_LOGIC_VECTOR(3 downto 0)
);
end counter;
architecture rtl of counter is
signal cnt : unsigned(3 downto 0) := (others => '0');
begin
process(clk, rst_n)
begin
if rst_n = '0' then
cnt <= (others => '0');
elsif rising_edge(clk) then
cnt <= cnt + 1;
end if;
end process;
count <= std_logic_vector(cnt);
end rtl;
シミュレーションの重要性
FPGAは実機デバッグが難しいため、テストベンチで徹底的にシミュレーションします。
// テストベンチ
module counter_tb;
reg clk = 0, rst_n = 0;
wire [3:0] count;
counter uut(.clk(clk), .rst_n(rst_n), .count(count));
always #5 clk = ~clk; // 10ns周期クロック
initial begin
#20 rst_n = 1;
#200 $finish;
end
endmodule
学習の始め方
- 開発ボード:Xilinx Basys 3(約1.5万円)、Altera DE10-Lite
- EDAツール:Vivado(Xilinx)、Quartus Prime(Intel/Altera)
- 入門課題:Lチカ → 7セグ表示 → UART通信 → 画像処理
ソフトとハードの境界を理解することで、システム全体の最適化ができるエンジニアになれます。





