搜索
bottom↓
回复: 0

大家帮看看这段程序----数字钟的

[复制链接]

出0入0汤圆

发表于 2010-3-8 15:41:49 | 显示全部楼层 |阅读模式
下面程序编译能过,但不能综合,警告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周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-6-10 14:38

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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