LRMの読み方をご紹介
この記事は SystemVerilog Advent Calendar 2020の 1日目になります。
まだまだ空きがありますので、興味あれば参加してください。
プロローグ
きっかけはこの本が発売されたことから
超久しぶりに新しい本が出た気がします。
私も購入したけど忙しくて読めてなく、まだ1章にもたどり着いてないです...orz
っというのも、私の環境も色々変わって今は CUDA書いたり、x86-64や AArch64のアセンブラと格闘したり、Pythonで書かれたプログラムをC++に変換したりと HDLと呼ばれる言語に4〜5年まともに書いてないんじゃないかと(汗
私の環境は変わりましたが、こういう本が世の中に出るのは個人的には嬉しく、できればもっと盛り上げたいなと思って今年 Advent Calendarやることにしました!
SystemVerilogがカバーしている範囲はかなり幅広く、興味があれば一度 LRM(Language Reference Manual)を読むことをおすすめします。
個人的には、こんな感じでした。
- 知らなかった構文があって、業務に活かせた
- ツールの挙動がおかしい時の確認に使えた。(問い合わせ時にLRMにこう書いてあるんだけどとか。)
- UVMやVIPなどのコード見て意味がわかる。(たまにマニアックな記述の塊だったやつもあった)
昔書いてたブログ見たら2013,4年ぐらい
1. LRMをDownloadしよう!
SystemVerilogのLRMは IEEE1800になります。Get programで 無償でDownloadできます。
ただし、IEEEアカウントは作る必要があります。(本記事書くときにIEEEアカウント作ってDownloadしました。今までしてなかった...)
Downloadできる版数は「IEEE1800-2017」です。
この記事見て、まだDownloadしていなかったら、ぜひDownloadしてください。
記事のメインはココです!!!
2. 目次を見てみよう
各パートおよび章立ては以下になってます。
Part One: Design and Verification Constructs 1. Overview 2. Normative references 3. Design and verification building blocks 4. Scheduling semantics 5. Lexical Converntions 6. Data Type 7. Aggregate data types 8. Class 9. Processes 10. Assignment statements 11. Operators and expressionsA 12. Procedural programming statements 13. Tasks and functions (subroutines) 14. Clocking blocks 15. Interprocess synchronization and communication 16. Assertions 17. Checkers 18. Constrained random value generation 19. Functional coverage 20. Utility system tasks and system functions 21. Input/output system tasks and system functions 22. Compiler directives Part Two: Hierarchy Constructs 23. Modules and hierarhy 24. Programs 25. Interfaces 26. Packages 27. Generate constructs 28. Gate-level and switch-level modeling 29. User-defined primitives 30. Specify blocks 31. Timing checks 32. Backannotation using the standard delay format 33. Configuring the contents of a design 34. Protected envelopes Part Three: Application Programming Interfaces 35. Direct programming interface 36. Programming language interface (PLI/VPI) overview 37. VPI object model diagrams 38. VPI routine definitions 39. Assertion API 40. Code coverage control and API 41. Data read API Part Four: Annexes Annex A (normative) Formal syntax Annex B (normative) Keywords Annex C (normative) Deprecation Annex D (informative) Optional system tasks and system functions Annex E (informative) Optional compiler directives Annex F (normative) Formal semantics of concurrent assertions Annex G (normative) Std package Annex H (normative) DPI C layer Annex I (normative) svdpi.h Annex J (normative) Inclusion of foreign language code Annex K (normative) vpi_user.h Annex L (normative) vpi_compatibility.h Annex M (normative) sv_vpi_user.h Annex N (normative) Algorithm for probabilistic distribution functions Annex O (informative) Encryption/decryption flow Annex P (informative) Glossary Annex Q (informative) Bibliography
1,300ページ以上もあるLRM本なのでそれなりに中身があります...
厳選10章13章をあげると、こんな感じでしょうか。
3. Design and verification building blocks 4. Scheduling semantics 6. Data Type 7. Aggregate data types 8. Class 10. Assignment statements 14. Clocking blocks 20. Utility system tasks and system functions 21. Input/output system tasks and system functions 22. Compiler directives 25. Interfaces 26. Packages 35. Direct programming interface
3. どれか読んでみよう
例えば、21. Input/output system tasks and system functions
だとこんな感じです。
このシステム関数の詳細が記載されている章になります。
「21.6 Command line input
」などは知らないと損しているのではと思ってます。
$test$plusargs ( string ) $value$plusargs ( user_string, variable )
使い方の例も記載されてますので、見てみてください。
分かりづらい部分については exampleとして例が載っているので、
実際に記述したときに、どういう値や挙動になるのかが分かるのでイメージしやすいと思います。
4. おわりに
SystemVerilog Advent Calendar 2020 の初日ということで、LRMについて書いてみました。
過去の自分のブログを見てて、へぇーって思うようなものがあったので羅列しときます。
こんな感じで、LRMを読んで気になったやつを自分で書いてみてるのも楽しいのではないかと思います。
では、良い SystemVerilogライフをお楽しみください!