用Verilog语法以及case语句实现八个不同亮度的led灯,使其成为流水灯,花型为从右向左
时间: 2023-04-03 14:04:06 浏览: 374
我可以回答这个问题。以下是Verilog语法以及case语句实现八个不同亮度的led灯,使其成为流水灯,花型为从右向左的代码:
module led_flow(
input clk,
output reg [7:0] led
);
reg [2:0] cnt;
always @(posedge clk) begin
case(cnt)
3'b000: led <= 8'b00000001;
3'b001: led <= 8'b00000011;
3'b010: led <= 8'b00000111;
3'b011: led <= 8'b00001111;
3'b100: led <= 8'b00011111;
3'b101: led <= 8'b00111111;
3'b110: led <= 8'b01111111;
3'b111: led <= 8'b11111111;
endcase
cnt <= cnt + 1;
end
endmodule
阅读全文