Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL CODING STYPE FOR STATE MACHINES.

Status
Not open for further replies.

Mirzaaur

Member level 2
Joined
Aug 5, 2005
Messages
50
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
1,690
Dear all,

I have a doubt about declaring the type for state variables. normall its declared as :

type sm is (sate1, stae2, stae3...);
signal pr_st, nxt_st: sm;

what difference it will make in synthesis or function of circuit if its done like this way

constant sate1 : std_logic_vector(2 downto 0) := "000";
constant state2 : std_logic_vector(2 downto 0) := "001";
constant state3 : std_logic_vector(2 downto 0) := "011";
constant state4 : std_logic_vector(2 downto 0) := "011";

signal pr_st,nxt_st : std_logic_vector(2 downto 0);


thank you very much for your time and any guidance,

best regards,

mirza
 

In the first declaration, your pr_st and nx_st signals can not go out of the set {state1,...,state4}.
In the second delaration, pr_st or nx_st can have a logic value out of that set such like "XX1" ..etc... But anyway, it wont cause much different if you take care a bit of it ...
 

I would say refer to any (or targeted) synthesizer reference manual for a good coding practice especially for RTL.

For example, in the case of Xilinx ISE (XST), hxxp://toolbox.xilinx.com/docsan/xilinx10/books/docs/sim/sim.pdf Finite State Machines (FSMs) under Chapter 4.

hxxp://toolbox.xilinx.com/docsan/xilinx10/books/docs/xst/xst.pdf Chapter 6
 

Considering coding styles supported (proffered ) by the EDA tool will be helpful.
You have suggested binary encoding, if you don't specify the states encoding, the tool gets the liberty to use target optimized encoding style(i.e. to use binary, gray, one hot etc). SO its better not to restrict the encoding of FSMs in hdl. because you can always provide constraints in EDA tool if you want to implement a particular type of FSM encoding.
 

Well in fact with the second type, you are defining the "state coding" of the state machine. The states should be converted to binary signals when implemented, and you are defining how to do that. If you don't the synthesizer would do that job. Usually they have options for that, and the default is AUTO which lets it use the best coding for speed/area results.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top