没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
MyHDL manual
Release 0.11
Jan Decaluwe
April 10, 2020
Contents
1 Overview 1
2 Background information 3
2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 A small tutorial on generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 About decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Introduction to MyHDL 7
3.1 A basic MyHDL simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Signals and concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Parameters, ports and hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Terminology review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5 Some remarks on MyHDL and Python . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6 Summary and perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Hardware-oriented types 13
4.1 The intbv class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Bit indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 Bit slicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.4 The modbv class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.5 Unsigned and signed representation . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5 Structural modeling 19
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2 Conditional instantiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 Converting between lists of signals and bit vectors . . . . . . . . . . . . . . . . . 21
5.4 Inferring the list of instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6 RTL modeling 23
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.2 Combinatorial logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.3 Sequential logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.4 Finite State Machine modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7 High level modeling 33
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.2 Modeling with bus-functional procedures . . . . . . . . . . . . . . . . . . . . . . 33
i
7.3 Modeling memories with built-in types . . . . . . . . . . . . . . . . . . . . . . . . 38
7.4 Modeling errors using exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.5 Object oriented modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8 Unit testing 45
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.2 The importance of unit tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.3 Unit test development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
9 Co-simulation with Verilog 53
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
9.2 The HDL side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
9.3 The MyHDL side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
9.4 Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
9.5 Implementation notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10 Conversion to Verilog and VHDL 61
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.2 Solution description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.4 The convertible subset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
10.5 Conversion of lists of signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
10.6 Conversion of Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
10.7 Assignment issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
10.8 Excluding code from conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
10.9 User-defined code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
10.10 Template transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
10.11 Conversion output verification by co-simulation . . . . . . . . . . . . . . . . . . . 70
10.12 Conversion of test benches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
10.13 Methodology notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
10.14 Known issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
11 Conversion examples 73
11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.2 A small sequential design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.3 A small combinatorial design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11.4 A hierarchical design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
11.5 Optimizations for finite state machines . . . . . . . . . . . . . . . . . . . . . . . . 81
11.6 RAM inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
11.7 ROM inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
11.8 User-defined code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
12 Reference 91
12.1 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.2 Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
12.3 Co-simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
12.4 Conversion to Verilog and VHDL . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
12.5 Conversion output verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Python Module Index 105
Index 107
ii
CHAPTER 1
Overview
The goal of the MyHDL project is to empower hardware designers with the elegance and
simplicity of the Python language.
MyHDL is a free, open-source package for using Python as a hardware description and ver-
ification language. Python is a very high level language, and hardware designers can use its
full power to model and simulate their designs. Moreover, MyHDL can convert a design to
Verilog or VHDL. This provides a path into a traditional design flow.
Modeling
Python’s power and clarity make MyHDL an ideal solution for high level modeling. Python
is famous for enabling elegant solutions to complex modeling problems. Moreover, Python is
outstanding for rapid application development and experimentation.
The key idea behind MyHDL is the use of Python generators to model hardware concurrency.
Generators are best described as resumable functions. MyHDL generators are similar to al-
ways blocks in Verilog and processes in VHDL.
A hardware module (called a block in MyHDL terminology) is modeled as a function that re-
turns generators. This approach makes it straightforward to support features such as arbitrary
hierarchy, named port association, arrays of instances, and conditional instantiation. Further-
more, MyHDL provides classes that implement traditional hardware description concepts. It
provides a signal class to support communication between generators, a class to support bit
oriented operations, and a class for enumeration types.
Simulation and Verification
The built-in simulator runs on top of the Python interpreter. It supports waveform viewing by
tracing signal changes in a VCD file.
With MyHDL, the Python unit test framework can be used on hardware designs. Although
unit testing is a popular modern software verification technique, it is still uncommon in the
hardware design world.
MyHDL can also be used as hardware verification language for Verilog designs, by co-
simulation with traditional HDL simulators.
1
剩余111页未读,继续阅读
资源评论
weixin_43492754
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MATLAB-simulink主动均衡电路模型#汽车级锂电池 动力锂电池模组(16节电芯) 主动均衡电路:Buck-boost电路 均衡对象:SOC 可调整充电电流 与放电电流 版本2020b
- 纺织生产绕线生产线sw17可编辑全套技术资料100%好用.zip
- SAP PS模块详细配置手册
- MATLAB统一潮流控制器仿真模型,UPFC模型,基于模块化多电平MMC的UPFC 高压输电线路
- aapt.exe + aapt2.exe
- SAP QM质量管理模块详细配置指南(S4/HANA系统)
- Comsol(光电仿真)光子晶体微腔及其傅里叶变分析 包含comsol和fdtd模型,以及matlab代码 ①传播表面等离激元和表面等离激元光栅等 ②类比凝聚态领域魔角石墨烯的 moir e 光子晶
- GSDML-V2.2-Hein Lanz-XE-20170410.xml
- 防静电电离鼓风机step全套技术资料100%好用.zip
- 钢材打捆机sw22可编辑全套技术资料100%好用.zip
- gsdml-v2.2-pepperl+fuchs-encoder-ena58il-20161028.xml
- MMC-HVDC模拟背靠背HVDC模块化多电平流器(MMC)作为为整个电网供电的电能质量调节系统 因此,模块化多电平逆变器作为远程端转器运行,也称为孤岛模式 这种电能质量调节系统的主要目标是能够保
- GSDML-V2.3-MT-IND331-PIR-20160408.xml
- SAP销售与分销(SD)模块的最佳业务实践培训指南
- GSDML-V2.3-Schneider-ATV71-20131127.xml
- GSDML-V2.3-Schneider-ATV320-20161117.xml
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功