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.

Moore code understanding

Status
Not open for further replies.

ek4m2005

Junior Member level 1
Junior Member level 1
Joined
Apr 20, 2008
Messages
17
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,385
hello every one,
i want to know and understand the code of the moore fsm for at leas 2 states.
regardes
mohamed
 

Moore is combinational,

primitive example
Let C= {Not A & Not B} OR {A & B}
we say here C = Exclusive OR of {A,B} = XOR{A,B}

128px-XOR_ANSI.svg.png

https://en.wikipedia.org/wiki/XOR_gate
 
Last edited:

thnx 4 ur reply, but i need to understand the finite state machines (FSM) that built in vhdl can be written by moore code, how ? i want to under stand it
regardes
 

Last edited:

i think this is a simple code for one or two states but i don't understand it, where the state and the transitions and the conditions and the input and the output and why he use (type)??
if u know a simple code for FSM moore code plz help
regrdes

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- This is a sample state-machine using enumerated types.
-- This will allow the synthesis tool to select the appropriate
-- encoding style and will make the code more readable.
 
--Insert the following in the architecture before the begin keyword
   --Use descriptive names for the states, like st1_reset, st2_search
   type state_type is (st1_<name_state>, st2_<name_state>, ...); 
   signal state, next_state : state_type; 
   --Declare internal signals for all outputs of the state-machine
   signal <output>_i : std_logic;  -- example output signal
   --other outputs
 
--Insert the following in the architecture after the begin keyword
   SYNC_PROC: process (<clock>)
   begin
      if (<clock>'event and <clock> = '1') then
         if (<reset> = '1') then
            state <= st1_<name_state>;
            <output> <= '0';
         else
            state <= next_state;
            <output> <= <output>_i;
         -- assign other outputs to internal signals
         end if;        
      end if;
   end process;
 
   --MOORE State-Machine - Outputs based on state only
   OUTPUT_DECODE: process (state)
   begin
      --insert statements to decode internal output signals
      --below is simple example
      if state = st3_<name> then
         <output>_i <= '1';
      else
         <output>_i <= '0';
      end if;
   end process;
 
   NEXT_STATE_DECODE: process (state, <input1>, <input2>, ...)
   begin
      --declare default state for next_state to avoid latches
      next_state <= state;  --default is to stay in current state
      --insert statements to decode next_state
      --below is a simple example
      case (state) is
         when st1_<name> =>
            if <input_1> = '1' then
               next_state <= st2_<name>;
            end if;
         when st2_<name> =>
            if <input_2> = '1' then
               next_state <= st3_<name>;
            end if;
         when st3_<name> =>
            next_state <= st1_<name>;
         when others =>
            next_state <= st1_<name>;
      end case;      
   end process;

 
Last edited by a moderator:

thats the template for a state machine. The state transitions are in the NEXT_STATE_DECODE process, and the registering of the state is in SYNC_PROC
 

i want to know why he put (type) function
 

A type is used to provide names for the states which makes the code more readable.

r.b.
 
the synthesisor will chose the encoding for the states when it synthesises the code. You can usually specify the type of coding you want (standed count, one hot, grey code etc) with the default being one hot for 3 or more states (at least for altera).
 
thnx, but if i made for ex. 40 state, should i write them in type?
 

That's entirely up to you!

r.b.
 
  • Like
Reactions: zel

    zel

    Points: 6
    No comments
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top