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

广州大型网站建设网店营销的推广方法有哪些

广州大型网站建设,网店营销的推广方法有哪些,微信小程序是怎么做出来的,外贸网站seo推广一个完整的 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/wzjs/185628.html

相关文章:

  • 做阿里巴巴网站的电话号码电商运营去哪里学比较好
  • 商标与logo的区别桂林seo顾问
  • app下载官网网站排名优化软件联系方式
  • 广州微网站建设效果网站推广及seo方案
  • 偃师企业网站深圳网络推广招聘
  • 扬州市邗江区建设局网站百度指数有什么作用
  • wordpress 搜狐视频播放厦门seo屈兴东
  • 做视频网站带宽要求舆情监测软件
  • 广东网站建设的seo搜索引擎优化价格
  • 学院网站建设策划书优化网站标题和描述的方法
  • 深圳网站搭建找谁企业推广app
  • 荆州学校网站建设app下载注册量推广平台
  • 网站建设选择本地网站首页的优化
  • 网站空间被攻击山东最新资讯
  • wordpress设置教程东莞seo推广公司
  • 淄博专业网站建设公司济南seo官网优化
  • 域名申请好怎么做网站查关键词排名软件
  • 那个网站做搬家推广比较好宁波网络营销怎么做
  • 珠海做网站的公司百度号码
  • 软件系统设计百度竞价seo排名
  • 搜索网站开发背景网络工程师
  • 广州做网站制作公司软文营销经典案例200字
  • 简单oa网站建设方案外链相册
  • 南山做网站公司百度软件中心
  • 桂林市网站建设公司软文写作技巧及范文
  • 罗湖实惠的网站建设费用上海网站推广服务公司
  • 海棠网站企业线上培训平台有哪些
  • 网站适合用angular做吗推荐友情链接
  • 北海做网站网络公关
  • 南京代做网站软文模板app