B
Beanut
Guest
Here's a list of rules I've compiled over time from experience and web
sites like this one. Please provide feedback. My target is for
engineers and students new to VHDL/Verilog who might not know what many
of us assume to be a given. I would like to correct any errors and
make sure no criticul rules are missed (such as commandment 11, You
shall only use numeric_std).
Enjoy,
Beanut
------------------------------------
1. Always use synchronous processes.
2. Always reset signals.
3. Use an asynchronously asserted Reset, synchronous deassertion.
4. All asynchronous inputs must be double synchronized to prevent
metastability.
http://klabs.org/richcontent/MAPLDCon00/Presentations/Session_A/A5_Erickson_S.PDF
5. Never use latches(latch=curse word). Check synthesis log for
warning messages where latches are used.
a. Latch glitches
b. Transparent latches cause oscillation
c. Difficult timing analysis
6. Only use clocks that are derivatives of master clock.
7. If rule #6 is violated, use double synchronizer for all signals
crossing clock domains.
8. Only use clocks for synchronous processes, do not substitute signals
for clocks(i.e. on clock signals for 'event command).
process 1:
if clk'event and clk = 1 then
irq <= data_bus;
process 2: Bad Example: process 2: Good Example:
if irq'event and irq = 1 then if clk'event and clk= 1 then
clear <= '1'; if irq = 1 then
clear <= '1';
9. Implement state machines with one of the following implementations:
a. 3 process state machine.
One synchronous process for updating state with next_state
One state machine process updating next_state only
One state machine process updating outputs only
b. 2 process state machine (preferred method)
One synchronous process for updating state with next_state
One state machine process updating next_state and outputs
10. State machines should assign outputs a hard coded value only. If
previous values are used in signal assignment statement then a latch
will be inferred to store that previous value.
Example:
Good: output <= '1' or output_bus<= "0010"
Bad: out <= outt xor input ; or out_bus <= out_bus(3 downto 1) & '0';
If previous value needed, use a synchronous if/else statement with
imbedded case or if/else statements
-------------END----------------
sites like this one. Please provide feedback. My target is for
engineers and students new to VHDL/Verilog who might not know what many
of us assume to be a given. I would like to correct any errors and
make sure no criticul rules are missed (such as commandment 11, You
shall only use numeric_std).
Enjoy,
Beanut
------------------------------------
1. Always use synchronous processes.
2. Always reset signals.
3. Use an asynchronously asserted Reset, synchronous deassertion.
4. All asynchronous inputs must be double synchronized to prevent
metastability.
http://klabs.org/richcontent/MAPLDCon00/Presentations/Session_A/A5_Erickson_S.PDF
5. Never use latches(latch=curse word). Check synthesis log for
warning messages where latches are used.
a. Latch glitches
b. Transparent latches cause oscillation
c. Difficult timing analysis
6. Only use clocks that are derivatives of master clock.
7. If rule #6 is violated, use double synchronizer for all signals
crossing clock domains.
8. Only use clocks for synchronous processes, do not substitute signals
for clocks(i.e. on clock signals for 'event command).
process 1:
if clk'event and clk = 1 then
irq <= data_bus;
process 2: Bad Example: process 2: Good Example:
if irq'event and irq = 1 then if clk'event and clk= 1 then
clear <= '1'; if irq = 1 then
clear <= '1';
9. Implement state machines with one of the following implementations:
a. 3 process state machine.
One synchronous process for updating state with next_state
One state machine process updating next_state only
One state machine process updating outputs only
b. 2 process state machine (preferred method)
One synchronous process for updating state with next_state
One state machine process updating next_state and outputs
10. State machines should assign outputs a hard coded value only. If
previous values are used in signal assignment statement then a latch
will be inferred to store that previous value.
Example:
Good: output <= '1' or output_bus<= "0010"
Bad: out <= outt xor input ; or out_bus <= out_bus(3 downto 1) & '0';
If previous value needed, use a synchronous if/else statement with
imbedded case or if/else statements
-------------END----------------