Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Honored Contributor I
1,173 Views

how to extend delay

How do i create delay for the output in the waveform? 

Currently i'm having half a cycle delay, i want to increase it to 1 cycle. 

(i have circled the area in the picture attatched) 

And also, how do i make the period of the output to be 3 times the size of 1 clock period? 

(i have also attatched the expected outcome) 

This is what i have till now... 

 

library ieee;  

use ieee.std_logic_1164.all;  

--------------------------------------------------------  

ENTITY traffic_light IS  

PORT(sensor : IN std_logic;  

clock : IN std_logic;  

red_light : OUT std_logic;  

green_light : OUT std_logic;  

yellow_light : OUT std_logic);  

END traffic_light;  

 

ARCHITECTURE simple OF traffic_light IS  

TYPE t_state is (red, green, yellow);  

SIGNAL present_state, next_state : t_state;  

BEGIN  

PROCESS(present_state, sensor)  

BEGIN  

CASE present_state IS  

WHEN green =>  

 

next_state <= yellow;  

red_light <= '0';  

green_light <= '1';  

yellow_light <= '0';  

WHEN red =>  

red_light <= '1';  

green_light <= '0';  

yellow_light <= '0';  

IF (sensor = '1') THEN  

next_state <= green;  

ELSE  

next_state <= red;  

END IF;  

WHEN yellow =>  

red_light <= '0';  

green_light <= '0';  

yellow_light <= '1';  

next_state <= red;  

END CASE;  

END PROCESS;  

 

PROCESS  

BEGIN  

WAIT UNTIL clock'EVENT and clock = '1';  

present_state <= next_state;  

END PROCESS;  

 

END simple; 

 

Please help!!
0 Kudos
4 Replies
Honored Contributor I
26 Views

Usually, the way to extend signals is to add counters, and then inside the state machine wait till that counter gets to the correct value.

0 Kudos
Honored Contributor I
26 Views

 

--- Quote Start ---  

Usually, the way to extend signals is to add counters, and then inside the state machine wait till that counter gets to the correct value. 

--- Quote End ---  

 

 

So does that mean i have to add counter to extend the output delay? and also the period of the output waveform? i'm sorry don't quite get what u mean... :confused:
0 Kudos
Honored Contributor I
26 Views

Yes add a counter, then in your state machine do something like this: 

 

WHEN red => red_light <= '1'; green_light <= '0'; yellow_light <= '0'; IF (sensor = '1') and counter = 3 THEN next_state <= green; ELSE next_state <= red;
0 Kudos
Honored Contributor I
26 Views

i guess i need to declare the "counter" at the top right? thanks i'll try it out

0 Kudos