当前位置: 首页 > news >正文

都用什么软件做网站做网站什么东西需要费用

都用什么软件做网站,做网站什么东西需要费用,上海网络优化服务,四川成都哪里好玩一个完整的 cocotb 验证 阶乘计算模块(factorial) 的例子,涵盖: Verilog RTL 设计(组合/时序可选)cocotb Python 验证平台(含随机激励、断言、日志)仿真运行说明(使用 i…

一个完整的 cocotb 验证 阶乘计算模块(factorial) 的例子,涵盖:

  1. Verilog RTL 设计(组合/时序可选)
  2. cocotb Python 验证平台(含随机激励、断言、日志)
  3. 仿真运行说明(使用 iverilog + gtkwave

1. Verilog RTL:阶乘计算器(同步启动、串行计算)

// factorial.v
module factorial (input         clk,input         rst_n,input         start,input  [3:0]  n,         // 最大支持 15!(4位)output reg    done,output reg [31:0] result
);reg [3:0] i;reg [31:0] acc;reg busy;always @(posedge clk or negedge rst_n) beginif (!rst_n) beginacc    <= 1;i      <= 0;busy   <= 0;done   <= 0;result <= 0;end else beginif (start && !busy) beginacc  <= 1;i    <= n;busy <= 1;done <= 0;end else if (busy) beginif (i > 1) beginacc <= acc * i;i   <= i - 1;end else beginresult <= acc;busy   <= 0;done   <= 1;endend else begindone <= 0;endendend
endmodule

2. cocotb 测试代码:测试随机 0~12 的阶乘

# test_factorial.py
import cocotb
from cocotb.triggers import RisingEdge, Timer
from cocotb.clock import Clock
import random
import math@cocotb.test()
async def test_factorial(dut):"""随机测试多组阶乘计算"""# 创建时钟 10ns 周期cocotb.start_soon(Clock(dut.clk, 10, units="ns").start())# 初始化dut.rst_n.value = 0dut.start.value = 0dut.n.value = 0await RisingEdge(dut.clk)dut.rst_n.value = 1await RisingEdge(dut.clk)for trial in range(10):x = random.randint(0, 12)expected = math.factorial(x)# 启动计算dut.n.value = xdut.start.value = 1await RisingEdge(dut.clk)dut.start.value = 0# 等待 donefor _ in range(50):await RisingEdge(dut.clk)if dut.done.value:breakelse:assert False, f"Timeout: DUT failed to complete for n={x}"got = dut.result.value.integerassert got == expected, f"Failed: {x}! = {got}, expected {expected}"dut._log.info(f"PASS: {x}! = {got}")

3. 仿真运行说明(以 Icarus Verilog + cocotb 为例)

文件结构

project/
├── factorial.v
├── test_factorial.py
├── Makefile

Makefile 示例(适配 Icarus)

TOPLEVEL_LANG = verilog
VERILOG_SOURCES = $(PWD)/factorial.v
TOPLEVEL = factorial
MODULE = test_factorialSIM = icarusinclude $(shell cocotb-config --makefiles)/Makefile.sim

4. 运行与结果

make

输出类似:

[INFO] cocotb.regression                         Test Passed: test_factorial
PASS: 5! = 120
PASS: 0! = 1
PASS: 7! = 5040
...

5. 优点总结(相比纯 Verilog TB)

项目cocotb 测试优势
语言友好使用 Python 写用例、随机测试、断言都非常简单
数学函数丰富可直接调用 math.factorial 做黄金模型
日志与报错assert + dut._log.info 提供直观日志
脚本化测试易于与 GitLab CI / pytest 等整合

如需扩展:

  • 加入 边界值测试(如 n = 12、15)
  • 测试 非法输入行为(如 n > 15)
  • 加入 波形支持vcd 输出可通过 $dumpfile 查看
http://www.dtcms.com/a/591186.html

相关文章:

  • 网站首页不见怎么做网站规划的类型
  • 类似于wordpress的网站做网站备案时间
  • 举报不良网站信息怎么做wordpress如何在页首添加登录账号
  • 建设网站 课程设计南京网站流量优化
  • 网站流量来源wordpress手机后台版
  • wordpress 3.9百度seo关键词排名技术
  • 怎么建设国际网站中国室内设计任务网
  • 网站建设注意哪些问题深圳网站建设公司联系方式
  • 网站怎么更新内容wordpress错误页
  • 服务器维护网站建设教程莆田网站建设网
  • 网站搭建设计范文外贸展示型网站建设公司
  • 湖北网站推广宣传wordpress做seo优化
  • 【Python】家庭用电数据的时序分析
  • 网站后台设置关键字seo技术好的培训机构
  • 地方志网站群建设游戏源代码交易平台
  • 建网站的公司有哪些公司网站制作导航
  • 广州代做网站工作网站建设
  • 一个页面的网站wordpress 菜单 无效
  • 企业网站建设基本流程图上海建设银行营业网站
  • 可以做司法考试题的网站网址导航模板wordpress
  • 网上商城建设网站优化心得
  • 服务器用来做网站空间WordPress使用固定连接
  • 营销型网站建设 兼职企业形象网站策划方案
  • 宜良网站建设网站设计的公司
  • 网站销售网站seo外链平台
  • 营销型网站开发流程网站代理服务器有问题
  • 网站制作软件是什么意思wordpress 初始化sql
  • 个人网站备案可以做公司网站用wordpress 报表图形
  • 网站title是什么意思wordpress适合外贸的主题
  • 汉中建筑信息平台seo外链怎么做能看到效果