Verilog第七章答案

上传人:二*** 文档编号:109683467 上传时间:2022-06-17 格式:DOC 页数:6 大小:14.57KB
收藏 版权申诉 举报 下载
Verilog第七章答案_第1页
第1页 / 共6页
Verilog第七章答案_第2页
第2页 / 共6页
Verilog第七章答案_第3页
第3页 / 共6页
资源描述:

《Verilog第七章答案》由会员分享,可在线阅读,更多相关《Verilog第七章答案(6页珍藏版)》请在装配图网上搜索。

1、数字系统设计与Verilog HDL第七章答案(第6版)7.2module dflip(d,clk,q);input d,clk;output reg q;always (posedge clk)beginq=d;end endmodule /sturct design /*module dflip(d,clk,q,q_n);input d,clk;output q,q_n;/nand (out,input1,input2);/the struct of logic designwire g5,g6;nand G1 (q_n.g5,q) ;nand G2 (q,g6,q_n) ;nand G3

2、 (g5,clk,g6);nand G4 (g6,clk,d) ;endmodule */module D_Test(in,out,clk);input clk;input in;output 7:0out;dflip u1(.d(in),.clk(clk),.q(out1);dflip u2(.d(out1),.clk(clk),.q(out2);dflip u3(.d(out2),.clk(clk),.q(out3);dflip u4(.d(out3),.clk(clk),.q(out4);dflip u5(.d(out4),.clk(clk),.q(out5);dflip u6(.d(o

3、ut5),.clk(clk),.q(out6);dflip u7(.d(out6),.clk(clk),.q(out7);dflip u8(.d(out7),.clk(clk),.q(out0);endmodule7.3/*module JK_Model(clk,j,k,Q);input clk;input j,k;output Q;reg Q;always(posedge clk)Q=j&(Q)|(k)&Q;endmodule */module JK_Model(clk,j,k,Q,rs,set);input clk,j,k,set,rs;output Q;reg Q;always(pose

4、dge clk or negedge rs or negedge set)beginif(!rs)Q=1b0;else if(!set)Q=1b1;else case(j,k)2b00:Q=Q;2b01:Q=1b0;2b10:Q=1b1;2b11:Q=Q;default:Q=1bx;endcaseendendmodule7.4module Counter5(clk,reset,car,out);/car jup loadinput clk,reset;output car,out;reg2:0cnt;reg car;wire2:0out;assign out=cnt;always(posedg

5、e clk or negedge reset)beginif(!reset)begincnt=3b000;car=0;endelse begin if(cnt=3b100)/model=5begincar=3b001;/upcnt=3b000;endelse begin cnt=cnt+3b001;car=3b000;endendendendmodule7.5module Ser_to_Par(clk,rst,in,out); input clk,rst; input in; output3:0 out; /wire3:0 out; reg 3:0 shiftreg; always(posed

6、ge clk or negedge rst) if(!rst) shiftreg=0; else begin shiftreg=shiftreg3:1,in;/mix (shiftreg3,2,1),in end assign out=shiftreg;endmodule7.6module Par_to_Ser(clk,rst,in,out);input clk,rst;input3:0in;output out;reg out;reg1:0i;always(posedge clk)beginif(rst)begini=2d0;out=1d0;endelse if(i=3)begin out=

7、ini;i=i+1;endendendmodule7.8module data(data_in,data_out);input 7:0 data_in;output 7:0 data_out;reg7:0 data_out;always (data_in)beginif(data_in7)data_out=(data_in)+1)|8h80;elsedata_out=data_in;endendmodule7.9module Light(clk,ledout,reset);input reset,clk;output7:0 ledout;integer i;reg7:0ledout;reg2:

8、0count;reg4:0count2;reg clkflag;reg1:0in;always(posedge clk)beginif(!reset)count=0;else if(count=3)beginclkflag=0;count=count+1;endelse if(count =7)beginclkflag=1;count=0;endelsebeginclkflag=1;count=count+1;endendalways(posedge clk)beginif(!reset)count2=0;else if(count2=7)beginin=2b00;count2=count2+

9、1;endelse if(count2=15)beginin=2b01;count2=count2+1;endelse if(count2=23)beginin=2b10;count2=count2+1;endelse if(count2=23)beginin=2b10;count2=0;endendalways(clkflag or count or in or reset)beginif(!reset)ledout=8h00;elsebegincase(in)2b00:if(clkflag) ledout=8hff; else ledout=8h00;2b01:case(count)h0:ledout=8h80;h1:ledout=8h40;h2:ledout=8h20;h3:ledout=8h10;h4:ledout=8h08;h5:ledout=8h04;h6:ledout=8h02;h7:ledout=8h01;default:ledout=8h00;endcase2b10:if(clkflag)ledout=8haa; else ledout=8h00; default:ledout=8h00;endcaseendendendmodule

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!