您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Verilog实例.rar
  所属分类: Java
  开发工具:
  文件大小: 683kb
  下载次数: 0
  上传时间: 2009-08-06
  提 供 者: lpy****
 详细说明: /* 本实验实现一个能显示小时,分钟,秒的数字时钟。 */ module clock(clk,rst,dataout,en); input clk,rst; output[7:0] dataout; reg[7:0] dataout; output[7:0] en; reg[7:0] en; reg[3:0] dataout_buf[7:0]; reg[25:0] cnt; reg[15:0] cnt_scan; reg[3:0] dataout_code; wire[5:0] cal; //各级进位标志 ass ign cal[0]=(dataout_buf[0]==9)?1:0; assign cal[1]=(cal[0]&&dataout_buf[1]==5)?1:0; assign cal[2]=(cal[1]&&dataout_buf[3]==9)?1:0; assign cal[3]=(cal[2]&&dataout_buf[4]==5)?1:0; assign cal[4]=(cal[3]&&dataout_buf[6]==9)?1:0; assign cal[5]=(cal[3]&&dataout_buf[6]==2&&dataout_buf[7]==1)?1:0; always@(posedge clk or negedge rst) begin if(!rst) begin cnt_scan<=0; en<=8'b1111_1110; end else begin cnt_scan<=cnt_scan+1; if(cnt_scan==16'hffff) begin en[7:1]<=en[6:0]; en[0]<=en[7]; end end end always@(*) begin case(en) 8'b1111_1110: dataout_code=dataout_buf[0]; 8'b1111_1101: dataout_code=dataout_buf[1]; 8'b1111_1011: dataout_code=dataout_buf[2]; 8'b1111_0111: dataout_code=dataout_buf[3]; 8'b1110_1111: dataout_code=dataout_buf[4]; 8'b1101_1111: dataout_code=dataout_buf[5]; 8'b1011_1111: dataout_code=dataout_buf[6]; 8'b0111_1111: dataout_code=dataout_buf[7]; default: dataout_code=dataout_buf[0]; endcase end always@(posedge clk or negedge rst) begin if(!rst) cnt<=0; else if(cnt!=40000000) cnt<=cnt+1; else cnt<=0; end always@(posedge clk or negedge rst) //实现计数和进位的功能 begin if(!rst) begin dataout_buf[0]<=0; dataout_buf[1]<=0; dataout_buf[2]<=15; dataout_buf[3]<=0; dataout_buf[4]<=0; dataout_buf[5]<=15; dataout_buf[6]<=2; dataout_buf[7]<=1; end else begin if(cnt==26'd40000000) begin if(!cal[0]) dataout_buf[0]<=dataout_buf[0]+1; else begin dataout_buf[0]<=0; if(!cal[1]) dataout_buf[1]<=dataout_buf[1]+1; else begin dataout_buf[1]<=0; if(!cal[2]) dataout_buf[3]<=dataout_buf[3]+1; else begin dataout_buf[3]<=0; if(!cal[3]) dataout_buf[4]<=dataout_buf[4]+1; else begin dataout_buf[4]<=0; if(!cal[4]) dataout_buf[6]<=dataout_buf[6]+1; else begin dataout_buf[6]<=0; if(!cal[5]) dataout_buf[7]<=dataout_buf[7]+1; else dataout_buf[7]<=0; end end end end end end end end always@(dataout_code) begin case(dataout_code) 4'b0000: dataout=8'b0000_0011; 4'b0001: dataout=8'b1001_1111; 4'b0010: dataout=8'b0010_0101; 4'b0011: dataout=8'b0000_1101; 4'b0100: dataout=8'b1001_1001; 4'b0101: dataout=8'b0100_1001; 4'b0110: dataout=8'b0100_0001; 4'b0111: dataout=8'b0001_1111; 4'b1000: dataout=8'b0000_0001; 4'b1001: dataout=8'b0001_1001; 4'b1010: dataout=8'b0001_0001; 4'b1011: dataout=8'b1100_0001; 4'b1100: dataout=8'b0110_0011; 4'b1101: dataout=8'b1000_0101; 4'b1110: dataout=8'b0110_0001; 4'b1111: dataout=8'b1111_1110; endcase end endmodule ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: Verilog实例
 输入关键字,在本站1000多万海量源码库中尽情搜索: