FPGA课程设计报告.docx
- 文档编号:4661466
- 上传时间:2022-12-07
- 格式:DOCX
- 页数:23
- 大小:576.79KB
FPGA课程设计报告.docx
《FPGA课程设计报告.docx》由会员分享,可在线阅读,更多相关《FPGA课程设计报告.docx(23页珍藏版)》请在冰豆网上搜索。
FPGA课程设计报告
西安邮电学院
FPGA课程设计报告
题目:
采用RAM实现计数器及FPGA功能验证
院系:
电子工程学院
专业班级:
学生姓名:
导师姓名:
起止时间:
2012-06-18至2012-06-29
2012年07月01日
FPGA课程设计报告提纲
1.任务
用一个10×8的双口RAM完成10个8位计数器,计数器的初值分别为1~10,时钟频率为1MHz,计数器计数频率为1Hz。
用FPGA开发板上的按键作为计数器计数值的输出选择控制,数码管(或led)作为选择计数器的计数值输出。
2.目的
采用RAM实现计数器及FPGA功能验证
3.使用环境(软件/硬件环境,设备等)
前仿modelsim
后仿modelsim
FPGA课程设计详细内容
4.1技术规范
1、先由RAM的数据读控制端在10个RAM地址中预置的8位初值。
2、将RAM存储的数据作为计数器的初始值,由计数器的控制端和分频器分频的时钟信号1Hz控制开始计数,暂停键暂停计数并同时存入RAM中赋计数器初始值的存储单元。
3、双端口RAM为10×8RAM由一个地址切换键按顺序切换1~10个地址端口。
4.系统工作流程:
切换端口→→RAM预置初始值→→读出数据→→
开始计数→→七段显示译码器译码→→输出到数码管显示。
5、分频:
将时钟频率为1MHz分频为计数器计数频率1Hz,用来进行秒计时。
4.2设计方案,功能验证方案,以及电路设计源代码,功能仿真激励源代码及功能仿真结果报告:
1、RAM的功能模块:
wr
rd
addr_in[3:
0]
din[7:
0]dout[7:
0]
RAM:
reg[7:
0]ram[10:
1]10×8的RAM存储阵列10个字每个子8位
输入端输入地址addr_in[3:
0];
输入数据din[7:
0];
上升沿有效写入信号wr;
输出数据dout[7:
0];
上升沿有效读信号rd;
端口
功能
Rd
读使能高电平有效;系统使能工作,将din数据写入ram的存储单元中
Wr
写使能高电平有效;将ram存储单元中的数据读出dout。
Addr_in
模块内控制读写地址;系统的模值控制
Din
数据输入口,内部接口
Dout
数据输出,内部数据传送
Reset
初始化置数,电平触发
RAM的地址切换:
双端口RAM为10×8RAM由地址切换键按顺序切换1~10个地址端口
addr_in[3:
0]
Ram存储单元
0001
0000_0001
0010
0000_0010
0011
0000_0011
0100
0000_0100
0101
0000_0101
0110
0000_0110
0111
0000_0111
1000
0000_1000
1001
0000_1001
1010
0000_1010
程序:
inputwr,rd;
inputreset,clk_1mhz;
inputaddr_in;
wire[3:
0]addr_in;
input[7:
0]din;
wire[7:
0]din;
output[7:
0]dout;
reg[7:
0]dout;
reg[7:
0]mem[10:
1];
always@(posedgeclk_1mhz,negedgereset)
begin
if(!
reset)
begin
mem[1]<=8'd1;mem[2]<=8'd2;
mem[3]<=8'd3;mem[4]<=8'd4;
mem[5]<=8'd5;mem[6]<=8'd6;
mem[7]<=8'd7;mem[8]<=8'd8;
mem[9]<=8'd9;mem[10]<=8'd10;
end
elseif(wr==1&&rd==0)
mem[addr_in]<=din;
elseif(rd==1&&wr==0)
dout<=mem[addr_in];
end
Endmodule
激励模块:
moduletest;
regclk_1mhz,wr,rd,reset;
reg[7:
0]din;
reg[3:
0]addr_in;
wire[7:
0]dout;
ramram(wr,rd,reset,dout,clk_1mhz,din,addr_in);
initial
begin
reset=1'd1;clk_1mhz=1'd0;
wr=1'd0;rd=1'd0;
addr_in=4'd0;
#2reset=1'd0;
#2rd=1'd1;
#2addr_in=4'd0;#2addr_in=4'd1;
#2addr_in=4'd2;#2addr_in=4'd3;#2addr_in=4'd4;
#2addr_in=4'd5;#2addr_in=4'd6;#2addr_in=4'd7;
#2addr_in=4'd8;#2addr_in=4'd9;#2addr_in=4'd10;
#3rd=1'd0;wr=1'd1;
din=8'd60;
#3din=8'd20;#3din=8'd25;#3din=8'd10;#3din=8'd6;
end
always
foreverbegin
#1clk_1mhz=~clk_1mhz;
end
Endmodule
2、计数器的功能模块:
rd
clk_1hz
dout[7:
0]din[7:
0]
start
stopcount_reset
计数:
开始计数start
计数器复位count_reset;
计数输出din[7:
0];
计数暂停stop;
程序:
moduleJSQ(dout,start,stop,din,clk_1hz,count_reset);
output[7:
0]din;
input[7:
0]dout;
inputstart,stop,clk_1hz,count_reset;
reg[7:
0]din;
always@(posedgeclk_1hz)
begin
if(!
count_reset)din=dout;
else
if(din==8'd255)din=8'd0;
elseif((start==1)&&(stop==0))din=din+1;
elsedin=din;
end
endmodule
激励模块:
moduletest;
wire[7:
0]din;
reg[7:
0]dout;
regstart,stop,clk_1hz,count_reset;
JSQff(dout,start,stop,din,clk_1hz,count_reset);
initial
begin
stop=1'd0;
start=1'd0;
clk_1hz=1'd0;
count_reset=1'd0;
#2dout=8'd1;
#3count_reset=~count_reset;
#2start=1'd1;
#30start=~start;
#1dout=8'd9;
#3count_reset=~count_reset;
#2start=1'd1;
end
always
foreverbegin
#1clk_1hz=~clk_1hz;
end
endmodule
3、’数码管的显示功能模块:
din[7:
0]dout[7:
0]
Reset复位时三位数码管显示为000.
程序:
moduleSMG(dout,hex_b,hex_s,hex_g);
input[7:
0]dout;
output[7:
0]hex_b;
output[7:
0]hex_s;
output[7:
0]hex_g;
reg[7:
0]hex_b;
reg[7:
0]hex_s;
reg[7:
0]hex_g;
reg[3:
0]dout_b;
reg[3:
0]dout_s;
reg[3:
0]dout_g;
always@(dout)
begin
begin
dout_b=dout/100;
dout_s=dout/10;
dout_g=dout%10;
case(dout_b)
4'd0:
hex_b=8'hC0;
4'd1:
hex_b=8'hF9;
4'd2:
hex_b=8'hA4;
4'd3:
hex_b=8'hB0;
4'd4:
hex_b=8'h99;
4'd5:
hex_b=8'h92;
4'd6:
hex_b=8'h82;
4'd7:
hex_b=8'hf8;
4'd8:
hex_b=8'h80;
4'd9:
hex_b=8'h90;
default:
hex_b=8'hC0;
endcase
case(dout_s)
4'd0:
hex_s=8'hC0;
4'd1:
hex_s=8'hF9;
4'd2:
hex_s=8'hA4;
4'd3:
hex_s=8'hB0;
4'd4:
hex_s=8'h99;
4'd5:
hex_s=8'h92;
4'd6:
hex_s=8'h82;
4'd7:
hex_s=8'hf8;
4'd8:
hex_s=8'h80;
4'd9:
hex_s=8'h90;
default:
hex_s=8'hC0;
endcase
case(dout_g)
4'd0:
hex_g=8'hC0;
4'd1:
hex_g=8'hF9;
4'd2:
hex_g=8'hA4;
4'd3:
hex_g=8'hB0;
4'd4:
hex_g=8'h99;
4'd5:
hex_g=8'h92;
4'd6:
hex_g=8'h82;
4'd7:
hex_g=8'hf8;
4'd8:
hex_g=8'h80;
4'd9:
hex_g=8'h90;
default:
hex_g=8'hC0;
endcase
end
end
Endmodule
激励模块:
moduletest;
reg[7:
0]dout;
wire[7:
0]hex_b;
wire[7:
0]hex_s;
wire[7:
0]hex_g;
SMGsmg(dout,hex_b,hex_s,hex_g);
initial
begin
dout=8'd0;
#2dout=8'd9;
#2dout=8'd99;
#2dout=8'd199;
end
endmodule
4、分频器功能模块:
clk
clk_1hz//clk_1mhz
分频:
将时钟频率为50MHz分频为计数器计数频率1Hz,用来进行秒计时。
分频:
将时钟频率为50MHz分频为计数器计数频率1MHz,用来进行ram控制输入、输出。
分频:
时钟信号clk;
分频信号clk_1hz、clk_1mhz;
程序:
moduleFPQ(clk,clk_1hz,clk_1mhz,reset);
inputclk;
inputreset;
outputclk_1hz,clk_1mhz;
regclk_1hz,clk_1mhz;
reg[29:
0]cnt;
reg[4:
0]cnt1;
//?
?
?
always@(posedgeclk,negedgereset)
begin
if(!
reset)
begin
clk_1mhz=0;cnt1<=5'd0;
end
else
if(cnt1==5'd25)
begin
cnt1<=5'b0;
clk_1mhz<=~clk_1mhz;
end
else
cnt1<=cnt1+1'b1;
end
always@(posedgeclk,negedgereset)
begin
if(!
reset)
begin
clk_1hz=0;cnt<=30'd0;
end
else
if(cnt==30'd2500_0000)
begin
cnt<=30'b0;
clk_1hz<=~clk_1hz;
end
else
cnt<=cnt+1'b1;
end
endmodule
激励模块:
moduletest;
regclk,reset;
wireclk_1hz,clk_1mhz;
FPQFRQ1(clk,clk_1hz,clk_1mhz,reset);
initial
begin
clk=1'd0;
reset=1'd0;
#9reset=1'd1;
end
always
begin
#1clk=~clk;
end
endmodule
5、总体模块:
Clk
总程序:
moduleram(wr,rd,clk,start,stop,reset,dout,clk_1hz,clk_1mhz,count_reset,din,addr_in,hex_b,hex_s,hex_g);
inputwr,rd;
inputclk;
inputstart,stop,reset,count_reset;
inputaddr_in;
wire[3:
0]addr_in;
output[wordlength-1:
0]din;
reg[wordlength-1:
0]din;
output[wordlength-1:
0]dout;
reg[wordlength-1:
0]dout;
outputclk_1hz,clk_1mhz;
regclk_1hz,clk_1mhz;
reg[wordlength-1:
0]mem[addrlength:
1];
reg[29:
0]cnt;
reg[4:
0]cnt1;
parameterwordlength=8;
parameteraddrlength=10;
output[7:
0]hex_b;
output[7:
0]hex_s;
output[7:
0]hex_g;
reg[7:
0]hex_b;
reg[7:
0]hex_s;
reg[7:
0]hex_g;
reg[3:
0]dout_b;
reg[3:
0]dout_s;
reg[3:
0]dout_g;
//分频器
always@(posedgeclk,negedgereset)
begin
if(!
reset)
begin
clk_1mhz=0;cnt1<=5'd0;
end
else
if(cnt1==5'd25)
begin
cnt1<=5'b0;
clk_1mhz<=~clk_1mhz;
end
else
cnt1<=cnt1+1'b1;
end
always@(posedgeclk,negedgereset)
begin
if(!
reset)
begin
clk_1hz=0;cnt<=30'd0;
end
else
if(cnt==30'd2500_0000)
begin
cnt<=30'b0;
clk_1hz<=~clk_1hz;
end
else
cnt<=cnt+1'b1;
end
//RAM
always@(posedgeclk_1mhz,negedgereset)
begin
if(!
reset)
begin
mem[1]<=8'd1;mem[2]<=8'd2;
mem[3]<=8'd3;mem[4]<=8'd4;
mem[5]<=8'd5;mem[6]<=8'd6;
mem[7]<=8'd7;mem[8]<=8'd8;
mem[9]<=8'd9;mem[10]<=8'd10;
end
elseif(wr==1&&rd==0)
mem[addr_in]<=din;
elseif(rd==1&&wr==0)
dout<=mem[addr_in];
end
//计数器
always@(posedgeclk_1hz,negedgecount_reset)
begin
if(!
count_reset)din=8'd0;
elseif(rd)din=dout;
elseif(din==8'd255)din=8'd0;
elseif((start==1)&&(stop==0))din=din+1;
elsedin=din;
end
//数码管显示
always@(doutorreset)
begin
if(!
reset)
begin
hex_b=8'hC0;
hex_s=8'hC0;
hex_g=8'hC0;
end
else
begin
dout_b=din/100;
dout_s=din/10;
dout_g=din%10;
case(dout_b)
4'd0:
hex_b=8'hC0;
4'd1:
hex_b=8'hF9;
4'd2:
hex_b=8'hA4;
4'd3:
hex_b=8'hB0;
4'd4:
hex_b=8'h99;
4'd5:
hex_b=8'h92;
4'd6:
hex_b=8'h82;
4'd7:
hex_b=8'hf8;
4'd8:
hex_b=8'h80;
4'd9:
hex_b=8'h90;
default:
hex_b=8'hC0;
endcase
case(dout_s)
4'd0:
hex_s=8'hC0;
4'd1:
hex_s=8'hF9;
4'd2:
hex_s=8'hA4;
4'd3:
hex_s=8'hB0;
4'd4:
hex_s=8'h99;
4'd5:
hex_s=8'h92;
4'd6:
hex_s=8'h82;
4'd7:
hex_s=8'hf8;
4'd8:
hex_s=8'h80;
4'd9:
hex_s=8'h90;
default:
hex_s=8'hC0;
endcase
case(dout_g)
4'd0:
hex_g=8'hC0;
4'd1:
hex_g=8'hF9;
4'd2:
hex_g=8'hA4;
4'd3:
hex_g=8'hB0;
4'd4:
hex_g=8'h99;
4'd5:
hex_g=8'h92;
4'd6:
hex_g=8'h82;
4'd7:
hex_g=8'hf8;
4'd8:
hex_g=8'h80;
4'd9:
hex_g=8'h90;
default:
hex_g=8'hC0;
endcase
end
end
endmodule
4.3综合及布局布线报告和引脚分布报告
管脚图:
Toassignmentnamevalueenable
clkLocationPIN_N2Yes
addr_in[0]LocationPIN_U3Yes
addr_in[1]LocationPIN_U4Yes
addr_in[2]LocationPIN_V1Yes
addr_in[3]LocationPIN_V2Yes
count_resetLocationPIN_N23Yes
hex_b[0]LocationPIN_AB23Yes
hex_b[1]LocationPIN_V22Yes
hex_b[2]LocationPIN_AC25Yes
hex_b[3]LocationPIN_AC26Yes
hex_b[4]LocationPIN_AB26Yes
hex_b[5]LocationPIN_AB25Yes
hex_b[6]LocationPIN_Y24Yes
hex_g[0]LocationPIN_AF10Yes
hex_g[1]LocationPIN_AB12Yes
hex_g[2]LocationPIN_AC12Yes
hex_g[3]LocationPIN_AD11Yes
hex_g[4]LocationPIN_AE11Yes
hex_g[5]LocationPIN_V14Yes
hex_g[6]LocationPIN_V13Yes
hex_s[0]LocationPIN_V20Yes
hex_s[1]LocationPIN_V21Yes
hex_s[2]LocationPIN_W21Yes
hex_s[3]LocationPIN_Y22Yes
hex_s[4]LocationPIN_AA24Yes
hex_s[5]LocationPIN_AA23Yes
hex_s[6]LocationPIN_AB24Yes
rdLocationPIN_N25Yes
resetLocationPIN_G26Yes
startLocationPIN_N26Yes
stopLocationPIN_P25Yes
wrLocationPIN_AE14Yes
4.6后仿真结果报告
前仿真图:
后仿真结果报告
4.7硬件测试结果报告
下载到实验板上可实现四位地址切换对应1~10个地址
wr键用来读取RAM中的数据到计数器
start键开始计数
Stop键停止计数
Rd将数读入到RAM对应的存储单元中
Re
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- FPGA 课程设计 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)