I have created a soundbox with different sounds connect to different buttons and switches. The switches work fine. High '1' is on, and low '0' is off.
I would like my buttons to latch for 3 seconds. I would like to press the button, release it, and have the sound play for 3 seconds. Some call this a one-shot, where a single press latches the bit until unlatched.
My code is VHDL in Vivado 2016.4. My board is a BASYS3.
I tried using a wait statement, but others have suggested that wait statements do not synthesize. Here is what I have. All help is appreciated. Thanks!
period - constance set to 1000ms
tempdata - signal std_logic
squareout - signal for tone 1
integerout - signal for tone 2
ipcoreout - signal for tone 3
dataout - output from system
section of code....
D1: process
begin
if btn_a = '1' then
tempdata <= squareout;
wait for 3 * period;
elsif btn_b = '1' then
tempdata <= integerout;
wait for 3 * period;
elsif btn_c = '1' then
tempdata <= ipcoreout;
wait for 3 * period;
elsif swt_a = '1' then
tempdata <= squareout;
wait until swt_a = '0';
elsif swt_b = '1' then
tempdata <= integerout;
wait until swt_b = '0';
elsif swt_c = '1' then
tempdata <= ipcoreout;
wait until swt_c = '0';
end if;
end process;
Question
rb251415
I have created a soundbox with different sounds connect to different buttons and switches. The switches work fine. High '1' is on, and low '0' is off.
I would like my buttons to latch for 3 seconds. I would like to press the button, release it, and have the sound play for 3 seconds. Some call this a one-shot, where a single press latches the bit until unlatched.
My code is VHDL in Vivado 2016.4. My board is a BASYS3.
I tried using a wait statement, but others have suggested that wait statements do not synthesize. Here is what I have. All help is appreciated. Thanks!
period - constance set to 1000ms
tempdata - signal std_logic
squareout - signal for tone 1
integerout - signal for tone 2
ipcoreout - signal for tone 3
dataout - output from system
section of code....
D1: process
begin
if btn_a = '1' then
tempdata <= squareout;
wait for 3 * period;
elsif btn_b = '1' then
tempdata <= integerout;
wait for 3 * period;
elsif btn_c = '1' then
tempdata <= ipcoreout;
wait for 3 * period;
elsif swt_a = '1' then
tempdata <= squareout;
wait until swt_a = '0';
elsif swt_b = '1' then
tempdata <= integerout;
wait until swt_b = '0';
elsif swt_c = '1' then
tempdata <= ipcoreout;
wait until swt_c = '0';
end if;
end process;
dataout <= tempdata;
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.