西安交通大学数字电子技术实验报告
更新时间:2024-07-11 07:33:01 阅读量: 综合文库 文档下载
西安交通大学数字电子技
术实验报告
实验三、ISE基础
实验预习:
(1) 安装ISE13.4软件。
(2) 按照视频文件“Verilog语言输入法D_Flip_Flop.exe”进行演练。
实验内容和步骤:
下载开发板相关器件的Datasheet,了解其性能。
按照P249附录A“FPGA实验预习报告模板”中的内容和步骤,完成D触发器的设计、综合、实现、仿真和下载全过程,熟悉ISE编程环境和用Adept下载编程文件的方法。 1. 在G盘用自己的学号建立文件夹,进入用自己学号建立的文件夹后,再建立本次实验
的文件夹,及本次实验所建工程的文件夹,文件夹名可以起名为:D_Flip_Flop、My_FirstISE、或Experiment_1、或Test_1,等等。 2. 建立工程文件。
3. 输入D触发器的Verilog程序。 4. 编写D触发器的约束文件。 5. 综合、实现及生成编程文件。 6. 基于ISim的行为仿真。
7. 采用Adept软件下载 *.bit 程序到开发板。 8. 测试D触发器的逻辑功能。
通过D触发器设计熟悉ISE软件后,自己设计一个门电路,例如与非门,重复以上ISE软件的使用步骤。
验收:
1. 按照老师布置的逻辑门电路设计Verilog语言程序、约束文件、下载、仿真。要能说明
任一时刻输入输出的逻辑关系。 2. 能够用开发板演示所设计的逻辑功能。
实验程序
1.VERILOG工程文件 module D_Flip_Flop( input clk,
input set, input D, input clr,
output reg q //注意:always模块中的输出必须是寄存器型变量 );
always @(posedge clk or posedge clr or posedge set)
begin
if(clr) q<=0; else if(set) q<=1; else q<=D;
end
endmodule 2.约束文件
NET \ //时钟 NET \ //SW7 NET \ //SW1 NET \ //SW0 NET \ //LD7 3.仿真文件
module test_D_Flip_Flop; // Inputs
reg clk; reg set; reg D; reg clr;
// Outputs
wire q;
// Instantiate the Unit Under Test (UUT)
D_Flip_Flop uut ( );
.clk(clk), .set(set), .D(D), .clr(clr), .q(q)
initial begin
// Initialize Inputs clk=0;
set=1; D=0; clr=0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here End
always#10clk=~clk; always#12D=~D; always#33clk=~clk; always#42set=~set; endmodule 仿真结果:
实验四、组合逻辑电路实验Ⅰ(2学时)
组合逻辑Ⅰ:
(1)使用VERILOG设计一个新的逻辑功能(比如四输入或门、或非门、与或非门等等),并在开发板上验证,比如:
进实验室前编写好VERILOG源文件、约束文件和仿真文件(见4.1.2,P101(2))。 (2)设计新的多路选择器(三选一、五选一等等),并在开发板上验证。实验前编写好VERILOG源文件、用户约束文件和仿真文件,实验报告中要给出仿真波形(见4.3,P111(2))。 (查看仿真波形、验收逻辑功能)
(3)查看74LS138的Datasheet,用Verilog语言设计一个3-8译码器。用三个逻辑开关作为输入,8个LED灯作为输出,验证所设计的3-8译码器的逻辑功能。(选做) 实验程序
1.VERILOG设计逻辑函数
(1).VERILOG程序
module gate2( input a, input b, input c, input d, output z );
assign z=~((a&b)|(c&d)); endmodule
(2).约束文件 NET \NET \NET \NET \NET \(3).仿真程序
#100;
// Add stimulus here #100;a<=0;b<=0;c<=0;d<=1; #200;a<=0;b<=0;c<=1;d<=0; #200;a<=0;b<=0;c<=1;d<=1;
#200;a<=0;b<=1;c<=0;d<=0; #200;a<=0;b<=1;c<=0;d<=1; #200;a<=0;b<=1;c<=1;d<=0; #200;a<=0;b<=1;c<=1;d<=1; #200;a<=1;b<=0;c<=0;d<=0; #200;a<=1;b<=0;c<=0;d<=1; #200;a<=1;b<=0;c<=1;d<=0; #200;a<=1;b<=0;c<=1;d<=1; #200;a<=1;b<=1;c<=0;d<=0; #200;a<=1;b<=1;c<=0;d<=1;
#200;a<=1;b<=1;c<=1;d<=0; #200;a<=1;b<=1;c<=1;d<=1;
#200;
end
仿真结果
2.四选一多路选择器 (1)VERILOG程序 module MUX( input wire a, input wire b, input wire c, input wire d, input wire s1, input wire s2, output wire y );
assign y=(a&(~s1)&(~s2))|(b&(~s1)&(s2))|(c&(s1)&(~s2))|(d&(s1)&(s2));
endmodule }
(2)约束文件 NET\NET\NET\NET\NET\NET\NET\
(3)仿真程序 #100 a<=1; b<=0; c<=0; d<=0; s1<=0; s2<=0; #400 a<=0; b<=1; c<=0; d<=0; s1<=0; s2<=1; #400 a<=0; b<=0; c<=1; d<=0; s1<=1;
s2<=0; #400 a<=0; b<=0; c<=0; d<=1; s1<=1; s2<=1;
end
(3)仿真结果
3.3-8译码器 (1)VERILOG程序 module yimaqi38( input wire [2:0]a, output wire [7:0]y );
assign y[0]=~a[2]&~a[1]&~a[0];
assign y[1]=~a[2]&~a[1]&a[0]; assign y[2]=~a[2]&a[1]&~a[0]; assign y[3]=~a[2]&a[1]&a[0]; assign y[4]=a[2]&~a[1]&~a[0]; assign y[5]=a[2]&~a[1]&a[0]; assign y[6]=a[2]&a[1]&~a[0]; assign y[7]=a[2]&a[1]&a[0];
endmodule (2)约束文件 NET\NET\NET\
NET\NET\NET\NET\NET\NET\NET\NET\
实验五、组合逻辑电路实验Ⅱ(2学时)
组合逻辑Ⅱ:
(1)完成4位数码管动态显示设计(见P121),实现将8个SW输入的两位十六进制数对应的8421BCD码,显示在数码管上。数码转换关系表4-2所示(见P115),比如,若在8个开关SW上输入2FH,四个数码管由左到右应显示0215。实验前编写好VERILOG源文件、用户约束文件等。(验收逻辑功能) 。
实现将8个SW输入的两位十六进制数对应的十进制数,显示在数码管上。比如,若在8个开关SW上输入7FH,四个数码管由左到右应显示127。实验前编写好VERILOG源文件、用户约束文件等。(验收逻辑功能) 。(选做)
(2)参考P126,:用Verilog语言设计一个4位全加器,给出布线后仿真波形,测试加法器的延时(要求在预习报告中完成)。(查看布线后仿真波形)。
(3)用Verilog语言设计一个4位比较器。用两组、每组4个逻辑开关作为输入,比较两组逻辑开关输入二进制数的大小,用三个LED灯指示比较结果,三个逻辑指示灯分别指示大于、等于、小于。(选做) 实验程序
1.2位16进制数码管 (1)VERILOG代码 input wire [7:0]x,
input wire clk,
input wire clr,
output reg [6:0]a_to_g, output reg [3:0]an
); wire s;
reg [3:0]digit; reg [19:0]clkdiv; assign s=clkdiv[19];
always@(*)
case(s)
0:if(x[3:0]>=4'b1010) digit=x[3:0]-4'b1010;
else
digit=x[3:0];
1:if(x[3:0]>=4'b1010) digit=4'b0001;
else
digit=4'b0000;
2:if(x[7:4]>=4'b1010)
digit=x[7:4]-4'b1010;
else
digit=x[7:4];
3:if(x[7:4]>=4'b1010)
digit=4'b0001;
else
digit=4'b0000;
default:digit=4'b0000; endcase
always@(*) case(digit)
0:a_to_g= 7'b0000001;
1:a_to_g= 7'b1001111; 2:a_to_g= 7'b0010010; 3:a_to_g= 7'b0000110; 4:a_to_g= 7'b1001100; 5:a_to_g= 7'b0100100; 6:a_to_g= 7'b0100000; 7:a_to_g= 7'b0001111; 8:a_to_g= 7'b0000000; 9:a_to_g= 7'b0000100; 'hA:a_to_g= 7'b0001000; 'hB:a_to_g= 7'b1100000;
'hC:a_to_g= 7'b0110001; 'hD:a_to_g= 7'b1000010; 'hE:a_to_g= 7'b0110000; 'hF:a_to_g= 7'b0111000; default:a_to_g= 7'b0000001;
endcase always@(*) begin an=4'b1111; an[s]=0; end
always@(posedge clk or posedge clr) begin if(clr==1) clkdiv<=0; else
clkdiv<=clkdiv+1; end
endmodule (2)约束文件
NET\NET\
NET\NET\NET\NET\NET\
NET\NET\NET\NET\NET\NET\
NET\NET\NET\NET\NET\NET\NET\NET\2.4位全加器
(1)VERILOG代码 module jiafaqi( input wire[3:0] a, input wire[3:0] b, output wire[3:0] s, output wire c4 ); wire[4:0] c; assign c[0]=0; assign s=a^b^c[3:0];
assign c[4:1]=a&b|c[3:0]&(a^b); assign c4=c[4]; endmodule (2)约束文件 NET\NET\NET\NET\NET\NET\NET\NET\
NET\NET\NET\NET\NET\3.4位比较器 (1)VERILOG代码 module bijiaoqi( input wire [3:0]A, input wire [3:0]B, output reg [2:0]y );
always@ (A or B) begin if(A>B)
y<=3'b001; else if(A==B) y<=3'b010; else y<=3'b100;
end
endmodule 2.约束文件 NET\NET\NET\NET\NET\NET\NET\NET\NET\NET\NET\
实验六、时序逻辑电路实验Ⅰ(2学时)
时序逻辑Ⅰ:
(1)设计一个秒脉冲发生器,用LED指示秒脉冲的发放(P144,(3))。(检查秒脉冲发生器的精度、能将1秒的脉冲周期改为2秒或3秒等);
(2) 试设计一个带有异步清零和同步置数信号的4位寄存器,并在开发板上验证(P145,(2))。将时钟信号改为2Hz或4Hz,观察异步清零和同步置数现象。(验收逻辑功能)
(3)设计一个具有同步清零、同步置数端的十进制加法计数器。选1Hz信号作为CLK信号,4个LED灯指示计数状态,一个逻辑开关做清零端,另一个逻辑开关做置数端。(选做)
(4)设计一个具有异步清零、同步置数端的4位二进制加法计数器。选1Hz信号作为CLK信号,4个LED灯指示计数状态,一个逻辑开关做清零端,另一个逻辑开关做置数端。(选做) 实验内容 1. 秒脉冲发生器
(1)VERILOG程序
module maichong( input clk,clr, output reg[0:0]q );
reg [26:0] counter; always @(posedge clk)
if(counter==25000000) counter <= 0; else counter <= counter+1; reg clk_div; always @(posedge clk)
if(counter==25000000) clk_div <= ~clk_div; always@(posedge clk_div or posedge clr)
begin if(clr==1) q<=0; else if(q==2) q<=0; else q<=q+1; end endmodule (2)约束文件
NET\NET\
NET\ //LED4
2. 异步清零同步置数四位寄存器
(1)VERILOG程序 module jicunqi( input load, input clk, input clr, input wire [3:0]d, output reg [3:0]q );
reg [27:0]q1;
always @(posedge clk or posedge clr) begin if(clr==1) q1<=0; else q1<=q1+1; end
assign mclk=q1[27];
always @(posedge mclk or posedge clr) begin if(clr==1) q<=0; else if(load==1) q<=d; end endmodule (1)约束文件 NET\NET\NET\
NET\NET\NET\NET\NET\NET\NET\NET\
3. 同步清零同步置数十进制加法器
实验七、时序逻辑电路实验Ⅱ(2学时) 时序逻辑Ⅱ:
(1)用层次化自顶向下的设计方法设计一个60进制计数器,用动态数码管显示计数值,时钟采用1Hz信号,观察计数效果;
(2)用层次化自顶向下的设计方法设计一个24进制计数器,用动态数码管显示计数值,时钟采用1Hz信号,观察计数效果;
(3)设计一个完整的数字钟,小时和分钟用数码管显示,秒用发光二极管闪烁显示,每秒闪烁一次。如有可能,请增加校时功能(选做)
实验内容
1.60进制计数器 (1)VERILOG程序 module top ( input wire clk,
input wire clk0, input wire clr1,
output wire [3:0]Second_an, output wire [6:0]Second_q );
wire jinwei; //模块间链接定义(注意须是wire)
Second instance_Second ( .clk(clk), .sec(sec) );
cnt60 instance_cnt60 ( .clk(sec), .clr(clr), .clk0(clk0),
.cnt60_an(Second_an), .cnt60_q(Second_q), .carry(carry) );
//这里省去了60进制计数器进位输出变量carry
Endmodule module Second( input wire clk,
output reg sec );
endmodule module cnt60( input wire clk,
input wire clr, input wire clk0, reg q1;
always @(posedge clk) begin if(q1==1) begin q1<=0;
sec<=~sec; //得到1Hz信号 end else q1<=q1+1; end
output reg [3:0]cnt60_an, output reg [6:0]cnt60_q,
output reg carry );
reg [3:0]cntl;
reg [3:0]cnth;
reg [19:0]clkdiv; //初始化 initial begin cntl=8; cnth=5; end
//60进制计数器
always @(posedge clk ) begin carry=0; cntl=cntl+1; if(cntl==9) begin
cntl=0; cnth=cnth+1; end
if(cnth==5&&cntl==9)
begin cntl=0; cnth=0;
carry=1; //carry是60进制计数器的进位 end end wire s;
reg [3:0]di=10; assign s=clkdiv[19];
always@(*) case(s) 0:di=cntl; 1:di=cnth; endcase
always@(*) case(di)
0:cnt60_q=7'b0000001; 1:cnt60_q=7'b1001111; 2:cnt60_q=7'b0010010; 3:cnt60_q=7'b0000110;
4:cnt60_q=7'b1001100; 5:cnt60_q=7'b0100100; 6:cnt60_q=7'b0100000; 7:cnt60_q=7'b0001111; 8:cnt60_q=7'b0000000; 9:cnt60_q=7'b0000100; default:
begin
cnt60_q=7'b0000001; end
endcase
always@(*) begin
cnt60_an=4'b1111; cnt60_an[s]=0; end
always@(posedge clk0 or posedge clr) begin if(clr==1)
clkdiv=0; else
clkdiv=clkdiv+1; end
endmodule (2)约束文件 NET \NET \
NET \NET \NET \NET \NET \NET \NET \NET \NET \NET \NET \NET \
NET \2.24进制计数器 (1)VERILOG程序 module top ( input wire clk,
input wire clk0, input wire clr1,
output wire [3:0]Second_an, output wire [6:0]Second_q );
wire jinwei; //模块间链接定义(注意须是wire)
Second instance_Second ( .clk(clk), .sec(sec) );
cnt60 instance_cnt24 ( .clk(sec), .clr(clr), .clk0(clk0),
.cnt60_an(Second_an), .cnt60_q(Second_q),
.carry(carry) );
//这里省去了24进制计数器进位输出变量carry
Endmodule module Second( input wire clk, output reg sec );
reg q1;
always @(posedge clk) begin if(q1==1) begin q1<=0;
sec<=~sec; //得到1Hz信号 end else q1<=q1+1; end
endmodule module cnt24 ( input wire clk,
input wire clr, input wire clk0,
output reg [3:0]cnt60_an, output reg [6:0]cnt60_q, output reg carry );
reg [3:0]cntl;
reg [3:0]cnth;
reg [19:0]clkdiv; //初始化 initial begin cntl=2; cnth=1; end
//24进制计数器
always @(posedge clk ) begin carry=0;
cntl=cntl+1; if(cntl==9) begin
cntl=0; cnth=cnth+1; end
if(cnth==2&&cntl==3) begin cntl=0; cnth=0;
carry=1; //carry是24进制计数器的进位 end end wire s;
reg [3:0]di=10; assign s=clkdiv[19];
always@(*) case(s) 0:di=cntl; 1:di=cnth; endcase
always@(*) case(di)
0:cnt60_q=7'b0000001; 1:cnt60_q=7'b1001111; 2:cnt60_q=7'b0010010; 3:cnt60_q=7'b0000110; 4:cnt60_q=7'b1001100; 5:cnt60_q=7'b0100100; 6:cnt60_q=7'b0100000; 7:cnt60_q=7'b0001111; 8:cnt60_q=7'b0000000; 9:cnt60_q=7'b0000100; default:
begin
cnt60_q=7'b0000001; end
endcase
always@(*)
begin
cnt60_an=4'b1111; cnt60_an[s]=0; end
always@(posedge clk0 or posedge clr) begin if(clr==1) clkdiv=0; else
clkdiv=clkdiv+1; end
endmodule (2)约束文件 NET \NET \
NET \NET \NET \NET \NET \
NET \NET \NET \NET \NET \NET \NET \NET \3.数字钟
(1)VERILOG程序 module top( input wire clk1, input wire clk2, output wire [3:0]an, output wire [6:0]atog );
wire [6:0]minut; wire [5:0]hou; wire [3:0]min0; wire [2:0]min1; wire [3:0]h0; wire [1:0]h1;
wire [3:0]digit;
count_1 counter(clk1,minut,hou);
count_to_num editor(minut,hou,min0,min1,h0,h1); led_enable decoder(clk2,min0,min1,h0,h1,an,digit); seven_led show(digit,atog); endmodule
module count_1( input wire clk, output reg [6:0]minute, output reg [5:0]hour );
initial begin minute=0; hour=0; end
always @(posedge clk) begin
if(minute<59) minute<=minute+1; else begin minute<=0;
if(hour<23) hour<=hour+1; else hour<=0; end end
//always @(posedge clk) //begin
//if(hour<23) hour<=hour+1; //else hour<=0; //end Endmodule
module count_to_num( input wire [6:0]minute, input wire [5:0]hour, output reg [3:0]min0, output reg [2:0]min1, output reg [3:0]h0, output reg [1:0]h1 ); always @(*) begin
if(hour<10) begin h1<=0;h0<=hour; end
else if(hour<20&&hour>=10) begin h1<=1;h0<=hour-10; end else begin h1<=2;h0<=hour-20; end end always @(*) begin
if(minute<10) begin min1<=0;min0<=minute; end
else if(minute<20&&minute>=10) begin min1<=1;min0<=minute-10; end else if(minute<30&&minute>=20) begin min1<=2;min0<=minute-20; end else if(minute<40&&minute>=30) begin min1<=3;min0<=minute-30; end else if(minute<50&&minute>=40) begin min1<=4;min0<=minute-40; end else begin min1<=5;min0<=minute-50; end end endmodule
module led_enable( input wire clk, input wire [3:0]min0, input wire [2:0]min1, input wire [3:0]h0, input wire [1:0]h1, output reg [3:0]en, output reg [3:0]digit
正在阅读:
西安交通大学数字电子技术实验报告07-11
神奇的植物作文400字06-21
明清封建君主专制制度评析10-26
公园街道统计工作开展情况总结报告08-04
聚酯切片特性粘度对FDY生产的影响07-27
会计电算化专业毕业论文范文费下载04-21
法律文化2014电大网考作业答案05-31
管径尺寸对照表03-25
XX公司母亲节活动策划方案04-04
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 西安交通大学
- 电子技术
- 实验
- 数字
- 报告
- 华远五期绿色施工综合总结报告(1015) - 图文
- 云南省玉溪市二中高一地理下学期期末考试试题(含解析)
- 小企业信贷存在的主要风险点
- 排队机软件设置 - 图文
- 幼儿园结构设计
- 张毅刚 单片机习题参考答案
- 2017年二级建造师继续教育题库(必修课)
- 土木工程专业英语(带翻译)
- 冀教版小学一年级数学上册期中测试卷(B卷)
- 清华大学自动化系罗予频计原作业答案三
- 2016浙美版三年级上册美术试卷及答案
- 2018年伊春市中考地理试题与答案
- 内蒙古赤峰市届中考化学模拟试题(七)(含解析)
- 《快速跑》教学设计
- 中国债券市场的改革与发展
- 2019高考物理二轮阶段性效果检测17含答案
- 例题--中级会计师辅导《中级会计实务》第十四章讲义5
- 中智上海资深雇员俱乐部
- 嘉兴市委党校引进人才待遇
- 高三专题 - 中西雕塑 - 图文