北航电子电路设计数字部分实验报告.docx

上传人:cl****1 文档编号:558357979 上传时间:2023-01-14 格式:DOCX 页数:6 大小:14.51KB
返回 下载 相关 举报
北航电子电路设计数字部分实验报告.docx_第1页
第1页 / 共6页
北航电子电路设计数字部分实验报告.docx_第2页
第2页 / 共6页
北航电子电路设计数字部分实验报告.docx_第3页
第3页 / 共6页
北航电子电路设计数字部分实验报告.docx_第4页
第4页 / 共6页
北航电子电路设计数字部分实验报告.docx_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《北航电子电路设计数字部分实验报告.docx》由会员分享,可在线阅读,更多相关《北航电子电路设计数字部分实验报告.docx(6页珍藏版)》请在金锄头文库上搜索。

1、北航电子电路设计数字部分实验报告电子电路设计数字部分实验报告学院:姓名:实验一简单组合逻辑设计实验内容描述一个可综合的数据比较器, 比较数据a、b的大小,若相同,则给出结果1,否则给出结果0。实验仿真结果实验代码主程序 modulecompare(equal,a,b);input7:0a,b;outputequal;assigneq ual=(ab)?1:0;endmodule 测试程序 modulet;reg7:0a,b;regclock,k;wireequal;initialbegina=0;b= 0;clock=0;k=0;endalways#50clock= clock;always(

2、posedgeclock )begina0 = $random%2;a1 = $random%2;a 2 = $random%2;a 3 = $random%2;a4 = $random%2;a5 = $random%2;a6 = $ran dom%2;a7 = $random%2;b0 = $random%2;b1 = $random%2;b = $random%2;b3 = $random%2;b4 = $random%2;b5 = $ra ndom%2;b6 = $random%2;b7 = $random%2;endinitialbegin#1 0$stop;endcomparem(.

3、equal(equal),.a(a),.b(b);endmodule 实验二简单分频时序逻辑电路的设计实验内容用always块和 (posedgeclk)或(negedgeclk)的结构表述一个1/2分频器的可综 合模型,观察时序仿真结果。实验仿真结果实验代码主程序modulehalf_clk(reset,clk_in,clk_out);inputclk_in,reset;outp utclk_out;regclk_out;always(negedgeclk_in)beginif(!reset)c lk_out=0;elseclk_out= clk_out;endendmodule 测试程序

4、timescale1ns/1psdefineclk_cycle50moduletop;regclk,reset ;wireclk_out;always#clk_cycleclk= clk;initialbeginclk=0;re set=1;#10reset=0;#110reset=1;#10$stop;endhalf clkm0(.re set(reset),.clk_in(clk),.clk_out(clk_out);endmodule 实验三利用条件语句实现计数分频时序电路实验内容利用10MHz的时钟, 设计一个单周期形状的周期波形。实验仿真结果实验代码主程序modulefdivisio

5、n(RESET,F10M,out);inputF10M,RESET;outputout;r egout;reg7:0i;always(posedgeF10M)if(!RESET)beginout=0;i =0;endelseif(i=2|i=3)beginout= out;i=i+1;endelseif(i= 5)i=1;elsei=i+1;endmodule 测试程序timescale1ns/1psmoduledivision_top;regF10M,RESET;wireout ;always#50F10M=F10M;initialbeginRESET=1;F10M=0;#90RESET=0

6、;#1RESET=1;#1$stop;endfdivisionfdivision(.RESET(RESET) ,.F10M(F10M),.out(out);endmodule实验四阻塞赋值与非阻塞赋 值的区别实验内容比较四种不同的写法,观察阻塞与非阻塞赋值的 区别。Blocking:always(posedgeclk)beginb=a;c=b;endBlocking1:always(posedgeclk)beginc=b;b=a;endBlocking2:always(posedgeclk)b=a;always(posedgeclk)c=b;non_Blocki ng:always(posed

7、geclk)beginb=a;c=b;End 实验仿真结果实验代 码主程序moduleblocking(clk,a,b,c);output3:0b,c;input3:0a;inputc lk;reg3:0b,c;always(posedgeclk)beginb=a;c=b;endendmodule 测试部分timescale1ns/1psinclude“./blocking.vinclude“./bloc king1.vinclude“./blocking2.vinclude“./non_blocking. v“modulecompareTop;wire3:0b11,c11,b12,c12,b

8、13,c13,b2,c2;reg3:0a;regclk;initialbeginclk=0;forever#50clk= clk;endin itialbegina=4,h3;$display(d“,a);#1a=4,h7;$display(d“,a);#1a=4,hf;$display(d“,a);#1a=4,ha;$display(d“,a);#1a=4,h2;$display(d“,a);#1$stop;endblockingblocking(clk,a,b 11,c11);blocking1blocking1(clk,a,b12,c12);blocking2blocking 2(clk

9、,a,b13,c13);non_blockingnon_blocking(clk,a,b2,c2);endm odule实验五用always块实现较复杂的组合逻辑实验目的运用 always块设计一个8路数据选择器。要求:每路输入数据与输出数 据均为4位2进制数,当选择开关(至少3位)或输入数据发生变 化时,输出数据也相应地变化。实验仿真结果实验代码主程序modulealu(out,opcode,a1,a2,a3,a4,a5,a6,a7,a8);output3:0ou t;reg3:0out;input3:0a0,a1,a2,a3,a4,a5,a6,a7;input2:0o pcode;alwa

10、ys(opcodeora1ora2ora3ora4ora5ora6ora7ora0)beginc ase(opcode)3, d0:out=a0;3, d1:out=a1;3, d2:out=a2;3, d3:out=a3;3, d4:out=a4;3, d5:out=a5;3, d6:out=a6;3, d7:out=a7;default:out=4,b;endcaseendendmodule 测试程序 timescale1ns/1nsinclude“./main5.v“modulealutext;wire3: 0out;reg3:0a1,a2,a3,a4,a5,a6,a7,a8;reg2:

11、0opcode;initia lbegina1=$random%16;a2=$random%16;a3=$random%16;a4=$ random%16;a5=$random%16;a6=$random%16;a7=$random%16; a8=$random%16;repeat(1)begin#1opcode=$random%8;a1= $random%16;a2=$random%16;a3=$random%16;a4=$random%16 ;a5=$random%16;a6=$random%16;a7=$random%16;a8=$rando m%16;end#1$stop;endalu

12、alu(out,opcode,a1,a2,a3,a4,a5,a6,a 7,a8);endmodule实验六在VerilogHDL中使用函数实验目的设计一 个带控制端的逻辑运算电路,分别完成正整数的平方、立方和最大 数为5的阶乘运算。实验仿真结果实验代码主程序moduletryfunct(clk,n,result1,result2,result3,reset);output 31:0result1,result2,result3;input3:0n;inputreset,clk;reg 31:0result1,result2,result3;always(posedgeclk)beginif(!

13、r eset)beginresult1=0;result2=0;result3=0;endelsebeginresu lt1=fun1(n);result2=fun2(n);result3=fun3(n);endendfuncti on31:0fun1;input3:0operand;fun1=operand*operand;endfunc tionfunction31:0fun2;input3:0operand;beginfun2=operand* operand;fun2=operand*fun2;endendfunctionfunction31:0fun3; input3:0operan

14、d;reg3:0index;beginfun3=1;if(operand11)f or(index=2;index=operand;index=index+1)fun3=index*fun3;els efor(index=2;index=10;index=index+1)fun3=index*fun3;endend functionendmodule 测试程序 include“./main6.vtimescale1ns/1psmoduletryfunctTop;r eg3:0n,i;regreset,clk;wire31:0result1,result2,result3;i nitialbeg

15、inclk=0;n=0;reset=1;#1reset=0;#1reset=1;for(i = 0;i=15;i = i+1)begin#2n=i;end#1$stop;endalways#50clk= cl k;tryfunctm(.clk(clk),.n(n),.result1(result1),.result2(resu lt2),.result3(result3),.reset(reset);endmodule 实验七在VerilogHDL中使用任务(task)实验目的用两种不同方法设计一个功 能相同的模块,该模块能完成四个8位2进制输入数据的冒泡排序。 第一种,模仿原题例子中用纯组合逻辑实现;第二种,假设8位数据是按照时钟节拍串行输入的,要求用时钟 触发任务的执行法,每个时钟周期完成一次数据交换操作。实验仿真结果实验代码主程序1modulerank(ra,rb,rc,rd,a,b,c,d);output7:0ra,rb,rc,rd;inp ut7:0a,b,c,d;reg7:0ra,rb,rc,rd,va,vb,vc,vd,tmp;regi;alw ays(aorborcord)beginva,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > PPT模板库 > 其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号