当前位置:首页 >> 学科竞赛 >>

袁章亦安


设计思路: 1. 两位的循环 LED 灯,自定义的循环 LED 灯; 2. 用按键控制数码管加减; 源码: module led_s(rst,clk,leds); input rst,clk; output [15:0] leds; reg [15:0] leds; reg [3:0]count; always @(posedge clk) begin if (rst) coun

t <=16 'h00_00; else begin if(count==4'hf) count <=16 'h00_00; else count <=count+1; end end always @(count) begin case(count) 0: leds<= 16 'b0000_0000_0000_0001; 1: leds<= 16 'b0000_0000_0000_0010; 2: leds<= 16 'b0000_0000_0000_0100; 3: leds<= 16 'b0000_0000_0000_1000; 4: leds<= 16 'b0000_0000_0001_0000; 5: leds<= 16 'b0000_0000_0010_0000; 6: leds<= 16 'b0000_0000_0100_0000; 7: leds<= 16 'b0000_0000_1000_0000; 8: leds<= 16 'b0000_0001_0000_0000; 9: leds<= 16 'b0000_0010_0000_0000; 10: leds<=16 'b0000_0100_0000_0000; 11: leds<=16 'b0000_1000_0000_0000; 12: leds<=16 'b0001_0000_0000_0000; 13: leds<=16 'b0010_0000_0000_0000; 14: leds<=16 'b0100_0000_0000_0000; 15: leds<=16 'b1000_0000_0000_0000;

default: leds<=16 'hxxxx; endcase end endmodule //4 位加减计数器 module counter_2(rst,add,sub,coun); input add,sub,rst; output[3:0]coun; reg [3:0]coun_add,coun_sub; always @(posedge add or posedge rst) begin if(rst) coun_add<=4'b0000; else coun_add<=coun_add+1; end always @(posedge sub or posedge rst) begin if(rst) coun_sub<=4'b0000; else coun_sub<=coun_sub-1; end assign coun=coun_add+coun_sub; endmodule //7 段译码电路 module seg7(en,indata,outdata); input[3:0] indata; input en; output[7:0] outdata; reg [7:0] outdata; always @(en or indata) if(en) case(indata) //abcd_efgh 4'd0: outdata<=8'b1111_1100; 4'd1: outdata<=8'b0110_0000; 4'd2: outdata<=8'b1101_1010; 4'd3: outdata<=8'b1111_0010; 4'd4: outdata<=8'b0110_0110;

4'd5: outdata<=8'b1011_0110; 4'd6: outdata<=8'b1011_1110; 4'd7: outdata<=8'b1110_0000; 4'd8: outdata<=8'b1111_1110; 4'd9: outdata<=8'b1111_0110; 4'd10: outdata<=8'b1110_1110; 4'd11: outdata<=8'b0011_1110; 4'd12: outdata<=8'b1001_1100; 4'd13: outdata<=8'b0111_1010; 4'd14: outdata<=8'b1001_1110; 4'd15: outdata<=8'b1000_1110; default: outdata<=8'bxxxx_xxxx; endcase endmodule 仿真:仿真通过 结果:按照预想进行,用按键控制数码管加减,LED 灯两位的循环。


相关文章:
袁章亦安
袁章亦安_学科竞赛_高中教育_教育专区。设计思路: 1. 两位的循环 LED 灯,自定义的循环 LED 灯; 2. 用按键控制数码管加减; 源码: module led_s(rst,clk,...
更多相关标签:
安保器材专卖店 亦庄 | 亦欢难安 | 亦安画廊 | 山东亦安咨询有限公司 | 亦安国际旅行 | 亦安物流 | 亦欢难安全文阅读 | 亦欢难安txt |