分频电路-verilog
来源:互联网 发布:js获取当前点击的元素 编辑:程序博客网 时间:2024/05/01 19:41
1. 2分频
module div_2(clk,rst,out);input clk,rst;output out;reg q;always@(posedge clk or negedge rst) if(!rst) q<=1'b0; else q<=~q;assign out=q;endmodule
2. 偶数分频
module div_8 (clk,rst,out);input clk,rst;output out;reg out;reg [2:0]cnt;always@(posedge clk or negedge rst) if(!rst) begin out<=1'b0; cnt<=3'b0; end else if(cnt==3'b3) // 3=8/2-1 begin cnt<=3'b0; out<=~out; end else cnt<=cnt+1'b1;endmodule
3. 奇数分频
module div_even (clk,rst,out);input clk,rst;output out;reg out1,out2;reg [2:0]cnt1;reg [2:0]cnt2;always@(posedge clk or negedge rst) if(!rst) begin out1<=1'b0; cnt1<=3'b0; end else if(cnt1==3'b2) //(5-1)/2 out1<=~out1; else if(cnt1==3'b4) //5-1 begin cnt1<=3'b0; out1<=~out1; end else cnt1<=cnt1+1'b1;always@(negedge clk or negedge rst) if(!rst) begin out2<=1'b0; cnt2<=3'b0; end else if(cnt2==3'b2) //(5-1)/2 out2<=~out2; else if(cnt2==3'b4) begin cnt2<=3'b0; out2<=~out2; end else cnt2<=cnt2+1'b1;assign out=out1|out2;endmodule
4. PWM(频率,占空比可调)
module pwm (clk,rst,f,p,out);input clk,rst;input [7:0] f,p;output out;reg out;reg [7:0]cnt;always@(posedge clk or negedge rst) if(!rst) begin cnt<=8'b0; end else if(cnt>=8'd200)//根据f增量大小,注意溢出 begin cnt<=8'b0; end else cnt<=cnt+f;assgin out=(cnt>p)?1:0;endmodule
阅读全文
0 0
- 分频电路-verilog
- 用Verilog实现电路分频
- Verilog任意整数分频电路
- 用Verilog语言实现奇数倍分频电路3分频、5分频、7分频
- 分频电路
- 分频电路(偶分频、奇分频)
- verilog实现占空比为1/2的奇数分频电路
- 关于verilog分频程序
- verilog 24分频代码
- Verilog时钟n分频
- verilog时钟分频设计
- 关于verilog分频程序
- 分频电路(转)
- 分频电路(转)
- [matlab]余弦分频电路
- verilog二分频代码&verilog三分频代码
- verilog二分频代码&verilog三分频代码
- Verilog实现任意整数分频
- java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
- org.apache.commons.lang.builder.ReflectionToStringBuilder
- maxSubArray
- 分形图的递归算法简介
- android中国天气网api获取天气信息并解析
- 分频电路-verilog
- Openstack Taskflow
- Html position(static、relative、absolute、fixed)
- hdu 1255 覆盖的面积(线段树+扫描线——面积交)
- HTML关键字<6>
- 安装 JPEG Toolbox
- POJ 1426 Find The Multiple DFS
- Effective Approaches to Attention-based Neural Machine Translation
- 指纹框架--指纹选项加载(一)