试用Veriloghdl设计一个七段数码管的显示译码器,要求可以同时兼容共阴共阳数码管

发布时间:2019-08-09 15:26:27

当兼容控制端sel=1时为共阳译码器,当兼容控制器sel=0时为共阴译码器
急啊,考试快结束了,。。。。开卷考试

推荐回答

module led8_display(clk,rst,sel,en,play);input clk;input rst;input sel;output[7:0] en;output[7:0] play;reg[30:0] count;reg[7:0] en;reg[7:0] play;always@(posedge clk or negedge rst)begin if(!rst) begin if(sel)//共阳译码 begin count<=0; en<=1; play<=8'b00111111; end else begin count<=0; en<=0; play<=8'b11000000; end end else begin count<=count+1; case(count[30:28]) 3'b000: begin if(consel) begin en<=8'b00000001; play<=8'b00111111; end elsebegin en<=8'b11111110; play<=8'b11000000; endend 3'b001: begin if(sel) begin en<=8'b00000010; play<=8'b00000110; end else begin en<=8'b11111101; play<=8'b11111001; endend 3'b010: begin if(consel)begin en<=8'b00000100; play<=8'b01011011; end else begin en<=8'b11111011; play<=8'b10100100; endend 4'b011: begin if(consel) begin en<=8'b00001000; play<=8'b01001111; end else begin en<=8'b11110111; play<=8'b10110000; endend endcase endendendmodule这个是我刚刚写的4位7段数码管流水灯显示1---4的程序,希望对你有用,按题目要求,你只需把代码中时钟分频器寄存器变量count删去、output reg[7:0] en;改成“output reg en,4位动态case显示改成单数码管静态显示就行了……
以上问题属网友观点,不代表本站立场,仅供参考!