Files
TBgen_App/__pycache__/iverilog_call.cpython-312.pyc

83 lines
6.4 KiB
Plaintext
Raw Normal View History

2026-03-30 16:46:48 +08:00
<EFBFBD>
&Zi<5A><00><00>:<00>dZddlZddlZddlmZddlmZejdk(rdZndZdZ d Z
d
Z dd <0B>Z d <0C>Z dd <0A>Zd<0E>Zd<0F>Zd<10>Zdd<11>Zedk(rNeej*<00>Zedk(reej*d<00>ye j/e<08>re ne ezZee <09>yy)z<>
Description : This file is related to iverilog calling. Some codes are modified from autosim.py v0.2 by Rain Bellinsky.
Author : Ruidi Qiu (r.qiu@tum.de)
Time : 2023/12/9 23:22:51
LastEdited : 2025/2/22 16:13:21
<EFBFBD>N)<01>
run_in_dir)<01> subproc_call<6C>nt<6E>\<5C>/zipynb_demo/verilog_test/z/usr/bin/iverilogz /usr/bin/vvpc<00><00><01><00>fd<01>}|jt<00>s |tz }t|<00>d}dj|<04>j dd<05>}d}t
<00>d|<06>d|<05><01>}||<07>t |<00>5t||<02>}ddd<08>d r|d
<EFBFBD>d ||dd|d gSt<00>d|<06><01>} || <09>t |<00>5t| |<02>}
ddd<08>
d r|d <0A>d ||| |
|
d gSd||| |
dgS#1swY<00>txYw#1swY<00>5xYw)aF
#### input:
- dir: the name of the directory that contains all verilog files; can end with or without "/"
- task_id: the name of the task, will be used as the name of the vvp file
#### output:
return a list of 5 elements:
- [0] (pass or not): bool, whether the simulation is successful
- [1] (cmd1): str, the iverilog compiling command
- [2] (run1_info): dict, the iverilog compiling result {"out": out_reg, "err": err_reg, "haserror": error_exist}
- [3] (cmd2): str, the vvp running command
- [4] (run2_info): dict, the vvp running result {"out": out_reg, "err": err_reg, "haserror": error_exist}
- [5]/[-1] (error_msg): str, the error message if there is any error; This is for convenience, the error message is also included in [2] or [4]
#### functionality:
given the name of the directory that contains all verilog files, create a vvp file and run it.
#### iverilog command explanation:
- -o + file_path: output file name (.vvp's name)
- -c + list_file_path: read file list from file
c<00>"<00><01><00>s t|i|<01><01>yy<00>N)<01>print)<03>args<67>kwargs<67>silents <20><>3/home/zhang/CorrectBench/TBgen_App/iverilog_call.py<70>s_printziverilog_call.<locals>.s_print-s<00><><00><15> <11>4<EFBFBD> "<22>6<EFBFBD> "<22><16><00>data<74><00>
<EFBFBD> zrun.vvpz -g2012 -o N<>haserrorziverilog compiling failedF<64>errz
vvp failedT) <09>endswith<74>IC<49> vList_gen<65>join<69>replace<63> IVERILOG_PATHrr<00>IVERILOG_VVP_PATH) <0B>dirr<00>timeoutr<00>
vlist_data<EFBFBD> vlist_str<74> vvp_filename<6D>cmd1<64> run1_info<66>cmd2<64> run2_infos ` r<00> iverilog_callr(s%<00><><00>,#<23> <0F><<3C><<3C><02> <1B> <0B>r<EFBFBD> <09><03><1A>3<EFBFBD><1E><06>'<27>J<EFBFBD><12><07><07>
<EFBFBD>#<23>+<2B>+<2B>D<EFBFBD>#<23>6<>I<EFBFBD><1C>L<EFBFBD>!.<2E> <0C>i<EFBFBD> H<>D<EFBFBD> <0B>D<EFBFBD>M<EFBFBD> <13>C<EFBFBD><1F>0<> <20><14>w<EFBFBD>/<2F> <09>0<><10><1A><1C><0F>+<2B>,<2C><15>t<EFBFBD>Y<EFBFBD><04>d<EFBFBD>I<EFBFBD>e<EFBFBD>4D<34>E<>E<>%<25>|<7C> 4<>D<EFBFBD> <0B>D<EFBFBD>M<EFBFBD> <13>C<EFBFBD><1F>0<> <20><14>w<EFBFBD>/<2F> <09>0<><10><1A><1C><0F> <0C><1D><15>t<EFBFBD>Y<EFBFBD><04>i<EFBFBD><19>5<EFBFBD>9I<39>J<>J<> <10>$<24> <09>4<EFBFBD><19>B<EFBFBD> 7<>7<>0<>0<><30>0<>0<>s<00>7 C7<03> D<03>7D<07>D c<00><><00>tjj|d<01>}d}|dr|dz }n|dz }|d<00> |d|dzz }|d <00>|d
|d d zz }|d |d d zz }|d<00> |d|dzz }|d<00>|d|dd zz }|d|dd zz }t|d<13>5}|j |<03>ddd<07>y#1swYyxYw)z.
save the run info of iverilog to dir
z run_info.txtrrziverilog simulation passed!
ziverilog simulation failed!
<EFBFBD>Nziverilog cmd 1:
%s
<EFBFBD>ziverilog cmd 1 output:
%s
<EFBFBD>outziverilog cmd 1 error:
%s
r<00>ziverilog cmd 2:
%s
<EFBFBD>ziverilog cmd 2 output:
%s
ziverilog cmd 2 error:
%s
<EFBFBD>w)<05>os<6F>pathr<00>open<65>write)<05>
ivrun_infor<00> run_info_path<74>lines<65>fs r<00>save_iv_runinfor8Hs<00><00><17>G<EFBFBD>G<EFBFBD>L<EFBFBD>L<EFBFBD><13>n<EFBFBD>5<>M<EFBFBD> <0E>E<EFBFBD><11>!<21>}<7D> <0A>2<>2<><05> <0A>2<>2<><05><11>!<21>}<7D> <20> <0A>(<28>J<EFBFBD>q<EFBFBD>M<EFBFBD>:<3A>:<3A><05><11>!<21>}<7D> <20> <0A>/<2F>:<3A>a<EFBFBD>=<3D><15>3G<33>H<>H<><05> <0A>.<2E>*<2A>Q<EFBFBD>-<2D><05>2F<32>G<>G<><05><11>!<21>}<7D> <20> <0A>(<28>J<EFBFBD>q<EFBFBD>M<EFBFBD>:<3A>:<3A><05><11>!<21>}<7D> <20> <0A>/<2F>:<3A>a<EFBFBD>=<3D><15>3G<33>H<>H<><05> <0A>.<2E>*<2A>Q<EFBFBD>-<2D><05>2F<32>G<>G<><05> <0A>m<EFBFBD>S<EFBFBD> !<21><17>Q<EFBFBD> <09><07><07><05><0E><17><17><17>s <00>!B<<03><Cc<00>8<00>t|||<02>}t||<00>|S)z0
run the iverilog and save the run info
)r(r8)rrr <00> iv_run_results r<00>iverilog_call_and_saver;ds"<00><00>"<22>#<23>v<EFBFBD>w<EFBFBD>7<>M<EFBFBD><13>M<EFBFBD>3<EFBFBD>'<27> <18>rc<00><><00>g}tj|<00>D]3\}}}|D](}|dddk(s<01> |jt|<05>dz<00><00>*<00>5|S)z"
dir: directory to search
<20><><EFBFBD><EFBFBD><EFBFBD>Nz.vr)r0<00>walk<6C>append<6E>str)r<00>v_list<73>root<6F>dirs<72>files<65>names r<00>
getVerilogrFls`<00><00><10>F<EFBFBD><1F>W<EFBFBD>W<EFBFBD>S<EFBFBD>\<5C>0<><19><04>d<EFBFBD>E<EFBFBD><19> 0<>D<EFBFBD><13>B<EFBFBD>D<EFBFBD>{<7B>d<EFBFBD>"<22><16> <0A> <0A>c<EFBFBD>$<24>i<EFBFBD>$<24>.<2E>/<2F>  0<>0<> <12>Mrc<00><><00>d|z}t|<00>}t|d<02>5}|j|<02>ddd<03>||d<04>S#1swY<00>xYw)zG
dir: directory to search, will save the list file in this dir
z %svlist.txtr/N)r1r)rFr2<00>
writelines)r<00> file_path<74>filelistr7s rrrysO<00><00>
<1E>s<EFBFBD>#<23>I<EFBFBD><19>#<23><EFBFBD>H<EFBFBD> <0A>i<EFBFBD><13> <1D><1F><11> <09> <0C> <0C>X<EFBFBD><1E><1F><1D>x<EFBFBD> 0<>0<><1F><1F>s <00><<03>Ac<00>B<00>t|jj<00>y)z'
for main.py to directly call.
N)r(<00>iverilogr)<01>configs r<00> run_iverilogrN<00>s<00><00><12>&<26>/<2F>/<2F>%<25>%<25>&rc<00>b<00>|<00> td<02>}t|<00>}t||<00>t|<01>y)z1
directly run this file: to run iverilog
Nz)Please enter project name (dir name):
>> )<04>inputr(r8r )r<00>msgs r<00>mainrR<00>s1<00><00> <0B>{<7B><13>@<40>A<><03> <18><03>
<1C>C<EFBFBD><13>C<EFBFBD><13><1D> <09>#<23>Jr<00>__main__r+r*)F<>xr
)<19>__doc__r0<00>sys<79> utils.utilsr<00> utils.subprocrrEr<00>RUN_DIRrrr(r8r;rFrrNrR<00>__name__<5F>len<65>argv<67>argr<00>dir_path<74>rr<00><module>r`s<><00><01><04>
<EFBFBD>
<EFBFBD>"<22>&<26><05>7<EFBFBD>7<EFBFBD>d<EFBFBD>?<3F> <0A>B<EFBFBD> <0C>B<EFBFBD>
$<24><07>#<23> <0A>"<22><11>/8<>b<17>8<19> <12> 1<>'<27>
<0F> <0C>z<EFBFBD><19>
<0A>c<EFBFBD>h<EFBFBD>h<EFBFBD>-<2D>C<EFBFBD>
<EFBFBD>a<EFBFBD>x<EFBFBD> <0C>S<EFBFBD>X<EFBFBD>X<EFBFBD>a<EFBFBD>[<5B><19>%<25>.<2E>.<2E>r<EFBFBD>2<>7<EFBFBD><07>"<22> <0C><08> <0C>W<EFBFBD> <0A> r