2257 views|3 replies

11

Posts

0

Resources
The OP
 

[Help] Use Quartus II to simulate a counting state machine [Copy link]

 This post was last edited by 1244334644 on 2022-4-2 14:13

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity FSM is
port (clk,reset,en : in std_logic;
state_current : out integer range 0 to 3);
end FSM;
architecture behv of FSM is
type FSM_ST is (IDLE,s1,s2);
signal c_st,next_state: FSM_ST :=IDLE; --设定初态

begin
tran: process (reset,clk) begin
if reset='0' then c_st<=IDLE;
elsif clk='1' and clk'event then c_st<=next_state;end if;
end process tran;

change: process(c_st,en)
variable a2,a3 : std_logic_vector(2 downto 0);

begin
case c_st is
when IDLE => if en='1' then next_state <= s1;else next_state<=IDLE;end if;

when s1 => if en='1' then a2 := a2 + 1; else next_state<=s1;end if;
if a2=5 then a2 := (others=>'0'); next_state <= s2;end if;

when s2 => if en='1' then a3 := a3 + 1;else next_state<=s2;end if;
if a3=7 then a3 := (others=>'0');next_state <= IDLE;end if;

when others => next_state <=IDLE;
end case;
end process change;

outstate: process(c_st) begin
case c_st is
when IDLE => state_current <= 1;
when s1 => state_current <= 2;
when s2 => state_current <= 3;
when others => state_current <= 0;
end case;
end process outstate;
end behv;

This simulation is inconsistent with the requirements , I really can't find what's wrong.

This post is from Altera SoC

Latest reply

I haven't written a Quartus II program for more than ten years. In what areas and industries is it mainly used now?   Details Published on 2022-4-2 11:13
 
 

1181

Posts

0

Resources
2
 

I haven't written a Quartus II program for more than ten years. In what areas and industries is it mainly used now?

This post is from Altera SoC

Comments

Mainly the EDA industry  Details Published on 2022-4-2 12:04
 
 
 

11

Posts

0

Resources
3
 
zhangdaoyu posted on 2022-4-2 11:13 I haven't written a Quartus II program for more than ten years. In what areas and industries is it mainly used now?

Mainly the EDA industry

This post is from Altera SoC
 
 
 

11

Posts

0

Resources
4
 

Got it, no initial values were assigned to a2 and a3

This post is from Altera SoC
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Reference salary for a master's degree in research and development

A summary of the salaries of major domestic companies in 2005     Japan's SONY 10,000/month, only graduate students ...

Lora parameter calculation and RF transmission distance calculation formula and tools

This post was last edited by xulikai on 2019-10-20 10:36 This content is originally created by EEWORLD forum user xuli ...

[Raspberry Pi Pico Review]——by fxyc87

@fxyc87 - Unboxing + Download - Start Programming - Start compiling the program 2 - How to save the written progra ...

Circuit Learning Guide Fan Shigui

552280

What is the difference between SPI_SDR = 0 and SPI_SDR = 0X55 in output?

This post was last edited by Shenzhen Xiaohua on 2021-11-9 15:13 The problem is twofold: 1. How many square waves are o ...

How to generate bin format files in MDK

In the integrated development environment of Realview MDK , by default, debug files in *.axf format and executable files ...

40 "Millions" of Raspberry Pi Cars - ROS Learning (C Language Programming to Control the Turtle)

This post was last edited by lb8820265 on 2022-11-1 14:52 In the previous section, we introduced how to run the "tu ...

Free Space Path Loss (FSPL)

In telecommunications, free space path loss (FSPL) is the loss in electromagnetic wave signal strength due to a line-of- ...

Evaluation and Award: Mir STM32MP135 Entry-Level MPU Development Board

Thanks to the following netizens for sharing their evaluation of the MiR STM32MP135 entry-level MPU development board. T ...

【Follow me Season 2 Episode 2】+ Access the open source smart home platform HA via Wi-Fi using the MQTT protocol

This post was last edited by Wang Jiahui on 2024-9-9 23:32 This time, I mainly want to learn about HA through this even ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list