Verilogのプリプロセッサを試しに作ってみた
今はifdef/else/endifくらいしか対応していないのでほぼ使えませんが、一応risc vのソースコードに適用できてました。 以下にソースコードと実行方法を示します。
ソースコード
RTL_View/rtl_preprocess.py at develop · moamoai/RTL_View · GitHub
実行方法
python rtl_preprocess.py --file ${RTL_FILE}
ステートマシン図
各状態での実行内容
- NORMAL
- none
- IF_TRUE
- IF_FALSE
- not print
- EL_TRUE
- IF_FALSE
- not print
- EL_FALSE
ツール対応状況
あとは以下表の×の項目に対応させれば完成と。
Compiler directives | Verilog - LRM | 対応状況 |
---|---|---|
‘celldefine | [19.1] | - |
‘default_nettype | [19.2] | - |
‘define | [19.3] | ○ |
‘else | [19.4] | ○ |
‘elsif | [19.4] | × |
‘endcelldefine | [19.1] | - |
‘endif | [19.4] | ○ |
‘ifdef | [19.4] | ○ |
‘ifndef | [19.4] | × |
‘include | [19.5] | × |
‘line | [19.7] | - |
‘nounconnected_drive | [19.9] | - |
‘resetall | [19.6] | - |
‘timescale | [19.8] | - |