用verilog 实现 74LS160,然后实现2000分频占空比50的分频器

因为这周有个作业要求用3个160实现一个类似2000分频占空比50的分频器,然后没用过verilog,就直接从网上抄了一个,但是并不好使,索性自己来

module LS160(clk,ep,et,ld,clr,dn,qn,cout);

input clk,ep,et,ld,clr;
output cout;
input [3:0] dn;
output [3:0] qn;
reg [3:0]temp;
reg cout;

always @(posedge clk or negedge clr)
begin
if(clr==0)
 temp<=4'd0; 
else
begin
if(clk==1&ld==0) 
temp<=dn;
else if(clk==1&ld==1)
begin 
if((ep&et)==0)
begin 
temp<=temp;cout=0;
end
else
begin
temp<=temp+1;cout=0;
end
end

if(temp==4'd9)
begin
cout=1;
temp<=4'd0; 
end
end
end
assign qn=temp;

endmodule

module count1000(clk,enp,ent,ld,clr,dn,qn,Q1000,Q100,out);
input clk,enp,ent,ld,clr;
input [11:0] dn;
output [11:0] qn;
output out;
reg [3:0]temp;
wire rco1,rco2,cout;
output Q100,Q1000;
reg out;
LS160 LS0 (clk,enp,ent,ld,clr,dn[3:0],qn[3:0],rco1);
LS160 LS1 (~rco1,1,1,ld,clr,dn[7:4],qn[7:4],rco2);
LS160 LS2 (rco2,1,1,ld,clr,dn[11:8],qn[11:8],cout);
assign Q100=rco2,Q1000=cout;

always@(posedge cout)
begin
if(cout==1)
out=~out;
end
endmodule

在这里插入图片描述
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值