完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
顶层文件: module ws(clk,rst,clk_ou); input clk,rst; output clk_ou; reg clk_ou; parameter s2=0,s3=1; reg [13:0]cnt3; always @(posedge clk or negedge rst) if(!rst) cnt3<=14'd0; else if(cnt3<=18000) cnt3<=cnt3+1'b1; //15*24us else cnt3<=14'd0; reg [9:0]cnt4; always @(posedge clk or negedge rst) if(!rst) cnt4<=10'd0; else if(cnt4<=1200) cnt4<=cnt4+1'b1; //24us else cnt4<=10'd0; reg [1:0] c_s,next_s; always @(posedge clk or negedge rst) if(!rst) c_s<=s2; else c_s<=next_s; wire c; rgb U1(.clk(clk),.rst(rst),.clk_out(c)); always @(*) case(c_s) s2:begin if(cnt3==18000) next_s<=s3; else next_s<=s2; end s3:begin if(cnt4==1200) next_s<=s2; else next_s<=s3; end default:clk_ou<=c; endcase always @(posedge clk or negedge rst) begin if(!rst) clk_ou<=1'b0; else begin case(next_s) s2: clk_ou<=c; s3: clk_ou<=1'b0; default: clk_ou<=1'b0; endcase end end endmodule 子文件:: module rgb(clk,rst,clk_out); input clk,rst; output clk_out; reg clk_out; reg [7:0]cnt; always @(posedge clk or negedge rst) if(!rst) cnt<=1'd0; else if(cnt<=250) cnt<=cnt+1'd1; //1码 else cnt<=1'd0; reg a; always @(posedge clk ) if(cnt<=199) a<=1'b1; else a<=1'b0; reg [7:0]cnt1; always @(posedge clk or negedge rst) if(!rst) cnt1<=1'd0; else if(cnt1<=250) cnt1<=cnt1+1'd1;// 0码 else cnt1<=1'd0; reg b; always @(posedge clk ) if(cnt1<=49) b<=1'b1; else b<=1'b0; parameter s0=0,s1=1; reg [7:0]cnt2; always @(posedge clk or negedge rst) if(!rst) cnt2<=1'd0; else if(cnt2<=250) cnt2<=cnt2+1'd1; //5us else cnt2<=1'd0; reg c_st,next_st; always @(posedge clk or negedge rst) if(!rst) c_st<=s0; else c_st<=next_st; always @( *) case (c_st) s0: begin clk_out<=a; if(cnt2==250) next_st<=s1; else next_st<=s0; end s1: begin clk_out<=b; if(cnt2==250) next_st<=s0; else next_st<=s1; end endcase endmodule |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 06:52 , Processed in 0.527851 second(s), Total 45, Slave 33 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号