当前位置:网站首页>Generic classes and parameterized classes of SystemVerilog
Generic classes and parameterized classes of SystemVerilog
2022-07-02 06:08:00 【Then the dish】
One Parameterized classes Parameterized classes
occasionally , It is useful to define such a class : By passing different parameter sizes 、 Or parameter type , Can easily establish various object. There is no need to target different data sizes or types , Write duplicate similar code .
Example :
class vector #(int size = 1);
bit [size-1:0] a;
endclass
vector #(10) vten; // object with vector of size 10
vector #(.size(2)) vtwo; // object with vector of size 2
typedef vector#(4) Vfour; // Class with vector of size 4The above example , It takes the data size or size as the parameter of the class . The following example , Take the data type as a parameter .
class stack #(type T = int);
local T items[];
task push( T a ); ... endtask
task pop( ref T a ); ... endtask
endclass
stack is; // default: a stack of ints
stack#(bit[1:10]) bs; // a stack of 10-bit vectors
stack#(real) rs; // a stack of real numbersSystemVerilog Templates that support writing generic code using parameterized classes . A parameter is a constant type that represents a value or data type . Once the simulation starts , You cannot change parameters . Before the simulation starts , The compiler evaluates parameter expressions as part of its refinement and code generation phases . therefore , You can use parameters as part of another type declaration , Or use the value of the parameter within the scope of the array declaration .
SystemVerilog In class header , send
边栏推荐
猜你喜欢

How vite is compatible with lower version browsers

Memcached installation

谷歌出海创业加速器报名倒计时 3 天,创业人闯关指南提前收藏!

Web components series (VIII) -- custom component style settings

借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力

Ti millimeter wave radar learning (I)

PHP development and testing WebService (soap) -win

Google play academy team PK competition, official start!

让每一位开发者皆可使用机器学习技术
![[whether PHP has soap extensions installed] a common problem for PHP to implement soap proxy: how to handle class' SoapClient 'not found in PHP](/img/25/73f11ab2711ed2cc9f20bc7f9116b6.png)
[whether PHP has soap extensions installed] a common problem for PHP to implement soap proxy: how to handle class' SoapClient 'not found in PHP
随机推荐
STC8H8K系列汇编和C51实战——数码管显示ADC、按键串口回复按键号与ADC数值
PHP development and testing WebService (soap) -win
memcached安装
页面打印插件print.js
Some descriptions of Mipi protocol of LCD
I/o multiplexing & event driven yyds dry inventory
ROS2----LifecycleNode生命周期节点总结
Brain and cognitive neuroscience matlab psychoolbox cognitive science experimental design - experimental design 4
Problems encountered in uni app development (continuous update)
脑与认知神经科学Matlab Psytoolbox认知科学实验设计——实验设计四
No subject alternative DNS name matching updates. jenkins. IO found, the reason for the error and how to solve it
Style modification of Mui bottom navigation
Little bear sect manual query and ADC in-depth study
Ti millimeter wave radar learning (I)
来自读者们的 I/O 观后感|有奖征集获奖名单
数据回放伴侣Rviz+plotjuggler
使用HBuilderX的一些常用功能
让每一位开发者皆可使用机器学习技术
From design delivery to development, easy and efficient!
图片裁剪插件cropper.js