SlideShare a Scribd company logo
1 of 39
Verilog HDLハンズオン
~準備編~
福田 祐樹
(Twitter→@Y_F_acoustics)
自己紹介
氏名:福田 祐樹(フクダ ユウキ)
年齢:23歳
出身:大分県
最終学歴:広島市立大学大学院(修士)
現在:社会人1年目・福島県在住
近況:電波暗室に缶詰
実際は・・・・
「FPGA開発ハンズオン」をしようと考えていたが・・・
ブロック図?タイミング解析?ELAを使ったデバッグ?
※時間があってもあっても足りない
Verilog HDLを用いたコーディング&シミュレーション
ハンズオン(実践編)で用いる環境
OS:Windows 10 or Linux (RHEL, SUSE, Ubuntu),64bit
開発環境:Intel Quartus Prime Lite Edition
(空き容量が少ない人はModelsim-Intel FPGA Starter EditionのみでもOK)
エディタ:お好みのもの(発表者はQuartus & VScodeを利用)
参考図書
木村 真也 著
トランジスタ技術SPECIAL No. 95
「改訂新版・わかるVerilog HDL入門」,CQ出版社
広島市立大学関係者へ
高橋 隆一 著
「Verilog HDLによるシステム開発と設計」,共立出版
本日のレクチャー内容
1. データ型
2. 基本的な記述の概要
3. ポート・モジュール内信号宣言
4. 演算子
5. 組み合わせ回路の例
6. 順序回路の例
7. テストベンチ
8. 実際の開発の一部
データ型
合成(FPGAにプログラムすること)できるデータ型は
「整数」のみ!!
任意ビット長!
ただし・・・
データ型(数値)
1 0 1 0 0 1 0 1
27 26 25 24 23 22 21 20
「ビット」・・・2進数の最小単位についておさらい
1 × 27 + 0 × 26 + 1 × 25 + 0 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20
= 128 + 32 + 4 + 1
= 165
𝑛ビット符号なし整数で表せる最大値は2 𝑛 − 1
データ型(数値)
数値は2進数,8進数,10進数,16進数で表現可能
{ビット数}’{b|o|d|h}{数値}
(例:10進数の253)
8’d253(10進数は253でも良い)
8’b11111101
8’hfd
ビット数!!
データ型(信号)
「単なる配線」か、「トリガに合わせて変化するもの」か
wire・・・単なる配線
reg・・・他の信号に同期して変化
データ型(信号)
wire ・・・単なる配線→値の保持ができない
データ型(信号)
reg (register) ・・・トリガに合わせて出力(遅延を持つ)
基本的な記述
module モジュール名(ポートリスト);
ポート宣言
モジュール内信号定義
function
インスタンシエーション(モジュールのインポート)
assign
always
initial
endmodule
基本的な記述
ポートリスト
入出力信号名を全て記載
基本的な記述
ポート宣言
ポートリスト内の信号が
1. 入力か出力か
2. ビット長を持つか
3. 符号付きか符号無しか
4. ビットオーダはどっちか
の情報を宣言
(補足)ビットオーダ
0 1 0 1
23 22 21 20
0 1 0 1
20 21 22 23
基本的な記述
モジュール内信号の宣言
入力,出力はしないがモジュール
内部で必要な信号
(カウンターなど)
input, outputの宣言以外は
ポートリスト宣言と同じ記法
基本的な記述
計算部分
ここが最も複雑
assign, always,
インスタンシエーション,
initial, functionなど
コメントアウト
// <-1行のみコメントアウト
/* この区間を全てコメントアウト */
※C言語と一緒
ポート・モジュール内信号宣言
ポート宣言
{input/output} {wire/reg} {(unsigned)/signed} ([MSB:LSB]) {信号名};
※()表記は省略可能(ただし[MSB:LSB]の省略は1ビット信号の場合のみ)
同じ型の信号は併記可能.
input wire [3:0] in_1, in_2;
in_1, in_2という名の4ビット符号なし整数の入力信号
output reg cy;
cyという名の1ビット出力信号(トリガに同期して出力)
input wire unsigned [3:0] in_1, in_2;
ポート・モジュール内信号宣言
モジュール内信号宣言
{wire/reg} {(unsigned)/signed} ([MSB:LSB]) {信号名};
※()表記は省略可能(ただし[MSB:LSB]の省略は1ビット信号の場合のみ)
同じ型の信号は併記可能.
input/output宣言を外すだけ
reg型は同時に初期化も可能(後ほど説明)
演算子
配線
assign ・・・他の信号を出力信号として取り出す
代入
=
<=
・・・ブロッキング代入
・・・ノンブロッキング代入
ノンブロッキング代入とブロッキング代入
ブロッキング代入・・・記述順に式を評価
ノンブロッキング代入・・・同時に式を評価
(a == 2, b == 3)
a = b;
b = a;
(a == 2, b == 3)
a <= b;
b <= a;
a == b == 3 a == 3, b == 2
演算子
算術演算
記号 演算
+ 加算
- 減算
* 乗算
/ 除算
% 剰余
** べき乗
演算子
関係演算
記号 演算
< 小なり
<= 小なりイコール
> 大なり
>= 大なりイコール
== 一致
!= 不一致
演算子
シフト演算
記号 演算
<< 左シフト(符号なし)
>> 右シフト(符号なし)
<<< 左シフト(符号あり)
>>> 右シフト(符号あり)
演算子
論理演算
記号 演算
! 論理否定
&& 論理積
|| 論理和
演算子
ビット演算
記号 演算
~ NOT
& AND
| OR
^ XOR
~^ XNOR
演算子
リダクション演算(ビット列に対する演算)
記号 演算
& AND
~& NAND
| OR
~| NOR
^ XOR
~^ XNOR
演算子
その他
記号 演算
?: 条件演算
{ } 連結演算
※if文を使うにはコツがいるので条件演算は覚えておくと便利
組み合わせ回路の例
XORをNOT,AND,ORだけで表現する
A B C
0 0 0
0 1 1
1 0 1
1 1 0
0 1
0 0 1
1 1 0
A
B
𝐶 = ~𝐴 & 𝐵 | (𝐴 & ~𝐵)
組み合わせ回路の例
条件演算子
同期式順序回路の構成に必要な記述
always文・・・信号の変化に合わせ動作させる
always @ (変化を受け取る信号) begin
変化に合わせた処理
end
always @ (posedge clk) begin
b <= a;
end
(例)
センシティビティリスト
センシティビティリストの記法 動作
posedge {信号名} 信号の立ち上がりエッジに同期
negedge {信号名} 信号の立ち下がりエッジに同期
{信号名} 信号の変化に同期
同期式順序回路の構成に必要な記述
assign文にはブロッキング代入(=),always文にはノンブロッキング代入(<=)
※バグの元
実際にどんなことが起こるだろうか・・・?
順序回路の例
D
CLK
Q
D-FFを作ってみる
果たしてこれは安定に動くのだろうか・・・?
テストベンチ
実際に作ったモジュールが要求仕様通りに動くかシミュレーションするためのHDLコード
ポートリストは記載しない
シミュレーション時間の設定を記載する
モジュールに入力する信号はreg
モジュールからの出力信号はwire
モジュールの宣言
遅延(`timescaleの単位で遅延,つまり5us)
開発の一部
次回予告
ハンズオン本番をします.
必要な環境:
Windows 10 or LinuxのPC
Intel Quartus Prime Lite Edition
次回 #hiro_itのタイムテーブル公開時にアジェンダ公開します.
このスライドを持っておくと良いかもしれません.
コード記述の予習は必要ありません(徐々に慣れていけるよう準備します)

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Verilog HDLハンズオン~準備編~