How Can Delays Be Implemented in VHDL Testbench Waveforms?

  • Thread starter Thread starter HD555
  • Start date Start date
  • Tags Tags
    Delay
Click For Summary
SUMMARY

This discussion focuses on implementing delays in VHDL testbench waveforms using Xilinx's ISE WebPACK Software. The user demonstrates a method to create a rising edge detector that outputs a pulse for two clock cycles by utilizing the "after" statement for simulation purposes. The code provided employs multiple processes to achieve the desired delay effect, although it acknowledges that such constructs are ignored during synthesis. The user also describes a workaround for creating a one-shot behavior using a state machine approach.

PREREQUISITES
  • Familiarity with VHDL syntax and constructs
  • Understanding of clock edge detection in digital design
  • Knowledge of simulation versus synthesis in VHDL
  • Experience with Xilinx ISE WebPACK Software
NEXT STEPS
  • Explore VHDL simulation techniques for waveform generation
  • Learn about state machine design in VHDL
  • Investigate the use of the "after" statement in VHDL for simulation
  • Study the differences between synthesis and simulation in VHDL
USEFUL FOR

VHDL developers, digital design engineers, and students learning about simulation techniques and state machine implementations in VHDL.

HD555
Messages
27
Reaction score
0
Hi, I have a small piece of code that will detect a rising edge and output a pulse for 2 clock cycles. I'm only doing this for simulation purposes and will not be porting this into a FPGA.

When using the after 10 ns after a statement, I know this is ignored during sythesis. How can I implement a delay and have it be shown on the testbench waveform?

Thanks. I'm using Xilinx's ISE WebPACK Software. Code is below.

Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity rising_edge_detector_2ms is
    Port ( 
			  clk : in  STD_LOGIC;
           signal_input : in  STD_LOGIC;
			  out1, out2 : out STD_LOGIC;
           output : out  STD_LOGIC
			 );  
end rising_edge_detector_2ms;


architecture Behavioral of rising_edge_detector_2ms is

signal Q_FF, Q1_FF, Q2_FF : STD_LOGIC;

begin

	process(clk)
	begin
		if rising_edge(clk) then
			Q_FF <= signal_input after 20 ns;
		end if;
	end process;
	
	process(clk)
	begin
		if rising_edge(clk) then
			Q1_FF <= Q_FF  after 20 ns;
		end if;
	end process;
	
	process(clk)
	begin
		if rising_edge(clk) then
			Q2_FF <= Q1_FF  after 20 ns;
		end if;
	end process;
	
-- Final Output Through AND Gate
	out1 <= Q1_FF;
	out2 <= Q2_FF;
	output <= (not Q2_FF) and signal_input;

end Behavioral;
 
Engineering news on Phys.org
I've had to create a purely VHDL one-shot type of behavior..which is pretty annoying.

Code:
--5 second one shot
Process (onehertz, fivetrigger, reset)
	variable fiveint: integer range 0 to 4;
begin
	if (reset = '0') then
		fivesec <= '1';
		fiveint := 0;
	elsif (rising_edge(onehertz)) then
		if (fivetrigger = '0') then
			fiveint := 0;
			fivesec <= '1';
		elsif (fiveint = 4) then
			fivesec <= '0';
		else
			fiveint := fiveint + 1;
		end if;
	end if;	
end process;

Not truly a one-shot since the trigger has to stay on the whole time, but if you create a state machine where a certain state enables this trigger, you can do it.

My thought process was:

State 1 goes to State 2 when the input goes high
State 2 enables this counting process
State 2 goes back to State 1 when counting is done.

It's bootleg but I got an A so it's all good.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
28K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
1
Views
9K
Replies
5
Views
11K
  • · Replies 1 ·
Replies
1
Views
12K
  • · Replies 2 ·
Replies
2
Views
8K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K