【温故而知新】【1】时钟分频-整数
来源:互联网 发布:梦里花落知多少全诗 编辑:程序博客网 时间:2024/05/16 15:54
离开微电子行业有一年时间了,最近准备返回老本行,因此想先把Verilog捡起来。
最简单的Verilog例子就是时钟分频,此处写了个整数分频,可以实现偶数分频,50%占空比,奇数分频,非50%占空比。
代码是参数化,分频数可调整。
代码如下:
//===========================================================// Author: seuchenrui@126.com//// Description:// This is a simple verilog code for clock frequency division// this code can be used to get // 1. even integer division (duty = 50%)// 2. odd inetger division (duty !=50%)//===========================================================module clock_div_integer#(parameter DIV_NUMBER=31)(inputiCLK,inputiRESET,outputreg oCLK);reg [clogb2(DIV_NUMBER)-1:0] count;always@(posedge iCLK or negedge iRESET)beginif(!iRESET)count <= 'd0;else if(count == DIV_NUMBER -1)count <= 'd0;elsecount <= count + 1'b1;endalways@(posedge iCLK or negedge iRESET)beginif(!iRESET)oCLK <= 1'b0;else if(count == DIV_NUMBER/2-1)oCLK <= ~oCLK;else if(count == DIV_NUMBER -1)oCLK <= ~oCLK;elseoCLK <= oCLK;end//================================// this function is used to check // bitwidth of the data//================================function integer clogb2;input [31:0] depth;beginfor(clogb2 = 0; depth>0;clogb2=clogb2+1)depth = depth>>1;endendfunctionendmodule
奇数仿真波形
明天继续谢谢时钟分频的代码
0 0
- 【温故而知新】【1】时钟分频-整数
- 【温故而知新】【3】时钟分频-半整数分频N.5
- 【温故而知新】【2】时钟分频-奇数50%占空比
- STM8S TIM1时钟分频
- 时钟的奇数分频
- 【FPGA】时钟分频设计
- 时钟分频简介
- 单片机的时钟分频
- Verilog时钟n分频
- s3c2440时钟分频
- verilog时钟分频设计
- FPGA 时钟分频
- 时钟 主频 分频 倍频 预分频 后分频
- 时钟分频引起的问题
- 时钟分频引起的问题
- 边沿检测,时钟任意分频,
- Verilog实现任意整数分频
- 非整数分频的实现
- Lock和synchronized的选择
- Java.math包中常用的类
- nyoj 单调递增最长子序列 17 (LIS模板)
- 修改Zend引擎实现PHP源码加密的原理及实践
- npm切换镜像站点
- 【温故而知新】【1】时钟分频-整数
- gradle配置.so文件存放目录
- PHP 错误级别
- 关于SOCKET中send和recv函数工作原理总结
- 9月-英语开始新的起航
- Android5.0 Toolbar和Theme的使用
- Linux命令总结
- android的简单wifi demo
- 转载:C++自增运算符的探索