Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16596 Discussions

Need Help with Sequence detector Code errors

Altera_Forum
Honored Contributor II
1,232 Views

Hello All, 

 

I am trying to create a finite state machine which detects the input sequence 1011. I have written the code however I am getting about 21 errors. I am new to VHDL so what looks syntactically correct to me may be totally wrong. I would greatly appreciative if there is anybody who could take a look at my code and offer some advice as to what is creating the errors. My code is attached. Thanks
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
286 Views

 

--- Quote Start ---  

Hello All, 

 

I am trying to create a finite state machine which detects the input sequence 1011. I have written the code however I am getting about 21 errors. I am new to VHDL so what looks syntactically correct to me may be totally wrong. I would greatly appreciative if there is anybody who could take a look at my code and offer some advice as to what is creating the errors. My code is attached. Thanks 

--- Quote End ---  

 

 

The simplest way to detect a sequence is to use delay to remember past values(shift register): 

in a clocked process use signal temp of 4 bits then 

temp(3) <= data; temp(2) <= temp(3); temp(1) <= temp(2); temp(0) <= temp(1); if temp = "1011" then sequence <= '1'; else sequence <= '0'; end if; 

 

you can also just code 

temp <= data & temp(3 downto 1); 

 

you may reverse the shift direction depending on which way suits your sequence sense. 

temp <= temp(2 downto 0) & data;
0 Kudos
Altera_Forum
Honored Contributor II
286 Views

good to go.Thank you!!!!

0 Kudos
Reply