逻辑仿真工具VCS使用

1 Makefile执行VCS仿真

  1. # Makefile for simulating the full_adder.v with the simulator VCS
  2. # ----------------------------------------------------------------------------------
  3. # Macro variable
  4. RTL := ./full_adder.v
  5. TB += ./full_adder_tb.v
  6. SEED ?= $(shell date +%s)
  7. # Target : Dependency
  8. all : compile simulate
  9. compile:
  10. vcs -sverilog -debug_all -timescale=1ns/1ps -l com.log
  11. simulate:
  12. ./simv -l sim.log
  13. run_dve:
  14. dve -vpd vcdplus.vpd &
  15. clean :
  16. rm -rf *.log csrc simv* *.key *.vpd DVEfiles coverage *.vdb
  17. # ------------------------------------------------------------------------------------
  18. # This all_cov target is used to collect the code coverage
  19. all_cov: compile_coverage simulate_coverage
  20. compile_coverage:
  21. vcs -sverilog -debug_all -cm line+cond+fsm+tgl+branch \
  22. -lca timescale.v full_adder.v full_adder_tb.v -l com.log
  23. simulate_coverage:
  24. ./simv +ntb_random_seed=$(SEED) -cm line+cond+fsm+tgl+branch \
  25. -lca -cm.log cm.log -l sim.log
  26. report_cov:
  27. urg -dir simv.vdb -format both -report coverage
  28. dve_cov:
  29. dve -cov -covdir simv.vdb -lca

2 full_adder RTL

  1. module fulladder (
  2. // module head : verilog-2001 format
  3. input wire a_in
  4. input wire b_in,
  5. input wire c_in,
  6. output wire sum_out,
  7. output wire c_out
  8. );
  9. // method 1 Gate Level Describe
  10. assign sum_out = a_in ^ b_in ^ c_in
  11. assign c_out = (a_in & b_in) | (b_in & c_in) | (c_in & a_in);
  12. // method 2 RTL design for Adder with the keyword "assign"
  13. // behavior of adder can be systhesizable
  14. // "assign" means connectivity ,which is used to describe a combinational circuit
  15. // assign {c_out,sum_out} = a_in + b_in + c_in;
  16. // method 3 RTL design for Adder with the keyword "always"
  17. //reg c_out,sum_out
  18. //always @ (a_in,b_in,c_in) begin
  19. endmodule

3 Testbench

  1. module full_adder_tb;
  2. reg ain,bin,cin; //drive the input port with the reg type
  3. wire sumout,cout;//sample the output port with the wire type
  4. full_adder u_full_adder(
  5. //task 1. how to create an instance
  6. // module head: verilog-2001 format
  7. /*input wire*/ .a_in (ain),
  8. /*input wire*/ .b_in (bin),
  9. /*input wire*/ .c_in (cin), //carry in
  10. /*output reg*/ .sum_out (sumout);
  11. /*output reg*/ .c_out (cout) //carry out
  12. );
  13. // behavior of the adder can be systhesizable
  14. // "assign" means connectivity
  15. // assign {c_out,sum_out} = a_in + b_in + c_in;
  16. // task 2. clock and rest generator
  17. parameter CLK_PERIOD = 20
  18. reg clk,rest_n; // rest_n :active low
  19. initial begin
  20. clk = 0
  21. forever begin
  22. #(CLK_PERIOD/2) clk = ~clk
  23. end
  24. end
  25. initial begin
  26. reset_n = 0;
  27. #100
  28. reset_n = 1;
  29. end
  30. //taske 3. drive the stimulus and capture the response
  31. //Here is a testcase
  32. initial begin
  33. #110 ain=0;
  34. bin=0;
  35. cin=0; //00
  36. #20 ain=0;
  37. bin=1;
  38. cin=0; //01
  39. #20 ain=1;
  40. bin=0;
  41. cin=0; //01
  42. #20 ain=1;
  43. bin=1;
  44. cin=0; //01
  45. #20 ain=0;
  46. bin=1;
  47. cin=0; //01
  48. #20 ain=1;
  49. bin=0;
  50. cin=0; //01
  51. #20 ain=1;
  52. bin=1;
  53. cin=0; //10
  54. #20 ain=0;
  55. bin=0;
  56. cin=1; //01
  57. #20 ain=0;
  58. bin=1;
  59. cin=1; //10
  60. #20 ain=0;
  61. bin=0;
  62. cin=1; //01
  63. #20 ain=0;
  64. bin=1;
  65. cin=1; //10
  66. #20 ain=1;
  67. bin=0;
  68. cin=1; //10
  69. #20 ain=1;
  70. bin=1;
  71. cin=1; //11
  72. #50 finish; // Here is a system task which can stop the simulation
  73. end
  74. //task 4. check the result
  75. always @ (posedge clk) begin
  76. if (!reset_n) begin
  77. $dispaly("%t:%m:restting...",$time) // counter 5 clock
  78. end
  79. else begin
  80. $dispaly("%t:%m:restting finish!",$time) // the 6th clock
  81. end
  82. end
  83. initial begin
  84. #115 if ({cout,simout} != 2'b00) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  85. #20 if ({cout,simout} != 2'b01) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  86. #20 if ({cout,simout} != 2'b01) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  87. #20 if ({cout,simout} != 2'b10) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  88. #20 if ({cout,simout} != 2'b01) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  89. #20 if ({cout,simout} != 2'b10) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  90. #20 if ({cout,simout} != 2'b10) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  91. #20 if ({cout,simout} != 2'b11) $display("Error:{cout,sumout}=%b,ain=%b,bin=%b,cin=%b",{cout,sumout},ain,bin,cin);
  92. end
  93. //task 5. dump waveform with the comiple option -debug_all
  94. initial begin
  95. $vcdpluson
  96. end
  97. endmodule

02-逻辑仿真工具VCS使用的更多相关文章

  1. [笔记]机器学习(Machine Learning) - 02.逻辑回归(Logistic Regression)

    逻辑回归算法是分类算法,虽然这个算法的名字中出现了"回归",但逻辑回归算法实际上是一种分类算法,我们将它作为分类算法使用.. 分类问题:对于每个样本,判断它属于N个类中的那个类或哪 ...

  2. VCS 常用命令速查

      VCS是编译型Verilog模拟器,它完全支持OVI标准的Verilog HDL语言.PLI和SDF.VCS具有目前行业中最高的模拟性能,其出色的内存管理能力足以支持千万门级的ASIC设计,而其模 ...

  3. DDR3 IP和CIC IP仿真问题解决记录

    1.更新vivado的仿真库(data/secureip和verilog和vhdl文件夹)至最新的vivado库和生成IP的版本匹配: 2.vcs编译脚本里面把仿真库地址指向匹配的仿真库版本: 3.v ...

  4. oracle12C--DG 状态集

    一,物理备库 01,状态查询与状态详解 select switchover_status from v$database 02,状态转换到备用数据库 alter database commit to ...

  5. 数字IC设计工程师成长之路

    学习的课程 仿真工具VCS实践学习 2019年12月9日-2019年12月23日

  6. 我叫Mongo,干了「查询终结篇」,值得您拥有

    这是mongo第三篇"查终结篇",后续会连续更新5篇 mongodb的文章总结上会有一系列的文章,顺序是先学会怎么用,在学会怎么用好,戒急戒躁,循序渐进,跟着我一起来探索交流. 通 ...

  7. VCS使用学习笔记(1)——Verilog相关的仿真知识

    本文主要学习Verilog的仿真特性,以及仿真器对Verilog的处理,算是对Verilog知识的增量学习.本文内容与我的另一篇博文(http://www.cnblogs.com/IClearner/ ...

  8. VCS使用学习笔记(0)——写在前面的话

    由于毕业设计做的是数字IC相关,虽然不是纯设计,但是也有设计相关.有设计就要有仿真验证,我就趁此机会来学习一下VCS的使用吧.当然,这里只是学习其简单的逻辑仿真功能,从波形仿真到覆盖率等,基本上不涉其 ...

  9. ASP.NET MVC5 网站开发实践(一) - 框架(续) 模型、数据存储、业务逻辑

    上次搭建好了项目框架,但还是觉得不太对劲,后来才想起来没有对开发目标进行定位,这个小demo虽然不用做需求分析,但是要实现什么效果还得明确.后来想了一下就做个最简单的网站,目标定为小公司进行展示用的网 ...

  10. TCP/IP详解系列 --- 概念总结02

    TCP复位报文段(RST)的用途: 1.当客户端程序访问不存在的端口时,目标主机将给它发送一个复位报文段:收到复位报文段的一端应该关闭连接或者重新连接,而不能回应这个复位报文段. 2.当客户端程序向服 ...

随机推荐

  1. iptables规则查询

    iptables规则查询 之前在iptables的概念中已经提到过,在实际操作iptables的过程中,是以"表"作为操作入口的,如果你经常操作关系型数据库,那么当你听到" ...

  2. 栈溢出漏洞利用流程——以syncbrs为例

    0x1 缓冲区溢出漏洞攻击简介 缓冲区溢出攻击是针对程序设计缺陷,向程序输入缓冲区写入使之溢出的内容(通常是超过缓冲区能保存的最大数据量的数据),从而破坏程序的堆栈,使程序转而执行其他指令,以达到攻击 ...

  3. 【Azure 环境】Azure 云环境对于OpenSSL 3.x 的严重漏洞(CVE-2022-3602 和 CVE-2022-3786)的处理公告

    问题描述 引用报告:(OpenSSL3.x曝出严重漏洞 : https://www.ctocio.com/ccnews/37529.html ) 最近OpenSSL 3.x 爆出了严重安全漏洞,分别是 ...

  4. 初步探索GraalVM——云原生时代JVM黑科技

    1 云原生时代Java语言的困境 经过多年的演进,Java语言的功能和性能都在不断的发展和提高,诸如即时编译器.垃圾回收器等系统都能体现Java语言的优秀,但是想要享受这些功能带来的提升都需要一段时间 ...

  5. Go语言基础-从菜鸟到火鸡

    课程介绍: 1.概述和环境搭建 2.程序开发 3.数据类型 4. 指针 5. 标志符 6. 运算符 7. 进制介绍 8.流程控制 9.循环控制 10.break与continue 11.函数 12.g ...

  6. Go语言核心36讲52

    你好,我是郝林. 专栏到这里,就要结束了. 差不多在半年以前(2018年的第二个季度),极客时间的总编辑郭蕾找到我,说想让我写一个关于Go语言的技术专栏. 我那时候还在轻松筹担任大数据负责人,管理着四 ...

  7. KubeEdge快速上手与社区贡献实践

    1.KubeEdge的架构特点与优势 持久化 云端组件,EdgeController,设备抽象API,CSI Driver,Admission WebHook 边缘组件,EdgeHub,MetaMan ...

  8. 第2-3-8章 分片上传和分片合并的接口开发-文件存储服务系统-nginx/fastDFS/minio/阿里云oss/七牛云oss

    目录 5.10 接口开发-分片上传 5.10.1 分片上传介绍 5.10.2 前端分片上传插件webuploader 5.10.3 后端代码实现 5.10.3.1 接口文档 5.10.3.2 代码开发 ...

  9. layui的switch监听事件无用

    像layui的这种表单事件是属于表单,而不是表格,所以操作是layui.form.on监听事件,而不是用layui.table.on table = layui.table , form = layu ...

  10. 关于解决 inittramfs unpacking failed:Decoding failed 报错

    解决办法 vi /etc/initramfs-tools/initramfs.conf 更改COMPRESS=lz4以COMPRESS=gzip 保存更改 sudo update-initramfs ...