SV基础 | SystemVerilog基础重点

SystemVerilog 教程第一章:简介 本文首发于VX小石头的芯语芯愿,欢迎前往围观。 SystemVerilog教程第一章:简介 阅读详情

内容来自白皮书,仅做复习记录!


SystemVerilog是一种面向对象的编程语言。与非面向对象的编程语言(如C语言)相比,面向对象语言最重要的特点是所有的功能都要在类(class)里实现。

A.1 结构体的使用

在非面向对象编程中,最经常使用的就是函数。

要实现一个功能,那么就要实现相应的函数。当要实现的功能比较简单时,函数可以轻易地完成目标。

如计算一串数据流的CRC校验值,虽然CRC的算法比较复杂,但是完全可以用一个函数实现。

但是,当要实现的功能比较复杂时,仅仅使用函数实现会显得比较笨拙。

假设某动物园要实现一个简单的园内动物管理系统,这个系统要具有如下的功能:统计园内所有的动物的信息,如名字、出生年月、类别(是否能飞翔)、每天进食量、是否健康等。

打印动物园内所有动物的信息。要实现上述的这些功能,仅仅考虑如何写函数是不够的,需要考虑如何存储这些信息,即要考虑数据结构。

伟大的EDA让电路设计也变成了程序设计!!!

程序设计=算法+数据结构。所以,在程序设计的开始阶段定一个好的数据结构就相当于成功了一半。

在程序设计语言中,一般都支持结构体。以C语言为例,可以使用struct声明一个结构体(这个结构体中有些信息的定义并不完善,如生日、类别等,但是作为例子足以说明问题):

struct animal {
   char name[20];
   int  birthday;/*example: 20030910*/
   char category[20];/*example: bird, non_bird*/
   int  food_weight;
   int  is_healthy;
};

当声明了结构体后,可以定义结构变量,并将结构变量作为函数的参数来实现上述功能:

void print_animal(struct animal * zoo_member){
   printf("My name is %s\n", zoo_member->name);
   printf("My birthday is %d\n", zoo_member->birthday);
   printf("I am a %s\n", zoo_member->category);
   printf("I could eat %d gram food one day\n", zoo_member->food_weight);
   printf("My healthy status is %d\n", zoo_member->is_healthy);
}
void main()
{
   struct animal members[20];
   strcpy(members[0].name, "parrot");
   members[0].birthday = 20091021;
   strcpy(members[0].category, "bird");
   members[0].food_weight = 20;
   members[0].is_healthy = 1;
   print_animal(&members[0]);
}

A.2 从结构体到类

结构体简单地将不同类型的几个数据放在一起,使得它们的集合体具有某种特定的意义。与这个结构体相对应的是一些函数操作(上节中只列出了print_animal函数)。

对于这些函数来说,如果没有了结构体变量,它们就无法使用;**对于结构体变量来说,如果没有这些函数,那么结构体也没有任何意义。**对于二者间如此亲密的关系,面向对象的开创者们开创出了类(class)的概念。

类将结构体和它相应的函数集合在一起,成为一种新的数据组织形式。

在这种新的数据组织形式中,有两种成分,

  • 一种是来自结构体的数据变量,在类中被称为成员变量;
  • 另外一种来自与结构
SystemVerilog(简称SV) SystemVerilog(简称SV)是一种广泛应用于数字芯片设计和验证的高级硬件描述及验证语言(HDVL)。它在传统的Verilog语言基础上扩展了面向对象编程(OOP)、断言(Assertion)、功能覆盖率(Coverage)等特性,成为现代芯片设计和验证的核心工具之一。:支持类(Class)、继承、多态等特性,便于构建可复用的验证组件(如Driver、Monitor、Scoreboard)。:基于SystemVerilog的标准化验证方法学,提供可复用的验证组件和流程。:描述时序逻辑(触发器)。 阅读详情

相关推荐

verilog和system verilog的区别

如果你已经熟悉 Verilog,学习 SystemVerilog 会相对容易,因为 SystemVerilog 包含了 Verilog 的所有特性,并在此基础上增加了许多新功能。两者可以根据项目需求灵活选择,但现代数字电路设计和验证中,SystemVerilog 已成为主流。是 Verilog 的超集,增加了许多高级特性,特别适合复杂的硬件设计和验证。是 Verilog 的超集,增加了许多高级特性,特别适合复杂的硬件设计和验证。是 Verilog 的超集,增加了许多高级特性,特别适合复杂的硬件设计和验证。

weixin_49118247的博客 2524

【SV LAB5】Synposys SystemVerilog数字验证实验笔记

systemverilog已经成为了目前最主流的数字设计验证语言,SV语言具有面向对象编程(OOP)特性,具备丰富的软硬件接口与数据结构,且支持并行多线程仿真,本文以Synopsys公司推出的SV验证实验中的Lab 5为例,将该lab中涉及到的Systemverilog用于验证中的重要特性与工具进行梳理与解读。

weixin_43370732的博客 1642

SystemVerilog学习笔记5 ---《SV Schedule》

1. 为什么要了解SV Schedule verilog是一个硬件描述语言,而硬件在现实中都是并行执行的,所以verilog描述的组合电路和时序电路都是并行执行的。 而仿真器作为运行在CPU上的软件,只是按照SV LRM的仿真调度算法,开始仿真后,将仿真时间串行的一步步的向前推进。 因此,实际DUT中同时发生的动作由模拟器建模为一组有序动作,依次执行。如果不能很好地撰写RTL代码和TestBench,那么仿真可能得到不匹配的结果:即DUT为正确,但是仿真却报告错误;或者DUT为错误,但是仿真却报告正确。

llxxyy507的博客 1473

【路科V0】SV实验1【SystemVerilogVerification Flow】

lab1实验介绍 实验的工具:Questa 设计模块介绍 实验中的待测试模块(DUT)是一个16输入,16输出的路由器,这个路由器的功能是把数据通过各个输入端(Input)发送到任意输出端(Output)。下面是最终完成的整个验证平台示意图。 实验文件 打开实验文件,你将会看到如下实验代码的结构,其中rtI中为设计代码,labs中为原始代码,solutions中为参考答案。 在Lab1中我们应该掌握以下内容: 用SV给待测试模块(DUT)搭建最简单的...

weixin_41788560的博客 7176

#systemVerilog# SV 和 C/C++ 之间的桥梁 DPI(二)

一 SV 和 C 的数据类型转换   SV 的输出在C中申明为指针。   SV中的数组在C中申明为指针。   可以通过C Macro SV_PACKED_DATA_NELEMS() 自动转换。 二SV 和 C 的函数转换实例 ...

那么菜的博客 1424

(25)FPGA计数器设计(SV代码实现)

(25)FPGA计数器设计(SV代码实现) 1.1 目录 1)目录 2)FPGA简介 3)Verilog HDL简介 4)FPGA计数器设计(SV代码实现) 5)结语 1.2 FPGA简介 FPGA(Field Programmable Gate Array)是在PAL、GAL等可编程器件的基础上进一步发展的产物。它是作为专用集成电路(ASIC)领域中的一种半定制电路而出现的,既解决了定制电路的不足,又克服了原有可编程器件门电路数有限的缺点。 FPGA设计不是简单的芯片研究,主要是利用 F

m0_46498597的博客 806

C++开发基础之掌握常用的三种异步编程模型

以上是三种常见的C++异步编程模型,每种模型都有其适用的场景和特点。根据具体需求,你可以选择合适的模型来进行异步编程。

dotnet研习社 2180

《BiLSTM with Multi-Polarity Orthogonal Attention for Implicit Sentiment Analysis》论文阅读笔记

文章名:《BiLSTM with Multi-Polarity Orthogonal Attention for Implicit Sentiment Analysis》 作者Jiyao Wei a,1, Jian Liaoa,1, Zhenfei Yanga, Suge Wanga,b,∗, Qiang Zhaoa 年份 2019 1 Introduction 目前文本情感分析多分析带...

weixin_39036944的博客 1635

避坑指南:雅特力AT32F403A在Keil5中的V2库配置常见问题解析

本文详细解析了国产MCU雅特力AT32F403A在Keil5中配置V2库的常见问题,包括工程创建、库文件配置、编译错误和外设设置等关键环节。针对项目文件夹结构混乱、芯片型号选择错误、头文件路径设置不当等典型问题提供实用解决方案,帮助开发者高效避坑,提升开发效率。

weixin_30335575的博客 382

AMP架构下的核间通信:RPMSG与共享内存原理详解

本文以RK3568等异构多核硬件为例,深入浅出解析了AMP架构下核间通信的核心逻辑,阐明RPMSG并非替代共享内存,而是以共享内存为数据载体、硬件信箱为中断通知工具、VirtIO为数据管理规则,构建的标准化高层协议与框架,为开发者提供简洁API,实现不同操作系统核心间高效通信。

qq_61335271的博客 2056

【PostgreSQL】PostgreSQL数据库函数比对模板(PG通用)

LOOKUP 函数从单行或单列区域 (区域:工作表上的两个或多个单元格。区域中的单元格可以相邻或不相邻。)或数组 (数组:用于建立可生成多个结果或可对在行和列中排列的一组参数进行运算的单个公式。数组区域共用一个公式;数组常量是用作参数的一组常量。LOOKUP 函数具有两种语法形式:向量形式和数组形式。vlookup查找匹配值超过255个字符显示#Value的解决办法。如果值为错误值 #N/A,则返回 TRUE。

tttzzzqqq2018的博客 1494

【项目实战】使用Python - Mediapipe、OpenCV进行手部面部检测(Python源码)

本文介绍了使用MediaPipe和OpenCV库进行实时面部和手部关键点检测的方法。通过MediaPipe的Holistic模型,可以获取468个面部特征点及每只手21个特征点。文章详细说明了环境配置、模型初始化参数设置,并提供了完整的代码实现,包括视频流处理、关键点绘制和FPS计算等功能。这套方案可应用于手语识别、疲劳检测等计算机视觉场景,为开发者提供了一套高效的开箱即用解决方案。

梦想起飞的地方 487

YOLOv11改进 | 损失函数篇 | YOLOv11引入引MPDIoU, GIoU,DIoU, CIoU, SIoU,EIoU, WIoU, LMPDIoU等损失函数

到此本文的正式分享内容就结束了,在这里给大家推荐我的YOLOv11改进有效涨点专栏,本专栏目前为新开的,后期我会根据各种前沿顶会进行论文复现,也会对一些老的改进机制进行补充,如果大家觉得本文帮助到你了,订阅本专栏,关注后续更多的更新~1. YOLOv11中添加MPDIoU, GIoU,DIoU, CIoU, SIoU等损失函数的方式。文件中用给出的代码替换掉。

tsg6698的博客 5283

STM32Cube高效开发教程<高级篇><FreeRTOS>(一)-----FreeRTOS基础

一、 FreeRTOS概述声明:本人水平有限,博客可能存在部分错误的地方,请广大读者谅解并向本人反馈错误。本专栏博客参考《STM32Cube高效开发教程(高级篇)》,有意向的读者可以购买正版书籍辅助学习,本书籍由王维波老师、鄢志丹老师、王钊老师倾力打造,书籍内容干货满满。写在前面:今天就算正式开始高级篇的博客编写了,我本人也是第一次学习FreeRTOS,所以整体的进度会比较慢,博客更新可能不太会及时,希望大家原谅。一、 FreeRTOS概述。

我的博客 1852

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 芯片验证 | UVM的domain机制
下一篇: 科技生活 | 马斯克专门而来的FSD是什么?
TrustZone_
TrustZone_ 优质创作者: 嵌入式与硬件开发、人工智能技术领域 优质创作者: 嵌入式与硬件开发、人工智能技术领域
博客等级 码龄7年 4万+粉丝 1366原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TrustZone_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址