//led_ctrl有1表示有按键按下 wire [2:0] led_ctrl = low_sw_r[2:0] & ( ~low_sw[2:0]); always @ (posedge clk or negedge rst_n) begin if (!rst_n) begin led_d1<=1; led_d2<=1; led_d3<=1; led_d4<=1; end //------------------------------1--case----------------------------------------------- else begin case(led_ctrl) 3’b000: led_d4<=0; 3'b001:led_d1<=~led_d1; 3'b010:led_d2<=~led_d2; 3'b100:led_d3<=~led_d3; default:led_d4<=1; endcase end //------------------------2------if—else if----else--------------------------------------- else if ( led_ctrl[0] ) led_d1<=~led_d1; // else if ( led_ctrl[1] ) led_d2<=~led_d2; else if ( led_ctrl[2] ) led_d3<=~led_d3; else led_d4<=~led_d4; //----------------------------3------else------------------------------------------------------ else begin if ( led_ctrl[0] ) led_d1<=~led_d1; if ( led_ctrl[1] ) led_d2<=~led_d2; if ( led_ctrl[2] ) led_d3<=~led_d3; end end