我选择第四种方案:申请核心板和外围板 成品板
实验名称:
实验目的:
掌握FPGA及外围系统的基本应用,通过FPGA做视频数据处理,信号处理,编码显示
实验概要:
1 常规实验
2 数据处理
3 编解码
4 IP核应用
5 数据采集卡实现
基于FPGA的图像处理系统设计
23 号终于收到板子了
图片稍后再补
先上一段 led_flash程序
module Led_Flash(
sysclk,
sysrst,
led,
);
input sysclk;
input sysrst;
output [7:0] led;
reg [7:0] led;
reg [25:0] delay_cnt;
always @(posedge sysclk or negedge sysrst)
begin
if(!sysrst)
delay_cnt <= 25'd0;
else
if(delay_cnt == 25'd25000000) //反转间隔 500ms
begin
delay_cnt <= 0;
led <= ~led;
end
else
delay_cnt <= delay_cnt + 1;
end
endmodule
流水灯程序 一会上视频
module led_water(
sysclk,
sysrst,
led,
);
input sysclk;
input sysrst;
output [7:0] led;
reg [7:0] led;
reg [25:0] delay_cnt;
reg [2:0] state;
always @(posedge sysclk or negedge sysrst)
begin
if(!sysrst)
begin
delay_cnt <= 25'd0;
state <= 2'd0;
end
else
if(delay_cnt == 25'd25000000)
begin
delay_cnt <= 0;
state <= state + 1'b1;
case(state)
3'b000 : led <= 8'b00000001;
3'b001 : led <= 8'b00000010;
3'b010 : led <= 8'b00000100;
3'b011 : led <= 8'b00001000;
3'b100 : led <= 8'b00010000;
3'b101 : led <= 8'b00100000;
3'b110 : led <= 8'b01000000;
3'b111 : led <= 8'b10000000;
endcase
end
else
delay_cnt <= delay_cnt + 1;
end
endmodule
让DIY 开发板上的8 个LED 实现向左流水灯的功能。
代码
module Led_Flash(
sysclk,
sysrst,
led,
);
input sysclk;
input sysrst;
output [7:0] led;
reg [7:0] led;
reg [25:0] delay_cnt;
reg [2:0] state;
always @(posedge sysclk or negedge sysrst)
begin
if(!sysrst)
begin
delay_cnt <= 25'd0;
state <= 2'd0;
end
else
if(delay_cnt == 25'd24999999)
begin
delay_cnt <= 0;
if(led==8'b00000000)
led<=8'b11111111;
else
led<=led>>1;
/*
state <= state + 1'b1;
case(state)
3'b000 : led <= 8'b00000001;
3'b001 : led <= 8'b00000010;
3'b010 : led <= 8'b00000100;
3'b011 : led <= 8'b00001000;
3'b100 : led <= 8'b00010000;
3'b101 : led <= 8'b00100000;
3'b110 : led <= 8'b01000000;
3'b111 : led <= 8'b10000000;
endcase
*/
end
else
delay_cnt <= delay_cnt + 1;
end
endmodule
a) 让 DIY开发板上的 8 个 LED实现向左跑马灯的功能
module Led_Flash(
sysclk,
sysrst,
led,
);
input sysclk;
input sysrst;
output [7:0] led;
reg [7:0] led;
reg [25:0] delay_cnt;
reg [2:0] state;
always @(posedge sysclk or negedge sysrst)
begin
if(!sysrst)
begin
delay_cnt <= 25'd0;
state <= 2'd0;
led<=8'b01111111;
end
else
if(delay_cnt == 25'd24999999)
begin
delay_cnt <= 0;
if(led==8'b11111111)
led<=8'b01111111;
else
led<={led[0],led[7:1]};
/*
state <= state + 1'b1;
case(state)
3'b000 : led <= 8'b00000001;
3'b001 : led <= 8'b00000010;
3'b010 : led <= 8'b00000100;
3'b011 : led <= 8'b00001000;
3'b100 : led <= 8'b00010000;
3'b101 : led <= 8'b00100000;
3'b110 : led <= 8'b01000000;
3'b111 : led <= 8'b10000000;
endcase
*/
end
else
delay_cnt <= delay_cnt + 1;
end
endmodule
b) 实现花样彩灯功能,即程序包含点亮 LED、LED 闪烁灯、流水
灯、跑马灯。 (流水灯可实现花样流水,如两边向内流水,从内
向两边流水) 。提示:可用 case语句实现。
我做的是双向流水灯 (状态机)
module Led_Flash(
sysclk,
sysrst,
led,
);
input sysclk;
input sysrst;
output [7:0] led;
reg [7:0] led;
reg [25:0] delay_cnt;
reg [2:0] state;
always @(posedge sysclk or negedge sysrst)
begin
if(!sysrst)
begin
delay_cnt <= 25'd0;
state <= 2'd10;
led<=8'b11111110;
end
else
if(delay_cnt == 25'd2499999)
begin
delay_cnt <= 0;
//if(led==8'b11111111)
//led<=8'b01111111;
case(state)
2'b01:begin
led<={led[0],led[7:1]};
if(led==8'b11111101)
state<=2'b10;
end
2'b10:
begin
led<={led[6:0],led[7]};
if(led==8'b10111111)
state<=2'b01;
end
endcase
/*
state <= state + 1'b1;
case(state)
3'b000 : led <= 8'b00000001;
3'b001 : led <= 8'b00000010;
3'b010 : led <= 8'b00000100;
3'b011 : led <= 8'b00001000;
3'b100 : led <= 8'b00010000;
3'b101 : led <= 8'b00100000;
3'b110 : led <= 8'b01000000;
3'b111 : led <= 8'b10000000;
endcase
*/
end
else
delay_cnt <= delay_cnt + 1;
end
endmodule
数码管+按键程序
/*module sm(CLK,RESET,LED);
input CLK,RESET;
output[7:0] LED;
reg[7:0] LED;
always @(CLK)
begin
LED[1]<=1;
end
endmodule
*/
module sm(CLK,RESET,DIG,SEG,KEY);
input CLK,RESET;
input [7:0] KEY;
output[7:0] DIG;
output[7:0] SEG;
reg[2:0] cnt_8;
reg[15:0] cnt_1khz;
always @(posedge CLK or negedge RESET)
begin
if(!RESET)
begin
cnt_1khz <= 0;
cnt_8 <= 0;
end
else
begin
if(cnt_1khz == 16'd4999999)
begin
cnt_1khz <= 0;
cnt_8 <= cnt_8 + 1'b1;
end
else
cnt_1khz <= cnt_1khz + 1'b1;
end
end
reg[7:0] DIG,SEG;
reg[3:0] dat;
reg [3:0] temp;
always @(cnt_8[2:0])
begin
case(cnt_8[2:0])
3'b000:begin DIG <= 8'b01111111;dat[3:0] <= temp; end
3'b001:begin DIG <= 8'b10111111;dat[3:0] <= temp; end
3'b010:begin DIG <= 8'b11011111;dat[3:0] <= temp; end
3'b011:begin DIG <= 8'b11101111;dat[3:0] <= temp; end
3'b100:begin DIG <= 8'b11110111;dat[3:0] <= temp; end
3'b101:begin DIG <= 8'b11111011;dat[3:0] <= temp; end
3'b110:begin DIG <= 8'b11111101;dat[3:0] <= temp; end
3'b111:begin DIG <= 8'b11111110;dat[3:0] <= temp; end
default: begin DIG <= 8'bz;dat <= 3'bz; end
endcase
case(dat[3:0])
4'b000:begin SEG[7:0] <= 8'hC0; end
4'b001:begin SEG[7:0] <= 8'hF9; end
4'b010:begin SEG[7:0] <= 8'hA4; end
4'b011:begin SEG[7:0] <= 8'hB0; end
4'b100:begin SEG[7:0] <= 8'h99; end
4'b101:begin SEG[7:0] <= 8'h92; end
4'b110:begin SEG[7:0] <= 8'h82; end
4'b111:begin SEG[7:0] <= 8'hF8; end
4'b1000:begin SEG[7:0] <= 8'h80; end
4'b1001:begin SEG[7:0] <= 8'h90; end
default: begin SEG <= 8'hz; end
endcase
end
reg [19:0] delay_count;
always @(posedge CLK or negedge RESET)
begin
if(!RESET)
delay_count<=0;
else
delay_count<=delay_count+1;
end
reg KEY_IN;
wire KEY_IN_R;
always @(posedge CLK or negedge RESET)
begin
if(!RESET)
KEY_IN<=0;
else if(!KEY[0])
KEY_IN<=1;
else
KEY_IN<=0;
end
assign KEY_IN_R = KEY_IN;
always @(posedge KEY_IN_R)
begin
if(temp>9)
temp<=0;
else
temp<=temp+1;
end
endmodule
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |