Author: Kermit Chen
Doc rev: 001
-
Coding a python script in other code file. e.g.:
- verilog file
- VHDL file
- markdown file
- text file
-
Faster generate code with template or look-up table
-
Repeat some operation by python
-
Call python script and file that you want to auto generate
python main.py <your_file>
- Parse all python script block
- Generate a
_temp.py
with script - Find the insert block in your file
- Insert the snippet by python return dictionary
NOTICE:
- Python script first function is
get_dict()
- Return must be a dictionary
- key: snippet name
- value: insert snippet
- Insert block is match the name with dictionary key when render the code
start symbol default: //[::pys::]
end symbol default: //[::pye::]
Recommend: write script block in comment, don't let the python code effect your code
//[::pys::]
<your python script>
//[::pye::]
start symbol default: //[::pds::]
end symbol default: //[::pde::]
Call start symbol with snippet name, auto generate code in there after python run.
Ignore internal block text and update by snippet
//[::pys::] <render_dict_name>
**DON'T MODIFY HERE!!**
**Run script will be regenerated every time.**
//[::pye::]
//[::pys::]
def get_dict():
reDict = {}
reDict['snipA'] = funcA()
reDict['snipB'] = funcB()
t = ''
for i in range(10):
t += str(i)
reDict['snipC'] = t
return reDict
//[::pye::]
...
//[::pds::] snipC
//[::pde::]
after run python to render
//[::pds::] snipC
0123456789
//[::pde::]
Change tags:
- [A] add
- [M] modify
- [RM] remove
- [U] update
- [O] optimize
Date: 2022.03.04
Changes:
- [A] Basic function
Fix bugs:
- NA