X
Xenon02
Guest

Hello !
Here is a problem in which I have been trying to fight with. The board is Basys3, the program is Vivado 2023.
it's not about those orange output from LEDs, I know why they work like that I guess.
But rather this outputs, they don't have any value ...
Here is the code for TOP :
Here is for the debouncer
And the testbench :
Here is a problem in which I have been trying to fight with. The board is Basys3, the program is Vivado 2023.
it's not about those orange output from LEDs, I know why they work like that I guess.
But rather this outputs, they don't have any value ...
Here is the code for TOP :
Code:
entity TOP is
Port ( btnR : in STD_LOGIC; -- Zmiana trybu świecenia
btnC : in STD_LOGIC; -- włącz/wyłącz
btnL : in STD_LOGIC; -- Zmiana prędkości świecenia
clk : in STD_LOGIC;
led : out STD_LOGIC_VECTOR (7 downto 0));
end TOP;
architecture Behavioral of TOP is
signal COUT : STD_LOGIC := '0';
signal BTNR_O : STD_LOGIC := '0';
signal BTNC_O : STD_LOGIC := '0';
signal BTNL_O : STD_LOGIC := '0';
signal LED_1 : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
signal LED_2 : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
begin
Debouncer: entity work.Debouncer PORT MAP (
CLOCK_IN => clk,
BIN => btnR,
BOUT => BTNR_O
);
Debouncer_1: entity work.Debouncer PORT MAP (
CLOCK_IN => clk,
BIN => btnC,
BOUT => BTNC_O
);
Debouncer_2: entity work.Debouncer PORT MAP (
CLOCK_IN => clk,
BIN => btnL,
BOUT => BTNL_O
);
end Behavioral;
Here is for the debouncer
Code:
entity Debouncer is
port( CLOCK_IN : in std_logic;
BIN : in std_logic;
BOUT : out std_logic
);
end Debouncer;
architecture Behavioral of Debouncer is
--the below constants decide the working parameters.
--the higher this is, the more longer time the user has to press the button.
constant COUNT_MAX : integer := 2;
--set it '1' if the button creates a high pulse when its pressed, otherwise '0'.
constant BTN_ACTIVE : std_logic := '1';
signal count : integer := 0;
type state_type is (idle,wait_time); --state machine
signal state : state_type := idle;
begin
process(CLOCK_IN)
begin
if(rising_edge(CLOCK_IN)) then
case (state) is
when idle =>
if(BIN = BTN_ACTIVE) then
state <= wait_time;
else
state <= idle; --wait until button is pressed.
end if;
BOUT <= '0';
when wait_time =>
if(count = COUNT_MAX) then
count <= 0;
if(BIN = BTN_ACTIVE) then
BOUT <= '1';
end if;
state <= idle;
else
count <= count + 1;
end if;
end case;
end if;
end process;
end Behavioral;
And the testbench :
Code:
entity TOP_tb is
-- Port ( );
end TOP_tb;
architecture Behavioral of TOP_tb is
signal clk : std_logic := '0';
signal btnR : std_logic := '0'; -- Zmiana trybu świecenia
signal btnC : std_logic := '0'; -- włącz/wyłącz
signal btnL : std_logic := '0'; -- Zmiana prędkości świecenia
signal led : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
begin
top_test: entity work.TOP PORT MAP (
btnR => btnR,
btnC => btnC,
btnL => btnL,
clk => clk,
led => led
);
CLOCK_IN_process :process
begin
clk <= '0';
wait for 2ns;
clk <= '1';
wait for 2ns;
end process;
Predkosc: process is -- Zmiana prędkości świecenia
begin
wait for 30ns;
btnL <= '1'; wait for 24ns;
btnL <= '0'; wait;
end process;
Off_On: process is -- włącz/wyłącz
begin
btnC <= '1'; wait for 24ns;
btnC <= '0'; wait;
end process;
Mode: process is -- Proces zmiany trybu
begin
btnR <= '0'; wait;
end process;
end Behavioral;