Learn how to implement a Finite State Machine (FSM) in VHDL. To implement Moore FSM in VHDL. Using the FSM VHDL code template. Of the code “type t_money. Issues regarding finite state machine design using the hardware description language. VHDL coding styles and different. Index Terms — VHDL code, Verilog code, finite state machine, Mealy machine, Moore machine, modeling issues. Finite State Machine Design and VHDL Coding Techniques Iuliana CHIUCHISAN, Alin Dan POTORAC, Adrian GRAUR.

Active1 year, 3 months ago

Vhdl Code For Serial Adder Using Moore Type Fsm


I've a design problem in VHDL with a serial adder.The block diagram is taken from a book.

Since i'm not skilled enough in design with clock (except some silly flip flop i've found on the web, and similarly a register, where the design is pretty much the same) i have some problem in the design.

I would start with a register (n bit) a full adder and than a flip flop as basic component. Register and flip flop should be updated and shift for every clock cycle, the full adder is combinatorial so it is ok. I'm not sure however how the whole entity for the adder should be designed i would attempt with something like

The internal architecture confuse me a lot since actually i don't know how to behave in the synchronization stuff.. At high level i would say probably internally should be even a counter that probably keep track of when all the bits are being processed. But i'm not sure if this is the right way to perform this design, i would like to keep as much close i can to the diagram i posted.


Any suggestion for such simple design?


Ok here i have my first attempt for the design.. I splitted in three process, first process for handling the input registers, second for handling the full adder and third for handling the register z, i sync with a clock signal and i think i've written a correct sensitivity list for each process. Input signal are also clk, load and clear. Clk is the clock, load is to write the x,y value in the registers while clear is to clear registers and flip flop. Pleaaaaaaaaaase give me any feedback!!!


1 Answer


z : out std_logic_vector(n - 1 downto 0));The output must be std_logic, because it is a serial output

Also, you can use the + operator directly to the std_logic_vectors. Just add the 'ieee.std_logic_signed' librarySo that you can write z_reg <= x+y;

if rising_edge(clk) then if clr = '1' then --clear all the registers, and flip flop


Not the answer you're looking for? Browse other questions tagged serialvhdldesignadder or ask your own question.

Serial Adder Circuit

Mealy State Machine

4 Bit Serial Adder

The Output of the state machine depends on both present state and current input. When the input changes,the output of the state machine updated without waiting for change in clock input.

Moore State Machine

The Output of the State machine depends only on present state. The output of state machine are only updated at the clock edge.

Let’s construct the sequence detector for the sequence 101 using both mealy state machine and moore state machine.

Moore state require to four states st0,st1,st2,st3 to detect the 101 sequence.

Mealy state machine require only three states st0,st1,st2 to detect the 101 sequence.

VHDL code for Sequence detector (101) using moore state machine

VHDL code for Sequence detector (101) using mealy state machine

TestBench VHDL code for sequence detector using Moore State Machine

Note: Same testbench code can be used for Mealy VHDL code by simply changing the component name to mealy.

TestBench output waveform for Mealy and Moore State Machine

From the above shown waveform, sequence 101 is detected twice from the testbench VHDL code.

Serial Adder Verilog