953 views|1 replies

501

Posts

4

Resources
The OP
 

[Domestic FPGA Anlu high-integration low-power SF1 series FPSoC new product] Key control running water light test [Copy link]

 

8562164817a6b1f122e057b987d0383b

Preface

The LED was tested before, and this article continues to conduct interactive tests in conjunction with the KEY.

process

New Construction

Reference: https://en.eeworld.com/bbs/thread-1234259-1-1.html

New project key

Create source file key. Add to project

Enter the following

module key_led(
input sys_clk ,
input sys_rst_n,
input [1:0] key,
output reg [2:0] led
);

//reg define
reg [23:0] cnt;
reg [1:0] led_control;


always @ (posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)
cnt<=24'd9_999_999;
else if(cnt<24'd9_999_999)
cnt<=cnt+1;
else
cnt<=0;
end


always @(posedge sys_clk or negedge sys_rst_n) begin
if (!sys_rst_n)
led_control <= 2'b00;
else if(cnt == 24'd9_999_999)
led_control <= led_control + 1'b1;
else
led_control <= led_control;
end


always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n) begin
led<=4'b 0000;
end
else if(key[0]== 0)
case (led_control)
2'b00 : led<=4'b100;
2'b01 : led<=4'b010;
2'b10 : led<=4'b001;
default : led<=4'b000;
endcase
else if(key[1]== 0)
case (led_control)
2'b00 : led<=4'b001;
2'b01 : led<=4'b010;
2'b10 : led<=4'b100;
default : led<=4'b000;
endcase
else
led<=4'b000;
end

endmodule

constraint

From the schematic diagram, we can see that LED_R, LED_G, LED_B correspond to J4 H5 J5 respectively

25M clock input corresponds to D7

If there is no dedicated reset button, use KEY0 H3

KEY1 and KEY2 in the schematic diagram correspond to H2 G3 corresponding to KEY0 and KEY1 in the code

The constraints are as follows

Running Tests

Key 0 reset

Press KEY1 and hold it, the running light will light up

Press KEY2 and hold it, the water light will change direction

Summarize

The TD software development process is the same as other platforms, creating a project, adding source code, constraints, compiling and downloading. The overall development experience is not much different, but the GUI interface can still be optimized, and the download is relatively simple. This experience is still good.

This article tests basic IO operations by combining buttons and LED interactions.

This post is from Domestic Chip Exchange

Latest reply

The interactive test of buttons and LEDs shows that the code is not much and the effect is very good.   Details Published on 2023-2-27 07:29
 
 

6555

Posts

0

Resources
2
 

The interactive test of buttons and LEDs shows that the code is not much and the effect is very good.

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list