本帖最后由 sunsongyeah 于 2011-5-24 08:50 编辑
module fenpin(
Clk,
clkout
);
input Clk;
output clkout;
reg clkout;
reg [31:0] Cout;
reg Clk_En;
initial
clkout<=0;
always @(posedge Clk )
begin
Cout <= (Cout == 32'd50000_000) ? 32'd0 : (Cout + 32'd1);
Clk_En <= (Cout == 32'd50000_000) ? 1'd1 : 1'd0;
clkout<=Clk_En;
end
endmodule
module counter10(
Clk,
EN,RET,
CQ,OUT
);
input Clk;
input EN,RET;
output [3:0] CQ;
output OUT;
reg OUT;
/*---------------------------------------------------*/
wire Rst_n;
assign
Rst_n = RET;
/*---------------------------------------------------*/
reg[3:0] Led;
reg Clk_En;
always @(posedge Clk or negedge Rst_n)
begin
if(~Rst_n)
begin
OUT<=0;
Led <= 4'd0;
end
else
begin
Clk_En <= Clk;
if(Clk_En&EN) //==0.5s
begin
begin
if(Led<=4'd8)
Led <= Led + 3'd1;
else
Led<=4'd0;
end
begin
if(Led>=4'd9)
OUT<=1'd1;
else
OUT<=1'd0;
end
end
end
end
/*---------------------------------------------------*/
assign
CQ = Led;
module counter6(
Clk,
EN,RET,
CQ
);
input Clk;
input EN,RET;
output [3:0] CQ;
/*---------------------------------------------------*/
wire Rst_n;
assign
Rst_n = RET;
/*---------------------------------------------------*/
reg[3:0] Led;
reg Clk_En;
always @(posedge Clk or negedge Rst_n)
begin
if(~Rst_n)
begin
Clk_En <= 1'd0;
Led <= 4'd0;
end
else
begin
Clk_En <= Clk;
if(Clk_En&EN) //==0.5s
begin
if(Led<=4'd4)
Led <= Led + 3'd1;
else
Led<=4'd0;
end
end
end
/*---------------------------------------------------*/
assign
CQ = Led;
/*---------------------------------------------------*/
endmodule
/*---------------------------------------------------*/
endmodule
任务就是最后将LED显示的信号转为数码显示管上。
如何编写。
菜鸟先拜谢各位高手!!! |