Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid...

33
Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Clifford Wolf, Axel Jantsch 29 th of March 2019, Workshop on Open Source Design Automation (OSDA), Florence, Italy

Transcript of Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid...

Page 1: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

Python Wraps Yosys for Rapid Open-Source EDA ApplicationDevelopment

Benedikt Tutzer, Christian Krieg, Clifford Wolf, Axel Jantsch

29th of March 2019, Workshop on Open Source Design Automation (OSDA), Florence, Italy

Page 2: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

What is pyosys?

kernel

read opt synth

. . .

YosysYosys:

• Kernel

• Default Passes

• Custom Passes

• C++ Interface

2Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 3: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

What is pyosys?

kernel

read opt synth

. . .

Yosys

pyosys

Python

Yosys:

• Kernel

• Default Passes

• Custom Passes

• C++ Interface

pyosys

• Python Interface

2Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 4: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

What is pyosys?

kernel

read opt synth

. . .

Yosys

pyosys

Python pass

Yosys:

• Kernel

• Default Passes

• Custom Passes

• C++ Interface

pyosys

• Python Passes

2Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 5: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

What is pyosys?

kernel

read opt synth

. . .

Yosys

pyosys

Python

Python pass

Yosys:

• Kernel

• Default Passes

• Custom Passes

• C++ Interface

pyosys

• Python Interface

• Python Passes

2Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 6: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

opt

write

edif

Sample TCL Flow:

• read HDL design

3Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 7: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

opt

write

edif

Sample TCL Flow:

• read HDL design

• depicted to internal data structure

3Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 8: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

opt

write

edif

Sample TCL Flow:

• synthesize

• read and write from/to internal data

structure

3Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 9: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

opt

write

edif

Sample TCL Flow:

• optimize

• read and write from/to internal data

structure

3Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 10: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

opt

write

edif

Sample TCL Flow:

• read from internal data structure

• write to edif file

3Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 11: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• read HDL design

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 12: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• read HDL design

• depicted to accessible internal data

structure

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 13: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• synthesize

• read and write from/to internal data

structure

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 14: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• C++ code

• Elaborate computations with full

design access

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 15: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• if design does not fit: optimize

• read and write from/to internal data

structure

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 16: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Why pyosys?

read

verilog

Design

synth

?

optNo

write

Yes

edif

Sample C++ based Yosys Flow:

• write netlist file

• read from internal data structure

• write to edif file

4Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 17: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Motivation

• TCL1 sufficient for synthesis flow

• C++ based Yosys

• Functionality focused, fast prototyping through Python

1Tool Command Language

5Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 18: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Motivation

• TCL1 sufficient for synthesis flow

• C++ based Yosys

• Functionality focused, fast prototyping through Python

1Tool Command Language

5Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 19: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Motivation

• TCL1 sufficient for synthesis flow

• C++ based Yosys

• Functionality focused, fast prototyping through Python

1Tool Command Language

5Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 20: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Implementation

Yosysheaders

pyosysconfig

pyosysscript

C++wrappers

C++compiler

Boost.Python

Yosyslibrary

Yosys Makefile

6Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 21: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Implementation

Yosysheaders

pyosysconfig

pyosysscript

C++wrappers

C++compiler

Boost.Python

Yosyslibrary

Yosys Makefile

6Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 22: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Implementation

Yosysheaders

pyosysconfig

pyosysscript

C++wrappers

C++compiler

Boost.Python

Yosyslibrary

Yosys Makefile

6Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 23: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Implementation

Yosysheaders

pyosysconfig

pyosysscript

C++wrappers

C++compiler

Boost.Python

Yosyslibrary

Yosys Makefile

6Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 24: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Implementation

Yosysheaders

pyosysconfig

pyosysscript

C++wrappers

C++compiler

Boost.Python

Yosyslibrary

Yosys Makefile

6Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 25: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Live Demo

1 Interactive usage: from a Python shell

2 Non-interactive usage: creating a pass

7Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 26: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 27: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 28: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 29: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 30: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 31: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 32: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,

ww

w.i

ct.t

uw

ien

.ac.

at

Wrap up

• Interactive usage → immediate feedback

• Python scripting → fast prototyping

• Develop Python passes → abstraction to arbitrary designs

• Use Python passes in C++ → flexible pass usage

• Use Python passes in Yosys scripts → reuse existing code

• Currently available at:www.github.com/christian-krieg/yosys/tree/feature/python_bindings

• Hopefully soon in the official Yosys repository

8Tutzer, Krieg, Wolf, Jantsch — pyosys

Page 33: Python Wraps Yosys for Rapid Open-Source EDA Application ... · Python Wraps Yosys for Rapid Open-Source EDA Application Development Benedikt Tutzer, Christian Krieg, Cli ord Wolf,