实验步骤
1.实验目的:
学习移位寄存器
2.实验工具:
电脑和Quartur ii软件和modelsim软件。
3.实验过程:
第一步:打开Quartyr ii。
第二步:新建“Hew Project Wizard”。
第三步:将代码输入到“Venliog HDL Flie”。
第四步:保存。
第五步:编译。
第六步:生成测试文件。
第七步:进行仿真。
第八步:进行调试。
4.实验代码及结果截图
①module reg4(D, Clock, Resetn, Q);
input [3:0] D;
input Clock, Resetn;
output reg [3:0] Q;
always @(posedge Clock,negedge Resetn)
if (Resetn == 0)
Q<=4’b0000;
else
Q<=D;
endmodule
②module regne (D, Clock, Resetn, E, Q);
parameter n = 4;
input [n-1:0] D;
input Clock,Resetn,E;
output reg [n-1:0] Q;
always @(posedge Clock,negedge Resetn)
if (Resetn ==0)
Q<=0;
else if (E)
Q<=D;
endmodule
③module shift3 (w,Clock,Q);
input w,Clock;
output reg [1:3] Q;
always @(posedge Clock)
begin
Q[3]<=w;
Q[2]<=Q[3];
Q[1]<=Q[2];
end
endmodule
④module shift3 (w,Clock,Q);
input w,Clock;
output reg [1:3] Q;
always @(posedge Clock)
begin
Q[3]=w;
Q[2]=Q[3];
Q[1]=Q[2];
end
endmodule
⑤module count4 (Clock,Resetn, E,Q);
input Clock, Resetn, E;
output reg [3:0] Q;
always @(posedge Clock,negedge Resetn)
if (Resetn == 0)
Q<=0;
else if (E)
Q<=Q+1;
endmodule
6.实验总结
(1)通过本次实验学会如何调试波形图
(2)学习了移位寄存器
7.实验视频链接
http://m.v.qq.com/play.html?cid=&vid=p3247pu6182&vuid24=QGpUXQGBtSK8e15CLhVJFg%3D%3D&url_from=share&second_share=0&share_from=copy