/*数码管显示部分*/
/***********************************************************************/
always @ (posedge Clk, negedge Rst_n)
begin
if (!Rst_n)
Disp_data <= 32'haaaaaaaa;//32'hcccccccc
else
if (Key_flag == 1'b1
&& ((c_state ==IDLE && Key_value < 4'ha)
|| (c_state ==NUM_IN && Key_value < 4'ha)
|| (c_state ==CHANGE && Key_value < 4'ha)))
Disp_data <= {Disp_data[27:0], Key_value};
else if (Key_flag == 1'b1
&& ((c_state ==IDLE && Key_value == 4'hc)
|| (c_state ==NUM_IN && Key_value == 4'hc)
|| (c_state ==CHANGE && Key_value == 4'hc)))
Disp_data <= 32'haaaaaaaa;
else if (c_state ==IDLE || c_state == PASS || c_state == ERROR)
Disp_data <= 32'haaaaaaaa;
else
Disp_data <= Disp_data;
end
function [6:0] decode;
input [3:0] in;
begin
case (in)
// 4'h0:decode[6:0] = 7'b1000000; /*0*/
// 4'h1:decode[6:0] = 7'b1111001; /*1*/
// 4'h2:decode[6:0] = 7'b0100100; /*2*/
// 4'h3:decode[6:0] = 7'b0110000; /*3*/
// 4'h4:decode[6:0] = 7'b0011001; /*4*/
// 4'h5:decode[6:0] = 7'b0010010; /*5*/
// 4'h6:decode[6:0] = 7'b0000010; /*6*/
// 4'h7:decode[6:0] = 7'b1111000; /*7*/
// 4'h8:decode[6:0] = 7'b0000000; /*8*/
// 4'h9:decode[6:0] = 7'b0010000; /*9*/
4'h0:decode[6:0] = 7'b0111111; /*-*/
4'h1:decode[6:0] = 7'b0111111; /*-*/
4'h2:decode[6:0] = 7'b0111111; /*-*/
4'h3:decode[6:0] = 7'b0111111; /*-*/
4'h4:decode[6:0] = 7'b0111111; /*-*/
4'h5:decode[6:0] = 7'b0111111; /*-*/
4'h6:decode[6:0] = 7'b0111111; /*-*/
4'h7:decode[6:0] = 7'b0111111; /*-*/
4'h8:decode[6:0] = 7'b0111111; /*-*/
4'h9:decode[6:0] = 7'b0111111; /*-*/
// 4'ha:decode[6:0] = 7'b0001000; /*a*/
4'ha:decode[6:0] = 7'b1111111; /* */
4'hb:decode[6:0] = 7'b0000011; /*b*/
// 4'hc:decode[6:0] = 7'b1000110; /*c*/
4'hc:decode[6:0] = 7'b0111111; /*-*/
4'hd:decode[6:0] = 7'b0100001; /*d*/
4'he:decode[6:0] = 7'b0000110; /*e*/
4'hf:decode[6:0] = 7'b0001110; /*f*/
endcase
end
endfunction
希望能够告知代码或者是大致思路,如果可以解决的话麻烦加一下QQ1759779471,可以给50元作为报酬,谢谢。如果需要完整代码才可以解决也可以联系我。