1.实验目的:
熟悉Verilog语言的使用,熟练的使用modelsim软件,对老师期末布置的三个实验进行仿真。
2.实验内容:
1.数字逻辑基础与Verilog设计P160 图5.57
2.Verilog HDL(第二版)数字电路设计及仿真 十二章选题三
3.Verilog HDL(第二版)数字电路设计及仿真 P202 例6.40
3.实验原理:1.用书中D触发器的代码,运行仿真分析D触发器的原理。2.使用点阵进行电路设计,设计出8x8的点阵,控制发光二极管,从而使其可以显示特定的字符。
3.设计不带内嵌定时控制的非静态循环,具有数据依赖性的循环的迭代次数在仿真前不能确定。如果该循环没有内嵌定时控制,那么该行为能够被仿真但不能综合。在仿真时这种行为实际上是顺序执行的,但硬件不能在单个
时钟周期中完成循环的计算,可从第三个实验中中得到证实。
4实验工具:PC机和modelsim软件。
5.实验截图:第一个实验仿真结果
第二个实验仿真结果
第三个实验仿真结果
6.实验视频:
由于视频文件过大,作者已发布在哔哩哔哩app,请打开以下链接进行播放:
点阵实验:【点阵实验视频-哔哩哔哩】https://b23.tv/7tdldY
【数字电路基础、期末实验考试三大实验、详细讲解-哔哩哔哩】https://b23.tv/jDkuWO
7.实验代码:1.module rege(D,Clock,Resetn,E,Q);
input D,Clock,Resetn,E;
output reg Q;
always @(posedge Clock,negedge Resetn)
if(Resetn==0)
Q<=0;
else if(E)
Q<=D;
endmodule
2.module dianzhen8x8(line,column,clk, reset);
input clk, reset;
output [7:0] line, column;
reg [7:0] line, column;
reg[7:0] i,j,k; //
task dis; //
reg[7:0] column_tmp; //
reg[7:0] line_tmp; //
begin
case(i) //
0:column_tmp=8’h01; //
1:column_tmp=8’h02; //
2:column_tmp=8’h04;//
3:column_tmp=8’h08;//
4:column_tmp=8’h10;//
5:column_tmp=8’h20;//
6:column_tmp=8’h40;//
7:column_tmp=8’h80;//
default:column_tmp=8’h00;//
endcase
k=(i+j)%80; //
case(k) //
0:line_tmp = 8’h00; // V
1:line_tmp = 8’h40; //
2:line_tmp = 8’h78; //
3:line_tmp = 8’h04; //
4:line_tmp = 8’h02; //
5:line_tmp = 8’h04;//
6:line_tmp = 8’h78;//
7:line_tmp = 8’h40;//
8:line_tmp = 8’h00; //e
9:line_tmp = 8’h3C;//
10:line_tmp = 8’h52;//
11:line_tmp = 8’h92;//
12:line_tmp = 8’h92;//
13:line_tmp =8’h52;//
14:line_tmp= 8’h34;//
15:line_tmp= 8’h00;//
16:line_tmp = 8’h00; //r
17:line_tmp = 8’h00;//
18:line_tmp = 8’h80;//
19:line_tmp = 8’hFE;//
20:line_tmp = 8’h10;//
21:line_tmp = 8’h20;//
22:line_tmp = 8’h40;//
23:line_tmp = 8’h40;//
24:line_tmp = 8’h00; //i
25:line_tmp = 8’h00;//
26:line_tmp = 8’h00;//
27:line_tmp = 8’h20;//
28:line_tmp = 8’hBF;//
29:line_tmp = 8’h02; //
30:line_tmp = 8’h00;//
31:line_tmp = 8’h00;//
32:line_tmp = 8’h00; //1
33:line_tmp = 8’h00;//
34:line_tmp = 8’h00;//
35:line_tmp = 8’h7E; //
36:line_tmp = 8’h02;//
37:line_tmp= 8’h02;//
38:line_tmp = 8’h00;//
39:line_tmp =8’h00;//
40:line_tmp = 8’h00; // o
41:line_tmp = 8’h3C;//
42:line_tmp = 8’h42;//
43:line_tmp = 8’h42;//
44:line_tmp = 8’h42;//
45:line_tmp = 8’h3C;//
46:line_tmp = 8’h00;//
47:line_tmp = 8’h00;//
48:line_tmp = 8’h00;//
49:line_tmp = 8’h00;//
50:line_tmp =8’h64;//
51:line_tmp = 8’h92;//
52:line_tmp = 8’h92;//
53:line_tmp = 8’h6C;//
54:line_tmp = 8’h00; //
55:line_tmp = 8’h00;//
56:line_tmp = 8’h00; // H
57:line_tmp = 8’hFE;//
58:line_tmp = 8’h10; //
59:line_tmp = 8’h10; //
60:line_tmp = 8’h10;//
61:line_tmp = 8’h10;//
62:line_tmp = 8’hFE;//
63:line_tmp = 8’h00;//
64:line_tmp = 8’h00;//D
65:line_tmp = 8’h7E;//
66:line_tmp = 8’h42;//
67:line_tmp = 8’h42;//
68:line_tmp= 8’h42;//
69:line_tmp= 8’h3C;//
70:line_tmp= 8’h00;//
71:line_tmp= 8’h00;//
72:line_tmp= 8’h00;//1
73:line_tmp= 8’h00;//
74:line_tmp= 8’h7E;//
75:line_tmp = 8’h02;//
76:line_tmp = 8’h02;//
77:line_tmp = 8’h02;//
78:line_tmp = 8’h02; //
79:line_tmp = 8’h00; //
default:line_tmp = 8’h00;
endcase
column = column_tmp; //
line = line_tmp; //
end
endtask
always @(posedge clk )
if(reset)
begin
i=0;
j=0;
end
else
begin
i=i+1;//
if(i9)
begin
j=0; //
j=j+1;//
end //
if(j81)
j=0;//
dis;//?
end
endmodule
module tb8x8;
reg clk,reset;
wire [7:0] line, column;
initial
begin
clk=0;
reset=0;
#10 reset=1;
#10 reset=0;
#1000 $stop;
end
always #5 clk=~clk;
dianzhen8x8 i8x8 (line, column, clk, reset);
endmodule
3.module count_ones_c#( parameter data_width = 4,count_width = 3)(
output reg [count_width-1:0] bit_count,
input [data_width-1: 0] data,
input clk, reset
);
reg [count_width-1: 0] count, index;
reg [data_width-1:0] temp;
always @(posedge clk)
if (reset) begin count = 0; bit_count = 0; end
else begin
count=0;
temp = data;
for(index=0;| temp; index = index + 1) begin
if (temp[0] ) count = count+ 1;
temp=temp>>1;
end
bit_count= count;
end
endmodule
实验感悟:通过大量的Verilog代码的编写,熟悉了代码的格式,学会自己看懂代码,懂得实验原理,在老师的引领下,从懵懂无知,到逐渐步入了数字电路的世界,领悟Verilog语言的精妙和数字的电路的奇妙,不断进步,成为更严更博识更强大的学生。
版权声明:本文为CSDN博主「qq_54973177」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。