集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2456|回复: 7

奇数分频

[复制链接]
CHA 发表于 2010-6-27 23:18:24 | 显示全部楼层 |阅读模式
本帖最后由 fpgaw 于 2010-7-6 06:15 编辑

想了好久都没有解决 奇数分频 可综合的问题<br>
CCIE 发表于 2010-6-27 23:35:06 | 显示全部楼层
module div5(reset,clk,qout);<br>
input reset;<br>
input clk;<br>
output qout;<br>
<br>
reg [2:0] qq;<br>
reg dq;<br>
<br>
always @(posedge clk)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (!reset)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; qq&lt;=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else if (qq==2'b10)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; qq&lt;=0; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; qq&lt;=qq+1;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;end<br>
always @(negedge clk)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (!reset)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; dq&lt;=0; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; dq&lt;=qq[1]; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;end <br>
assign qout=dq || qq[1];<br>
endmodule
CTT 发表于 2010-6-28 00:05:16 | 显示全部楼层
给个三分频的程序  大家指点一下
HDL 发表于 2010-6-28 01:01:46 | 显示全部楼层
参考一下,谢谢
CCIE 发表于 2010-6-28 01:30:17 | 显示全部楼层
这个就是三分频的例子
UFO 发表于 2010-6-28 03:00:19 | 显示全部楼层
我也来学习一下
AAT 发表于 2010-6-28 04:46:26 | 显示全部楼层
你这个不能综合哦!用个两位的状态机可以实现!
FFT 发表于 2010-6-28 05:07:50 | 显示全部楼层
楼上程序的下半部分直接按下面这样不行么?<br>
always @(negedge clk)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (!reset)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; dq&lt;=0; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else if (qq==3)<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;qout&lt;=~clk; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;end
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2024-12-24 10:15 , Processed in 0.064762 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表