关键代码:
always@(posedge sys_clk)
count=count+1;
assign clk=count[24];
always@(posedge clk)
begin
case(state)
3'b000:led=8'b01111111;
3'b001:led=8'b10111111;
3'b010:led=8'b11011111;
3'b011:led=8'b11101111;
3'b100:led=8'b11110111;
3'b101:led=8'b11111011;
3'b110:led=8'b11111101;
3'b111:led=8'b11111110;
endcase
state=state+1;
end
运行视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_3CCF9DFDF77B771B_false_EEA982EE6B20F4D1_1/player.swf
源程序分享:LED_pao1.rar
没有信号是显示F
关键代码:
always@(posedge clk or negedge rstn)
begin
case(sw)
8'b11111111:sm_seg=8'h8e;//f
8'b11111110: sm_seg=8'hf9;//1
8'b11111101: sm_seg=8'ha4;//2
8'b11111011: sm_seg=8'hb0;//3
8'b11110111: sm_seg=8'h99;//4
8'b11101111: sm_seg=8'h92;//5
8'b11011111: sm_seg=8'h82;//6
8'b10111111: sm_seg=8'hf8;//7
8'b01111111: sm_seg=8'h80;//8
endcase
end
assign sm_dig=8'b00000000;
运行视频
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_4BF536BAAD227135_false_EEA982EE6B20F4D1_1/player.swf
源代码分享:swshumaguan.rar
关键代码:
//-------------------设定扫描频率-------------------------------
always @(posedge clk or negedge rstn)
if(!rstn) delay<=26'd0;
else
begin
if(delay==26'd24999999)
begin
delay_1s<=~delay_1s;
delay<=26'd0;
end
else
begin
delay<=delay+1'b1;
end
end
always @(posedge clk or negedge rstn)
if(!rstn) delay_1k<=15'd0;
else
if(delay_1k==15'd4999)
begin
cnt<=~cnt;
delay_1k<=15'd0;
end
else
delay_1k<=delay_1k+1'b1;
//----------------60 S 计数器------------------------------
always@(posedge delay_1s or negedge rstn)
if(!rstn) begin
num_ge<=4'd0;
num_shi<=3'd0;
end
else
begin
if(num_ge==4'd9&&num_shi<3'd5)
begin
num_ge<=4'd0;
num_shi<=num_shi+3'd1;
end
else if(num_ge==4'd9&&num_shi==3'd5)
begin
num_ge<=4'd0;
num_shi<=3'd0;
end
else
begin
num_ge<=num_ge+4'd1;
end
end
运行视频
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_2E4027B9411AB916_false_EEA982EE6B20F4D1_1/player.swf
源代码分享:jishu60.rar
关键源代码:
always@(posedge clk or negedge rstn)
begin
if(!rstn)
LED<=1'b1;
else if(!key_in)
LED<=~LED;
else
LED<=LED;
end
实现视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_DCCE5344C99BC8F9_false_EEA982EE6B20F4D1_1/player.swf
分享源程序:anjiankongLED.rar
关键代码:
always@(posedge clk or negedge rstn)
begin
if(!rstn)
disp_dat<=3'd0;
else
begin
if(key_in)
disp_dat<=disp_dat+1'b1;
else if(disp_dat>=4'ha)
disp_dat<=4'h0;
else
case(disp_dat)
4'h9:sm_seg=8'h90;//9
4'h8:sm_seg=8'h80;//8
4'h7:sm_seg=8'hf8;//7
4'h6:sm_seg=8'h82;//6
4'h5:sm_seg=8'h92;//5
4'h4:sm_seg=8'h99;//4
4'h3:sm_seg=8'hb0;//3
4'h2:sm_seg=8'ha4;//2
4'h1:sm_seg=8'hf9;//1
4'h0:sm_seg=8'hc0;//0
endcase
end
end
视频分享:
源程序分享:anjiankongshumguan1-9.rar
关键代码:
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_samp<=1'b1;
else
key_samp<=key_in;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_samp_r<=1'b1;
else
key_samp_r<=key_samp;
end
assign key_scan=key_samp_r&(~key_samp);
always@(posedge clk or negedge rstn)
begin
if(!rstn)
cnt<=20'h0;
else if(key_scan)
cnt<=20'h0;
else
cnt<=cnt+1'b1;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_rstn<=1'b1;
else if(cnt<=20'hfffff)
key_rstn<=key_in;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_rstn_r<=1'b1;
else
key_rstn_r<=key_rstn;
end
assign key_low=key_rstn_r&(~key_rstn);
实现的视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_9BA553490045B4D7_false_EEA982EE6B20F4D1_1/player.swf
程序分享:xiaodouanjiankongzhiLED.rar
关键代码:
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_samp<=1'b1;
else
key_samp<=key_in;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_samp_r<=1'b1;
else
key_samp_r<=key_samp;
end
assign key_scan=key_samp_r&(~key_samp);
always@(posedge clk or negedge rstn)
begin
if(!rstn)
cnt<=20'h0;
else if(key_scan)
cnt<=20'h0;
else
cnt<=cnt+1'b1;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_rstn<=1'b1;
else if(cnt<=20'hfffff)
key_rstn<=key_in;
end
always@(posedge clk or negedge rstn)
begin
if(!rstn)
key_rstn_r<=1'b1;
else
key_rstn_r<=key_rstn;
end
assign key_low=key_rstn_r&(~key_rstn);
always@(posedge clk or negedge rstn)
begin
if(!rstn)
disp_dat<=3'd0;
else
begin
if(key_low)
disp_dat<=disp_dat+1'b1;
else if(disp_dat>=4'ha)
disp_dat<=4'h0;
else
case(disp_dat)
4'h9:sm_seg=8'h90;//9
4'h8:sm_seg=8'h80;//8
4'h7:sm_seg=8'hf8;//7
4'h6:sm_seg=8'h82;//6
4'h5:sm_seg=8'h92;//5
4'h4:sm_seg=8'h99;//4
4'h3:sm_seg=8'hb0;//3
4'h2:sm_seg=8'ha4;//2
4'h1:sm_seg=8'hf9;//1
4'h0:sm_seg=8'hc0;//0
endcase
end
end
endmodule
实现视频:
程序分享:xiaodouanjiankongshumguan1-9.rar
实验代码:
module beep(clk,
rstn,
beep
);
input clk;
input rstn;
output beep;
reg beep;
reg [24:0] div_cnt;
reg [14:0] delay_cnt;
wire [14:0] delay_end;
parameter clk_divider0=56817;
parameter clk_divider1=28408;
assign delay_end=div_cnt[24] ? clk_divider0:clk_divider1;
always @(posedge clk or negedge rstn)
begin
if (!rstn)
div_cnt<=25'd0;
else
div_cnt<=div_cnt+1'b1;
end
always @(posedge clk or negedge rstn)
begin
if (!rstn)
delay_cnt<=delay_end;
else if(delay_cnt==15'b0)
begin
beep<=~beep;
delay_cnt<=delay_end;
end
else
delay_cnt<=delay_cnt-1'b1;
end
endmodule
实现视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_713D9E0542DBE933_false_EEA982EE6B20F4D1_1/player.swf
源工程文件分享:jiuhuche1.rar
源代码:
module fengming(clk, beep);
input clk;
output beep;
reg beep;
reg [27:0] tone;
reg [14:0] counter;
always @(posedge clk)
begin
tone <= tone+1;
end
wire [6:0] fastsweep = (tone[22] ? tone[21:15] : ~tone[21:15]);
wire [6:0] slowsweep = (tone[25] ? tone[24:18] : ~tone[24:18]);
wire [14:0] clkdivider = {2'b01, (tone[27] ? slowsweep : fastsweep), 6'b000000};
always @(posedge clk)
begin
if(counter==0) counter <= clkdivider;
else counter <= counter-1;
end
always @(posedge clk)
begin
if(counter==0)
beep <= ~beep;
end
endmodule
实现视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_4C3F2787DA0F236A_false_EEA982EE6B20F4D1_1/player.swf
分享源代码:jingche.rar
实验十二(简易电子琴)
源代码:
module qing(clk,key,beep,led);
input clk;
input[7:0]key;
output beep;
output[7:0] led;
reg beep_reg;
reg[7:0]key_reg;
reg[22:0]counter,count_end;
reg key_flg;
initial key_flg = 1'b0;
always@(posedge clk)
begin
counter = counter + 1;
if(counter==count_end)
begin
counter = 0;
if(key_flg==1'b1)
beep_reg = ~beep_reg;
else beep_reg = 1'b0;
end
end
always@(counter[10:9])
begin
key_reg = key;
if(key_reg!=8'hff)key_flg = 1'b1;
else key_flg = 1'b0;
case(key_reg)
8'b11111110: count_end=20'd47774;
8'b11111101: count_end=20'd42568;
8'b11111011: count_end=20'd37919;
8'b11110111: count_end=20'd35791;
8'b11101111: count_end=20'd31888;
8'b11011111: count_end=20'd28409;
8'b10111111: count_end=20'd25309;
8'b01111111: count_end=20'd23912;
8'b01111110: count_end=20'd21282;
8'b01111101: count_end=20'd18961;
8'b01111011: count_end=20'h17897;
8'b01110111: count_end=20'd15944;
8'b01011111: count_end=20'd14205;
8'b00111111: count_end=20'd12655;
default: count_end=20'hfffff;
endcase
end
assign beep = beep_reg;
assign led = ~key_reg;
endmodule
实现视频:
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_A392966CE1D8D457_false_EEA982EE6B20F4D1_1/player.swf
分享源代码:yinjiandianziqing.rar
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图四被打赏50分 | |
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 |