|
下面程序编译能过,但不能综合,警告N多,是抄录一个网站改的。
原程序,为每个位各用7段控制,想改成共阴极的,可是,,,,,不会改。
希望大家多多指教
module miobiao(key,clk,dataout,en,led);
input key,clk;
//output [6:0] segdat1,segdat2,segdat3,segdat4,segdat5,segdat6,segdat7,segdat8;
output [3:0] led;
output [6:0] dataout;
output [7:0] en;
reg [3:0] led;
reg [24:0] count;
reg [7:0] sec,min,hour;
reg [6:0] dataout,en;
reg [3:0] dispdat1,dispdat2,dispdat3,dispdat4,dispdat5,dispdat6;
reg [2:0] count_reg;
reg second;
reg [1:0] count1;
reg cn,cm;
////////////////////fen pin///////////////////////////
/////////////////////////////////////////////////////////////
always @(posedge clk)
begin
count=count+1;
if(count==25'd25000000)//2500'0000;
begin
count=25'b0000000000000000000000000;
second=~second;
count1=count1+1;
end
end
////////////////////display////////////////////////////
////////////////////////////////////////////////////////
always @(count[2:0])
begin
count_reg=count[2:0];
//segdat7=7'b1111111;
//segdat8=7'b1111111;
if(count_reg==3'b110)
begin
count_reg=3'b000;
end
case(count_reg)
3'b000: dispdat1=sec[3:0]; // miao de ge wei
3'b001: dispdat2=sec[7:4]; //miao de shi wei
3'b010: dispdat3=min[3:0]; //fen de ge wei
3'b011: dispdat4=min[7:4]; //fen de shi wei
3'b100: dispdat5=hour[3:0]; //shi de ge wei
3'b101: dispdat6=hour[7:4]; //shi de shi wei
endcase
end
/////////////////////////miao de ge wei///////////////////////////////////////
always @(dispdat1)
begin
case(dispdat1)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0000_0001;
end
/////////////////////////miao de shi wei///////////////////////////////////////
always @(dispdat2)
begin
case(dispdat2)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0000_0010;
end
/////////////////////////fen de ge wei///////////////////////////////////////
always @(dispdat3)
begin
case(dispdat3)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0000_0100;
end
///////////////////////// fen de shi wei///////////////////////////////////////
always @(dispdat4)
begin
case(dispdat4)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0000_1000;
end
/////////////////////////shi de ge wei///////////////////////////////////////
always @(dispdat5)
begin
case(dispdat5)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0001_0000;
end
/////////////////////////shi de shi wei///////////////////////////////////////
always @(dispdat6)
begin
case(dispdat6)
4'h0: dataout=7'b1000000;//0
4'h1: dataout=7'b1111001;//1
4'h2: dataout=7'b0100100;//2
4'h3: dataout=7'b0110000;//3
4'h4: dataout=7'b0011001;//4
4'h5: dataout=7'b0010010;//5
4'h6: dataout=7'b0000010;//6
4'h7: dataout=7'b1111000;//7
4'h8: dataout=7'b0000000;//8
4'h9: dataout=7'b0010000;//9
endcase
en=8'b0010_0000;
end
//////////////////////////////ji shi chu li////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////miao de chu li///////////////////////////////////////////////////
always @(posedge second)
begin
if(!key)
begin
sec[7:0]=8'h0;
cn=0;
end
else
begin
cn=0;
sec[3:0]=sec[3:0]+1;
if(sec[3:0]==4'd10)
begin
sec[3:0]=4'd0;
sec[7:4]=sec[7:4]+1;
if(sec[7:4]==4'd6)
begin
sec[7:4]=4'd0;
cn=1;
end
end
end
end
//////////////////////////fen de chu li//////////////////////////////////////////
always @(posedge cn)
begin
if(!key)
begin
min[7:0]=8'h0;
cm=0;
end
else
begin
min[3:0]=min[3:0]+1;
cm=0;
if(min[3:0]==4'd10)
begin
min[3:0]=4'd0;
min[7:4]=min[7:4]+1;
if(min[7:4]==4'd6)
begin
min[7:4]=4'd0;
cm=1;
end
end
end
end
/////////////////////shi de chu li //////////////////////////////////////////////////////////////////
always @(posedge cm)
begin
begin
if(hour[7:4]==4'd2)
if(hour[3:0]>=4'd3)
begin
hour[7:4]=4'd0;
hour[3:0]=4'd0;
end
end
if(!key)
begin
hour[7:0]=8'h0;
end
else
begin
hour[3:0]=hour[3:0]+1;
if(hour[3:0]==4'd10)
begin
hour[3:0]=4'd0;
hour[7:4]=hour[7:4]+1;
end
end
end
reg [3:0] buffer;
always
begin
buffer=count1[1:0];
//led=26'b00000000000000000000000000;
end
/////////////////////////////led fa guang shan shuo////////////////////////////////
always @(buffer)
begin
case(buffer)
2'b00: led=4'b0000;
2'b10: led=4'b1111;
endcase
end
/*////////////////////////////////////shineng////////////////////////////////////////
always@(dispdat1,dispdat2,dispdat3,dispdat4,dispdat5,dispdat6)
begin
*/
endmodule |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|