EDAS设计DS1302.doc_第1页
EDAS设计DS1302.doc_第2页
EDAS设计DS1302.doc_第3页
EDAS设计DS1302.doc_第4页
EDAS设计DS1302.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

DS1302控制寄存器的设计一、总体的设计框图其中包括移位寄存器、计数器、控制器,各部分的引脚及功能如下:1)计数器加到16复为0,当n=8时,n8变为1,否则为0。2)移位寄存器clk:时钟脉冲;n8:当n=8时为1;rst:复位信号;indata:输入数据;z:选择dataio是作为输入口还是输出口;enwr:写入使能;n4:0:输入计数器的值;inone:输入命令字;dataout:数据输出;dataio:数据双向口;command0:命令字最低位;command6:命令字第六位;command7:命令字第七位;command15:命令字第一道第五位;3)控制器command0:命令字最低位,若为1则读,若为0则写;command6:命令字第六位,若为1则存取RAM数据,若为0则存取日历时钟数据;command7:命令字第七位,若为0,则写保护;command15:命令字第一至五位,表示操作单元的地址;ram_wr:写ram;ram_rd:读ram;ck_rd:读时钟数据;ck_wr:写时钟数据;enwr:若en=0,则写保护;二、基本原理及算法流程图首先通过移位寄存器将控制字写入,通过计数器计数值判断是否已经写完8位,然后控制器通过控制字来进行对数据的存取。三、各部分程序以及仿真1)计数器module countermy (sclk,rst,n,n8);input sclk;input rst;output reg 4:0n;output reg n8;always (posedge sclk)begin if (rst=0) n=0; else begin n=8) n8=1; else n8=0; if (n=15) n=0; end endendmodule2)移位寄存器module reg_shift(clk,indata,z,dataout,n8,enwr,dataio,rst,n,inone,command0,command6,command7,command15);input clk;input rst;input 4:0n;input inone;/输入一位命令字input indata;input z;/shu ru huo shu chuinput n8;input enwr;output reg command0;output reg command6;output reg command7;output reg 4:0command15; output reg dataout;inout dataio;reg dataio2;reg q;reg 7:0command;assign dataio=(!z)?dataio2:1bz;always(posedge clk)begin if(rst=0) command=8b0; else begin if (n=8) command=inone,command7:1; else if(enwr=1) begin command0=command0; command6=command6; command7=command7; command15=8) begin if (command0=0)/读数据,数据出去 /if (command6=0)/存取日历时钟数据 /else /存取RAM数据 /dataout=inone,dataout7:1; begin / dataio3=dataio2; if(!z) begin dataio2=indata; /dataout=1bz; end else begin dataio2=dataio; /dataout=dataio2; end /dataio2=dataio3; end endendendmodule3)控制器module control(command0,command6,command7,clk,rst,ram_wr,ram_rd,ck_wr,ck_rd,enwr);input command0;input command6;input command7;input clk;input rst;output reg ram_wr;output reg ram_rd;output reg ck_wr;output reg ck_rd;output reg enwr;always (posedge clk)begin if (rst=0) ram_wr,ram_rd,ck_wr,ck_rd=4b0; else enwr=0; case (command7,command6,command0) 3b100:begin ram_wr=0;ram_rd=0;ck_wr=1;ck_rd=0; end 3b101:begin ram_wr=0;ram_rd=0;ck_wr=0;ck_rd=1; end 3b110:begin ram_wr=1;ram_rd=0;ck_wr=0;ck_rd=0; end 3b111:begin ram_wr=0;ram_rd=1;ck_wr=0;ck_rd=0; end default: begin enwr=0;ram_wr=0;ram_rd=1;ck_wr=0;ck_rd=0; end endcaseendendmoduleComm

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论