OpenCores
URL https://opencores.org/ocsvn/yahamm/yahamm/trunk

Subversion Repositories yahamm

[/] [yahamm/] [trunk/] [doc/] [src/] [specification.tex] - Diff between revs 8 and 9

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 9
Line 11... Line 11...
\title{YAHAMM\\
\title{YAHAMM\\
  Yet Another Hamming Encoder and Decoder\\
  Yet Another Hamming Encoder and Decoder\\
  ---\\
  ---\\
  Specification
  Specification
}
}
\author{Nicola De Simone   \\
\author{Nicola De Simone (ndesimone@opencores.org)\\
Version 0.1}
Version 0.1}
\date{}
\date{}
\emergencystretch1em  %
\emergencystretch1em  %
 
 
\pagestyle{myfootings}
\pagestyle{myfootings}
Line 38... Line 38...
 
 
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
\begin{abstract}
\begin{abstract}
YAHAMM is a VHDL implementation of an Hamming encoder, as entity yahamm\_enc, and and Hamming decoder, as entity yahamm\_dec, of message lenght defined trough generic.  All the math needed to compute the code is internally implemented in VHDL and it is trasparent to the user.  Single Error Correction and Double Error Detection is also provided (see next for details).  Both encoder and decoder have latency 1 clock cycle, independently from their configuration.
YAHAMM is a VHDL implementation of an Hamming encoder, as entity yahamm\_enc, and and Hamming decoder, as entity yahamm\_dec, of message length defined trough generic.  All the math needed to compute the code is internally implemented in VHDL and it is transparent to the user.  Single Error Correction and Double Error Detection is also provided (see next for details).  Encoder has latency 1 clock cycle, decoder latency 2, independently from their configuration.
\end{abstract}
\end{abstract}
 
 
 
 
\section{Project files}
\section{Project files}
The projects includes the file:
The projects includes the file:
Line 51... Line 51...
\item rtl/vhdl/yahamm\_enc.vhd: encoder entity
\item rtl/vhdl/yahamm\_enc.vhd: encoder entity
\item rtl/vhdl/yahamm\_dec.vhd: decoder entity
\item rtl/vhdl/yahamm\_dec.vhd: decoder entity
\item rtl/vhdl/matrix\_pkg.vhd: help functions for matrix manipulation
\item rtl/vhdl/matrix\_pkg.vhd: help functions for matrix manipulation
\item rtl/vhdl/yahamm\_pkg.vhd: core math functions
\item rtl/vhdl/yahamm\_pkg.vhd: core math functions
\item bench/vhdl/yahamm\_tb[0-3].vhd: test benches
\item bench/vhdl/yahamm\_tb[0-3].vhd: test benches
\item sim/rtl\_sim/bin/Makefile: a set of rules for the analysis and simulation with ghdl
\item sim/rtl\_sim/bin/Makefile: a set of rules for the analysis and simulation with GHDL.
\end{enumerate}
\end{enumerate}
 
 
\section{Makefile}
\section{Makefile}
 
 
The Makefile targes call ghdl for analyzing the VHDL and running simulations.
The Makefile targets call ghdl for analyzing the VHDL and running simulations.
 
 
\subsection{Analyze the VHDL}
\subsection{Analyze the VHDL}
\begin{enumerate}
\begin{enumerate}
\item \verb|cd sim/rtl_sim/bin|
\item \verb|cd sim/rtl_sim/bin|
\item \verb|make <vhdl file>|
\item \verb|make <vhdl file>|
Line 68... Line 68...
 
 
\subsection{Run the simulation}
\subsection{Run the simulation}
\begin{enumerate}
\begin{enumerate}
\item \verb|cd sim/rtl_sim/bin|
\item \verb|cd sim/rtl_sim/bin|
\end{enumerate}
\end{enumerate}
To simulate a single testbench:
To simulate a single test-bench:
\begin{enumerate}
\begin{enumerate}
\item[2] \verb|make simulate_tb[0..3]|
\item[2] \verb|make simulate_tb[0..3]|
\end{enumerate}
\end{enumerate}
or, to simulate all testbenches:
or, to simulate all test-benches:
\begin{enumerate}
\begin{enumerate}
\item[2] \verb|make simulate|
\item[2] \verb|make simulate|
\end{enumerate}
\end{enumerate}
 
 
Each testbench will output ``OK'' if successful.
Each test-bench will output ``OK'' if successful.
 
 
The simulation will create waveform as VCD compressed file in \verb|cd sim/rtl_sim/out|.  They can be view, for example, with gtkwave by running:
The simulation will create waveform as VCD compressed file in \verb|cd sim/rtl_sim/out|.  They can be view, for example, with gtkwave by running:
 
 
\begin{enumerate}
\begin{enumerate}
\item[3] \verb|make view_[0..3]|
\item[3] \verb|make view_[0..3]|
Line 117... Line 117...
\end{verbatim}
\end{verbatim}
 
 
Generics:
Generics:
 
 
\begin{enumerate}
\begin{enumerate}
\item MESSAGE\_LENGHT: the data payload length, excluding parity bits.
\item MESSAGE\_LENGTH: the data payload length, excluding parity bits.
\item EXTRA\_PARITY\_BIT: if 1 the Hamming codes are extended by an extra parity bit. This way the minimum Hamming distance is increased to 4, which allows the decoder to distinguish between single bit errors and two-bit errors. Thus the decoder can detect and correct a single error and at the same time detect (but not correct) a double error (SECDED). If the decoder does not attempt to correct errors, it can detect up to three errors.  \seealso{Sec \ref{sec:decoder}}.  Default is 1.
\item EXTRA\_PARITY\_BIT: if 1 the Hamming codes are extended by an extra parity bit. This way the minimum Hamming distance is increased to 4, which allows the decoder to distinguish between single bit errors and two-bit errors. Thus the decoder can detect and correct a single error and at the same time detect (but not correct) a double error (SECDED). If the decoder does not attempt to correct errors, it can detect up to three errors.  \seealso{Sec \ref{sec:decoder}}.  Default is 1.
\item ONE\_PARITY\_BIT: if true the encoder does not perform Hamming enconding but just adds a single parity bit to the message.  Default is false.
\item ONE\_PARITY\_BIT: if true the encoder does not perform Hamming encoding but just adds a single parity bit to the message.  Default is false.
\end{enumerate}
\end{enumerate}
 
 
The generics MESSAGE\_LENGTH, EXTRA\_PARITY\_BIT and ONE\_PARITY\_BIT must have the same values on both the encoder and the decoder instantiations.
The generics MESSAGE\_LENGTH, EXTRA\_PARITY\_BIT and ONE\_PARITY\_BIT must have the same values on both the encoder and the decoder instances.
 
 
Ports:
Ports:
 
 
\begin{enumerate}
\begin{enumerate}
\item clk\_i: input reset, active high.
\item clk\_i: input reset, active high.
\item rst\_i: input reset, active high.
\item rst\_i: input reset, active high.
\item en\_i: input enable.  When asserted input data are encoded.  If de-asserted, data and parity outputs are zero.  Default is high.
\item en\_i: input enable.  When asserted input data are encoded.  If de-asserted, data and parity outputs are zero.  Default is high.
\item data\_i: input data.  Lenght equal to MESSAGE\_LENGTH.
\item data\_i: input data.  Length equal to MESSAGE\_LENGTH.
\item data\_o: output data. Lenght equal to MESSAGE\_LENGTH.
\item data\_o: output data. Length equal to MESSAGE\_LENGTH.
\item data\_valid\_o: output valid signal for data\_o.  This is just en\_i delayed by the core latency.
\item data\_valid\_o: output valid signal for data\_o.  This is just en\_i delayed by the core latency.
\item parity\_o: output parity bits.  The lenght of this vectors corresponds to the number of parity bits needed by the hamming code and it's computed by the VHDL function calc\_nparity\_bits().  One extra parity bit is needed if the generic EXTRA\_PARITY\_BIT is true.  The user instantiating the entity and mapping that port can determine the length in three ways:
\item parity\_o: output parity bits.  The length of this vectors corresponds to the number of parity bits needed by the hamming code and it's computed by the VHDL function calc\_nparity\_bits().  One extra parity bit is needed if the generic EXTRA\_PARITY\_BIT is true.  The user instantiating the entity and mapping that port can determine the length in three ways:
  \begin{enumerate}
  \begin{enumerate}
  \item Calculate the number of parity bits $r$ needed for the specified message length $k$, looking for the smallest $r$ such that $k \geq 2^r - r - 1$ for $r \ge 2$.
  \item Calculate the number of parity bits $r$ needed for the specified message length $k$, looking for the smallest $r$ such that $k \geq 2^r - r - 1$ for $r \ge 2$.
  \item Use the script \verb|sw/calc_nparity_bits.sh|.
  \item Use the script \verb|sw/calc_nparity_bits.sh|.
  \item Connect a bus or arbitrary random length.  Run any VHDL analysis tool and use the syntax error you get to see which is the right length.
  \item Connect a bus or arbitrary random length.  Run any VHDL analysis tool and use the syntax error you get to see which is the right length.
  \end{enumerate}
  \end{enumerate}
Line 172... Line 172...
\end{verbatim}
\end{verbatim}
 
 
Generics:
Generics:
 
 
\begin{enumerate}
\begin{enumerate}
\item \verb|CORRECT|: if true, the core corrects dectected errors.  Default is true.
\item \verb|CORRECT|: if true, the core corrects detected errors.  Default is true.
\item \verb|ERROR_LEN|: bit length of the error counters provided on ports \verb|cnt_errors_corrected_o| and \verb|cnt_errors_detected_o|.
\item \verb|ERROR_LEN|: bit length of the error counters provided on ports \verb|cnt_errors_corrected_o| and \verb|cnt_errors_detected_o|.
\item \verb|MESSAGE_LENGHT|: see Sec. \ref{sec:encoder}.
\item \verb|MESSAGE_LENGTH|: see Sec. \ref{sec:encoder}.
\item \verb|EXTRA_PARITY_BIT|: see Sec. \ref{sec:encoder}.
\item \verb|EXTRA_PARITY_BIT|: see Sec. \ref{sec:encoder}.
\item \verb|ONE_PARITY_BIT|: see Sec. \ref{sec:encoder}.
\item \verb|ONE_PARITY_BIT|: see Sec. \ref{sec:encoder}.
\end{enumerate}
\end{enumerate}
 
 
The generics MESSAGE\_LENGTH, EXTRA\_PARITY\_BIT and ONE\_PARITY\_BIT must have the same values on both the encoder and the decoder instantiations.
The generics MESSAGE\_LENGTH, EXTRA\_PARITY\_BIT and ONE\_PARITY\_BIT must have the same values on both the encoder and the decoder instances.
 
 
Ports:
Ports:
 
 
\begin{enumerate}
\begin{enumerate}
\item \verb|cnt_clr_i|: input synchronous clear of the error counters.
\item \verb|cnt_clr_i|: input synchronous clear of the error counters.
\item \verb|en_i|: optional input enable.  Can be connected to \verb|dout_valid_o| of the encoder to propagate a valid signal to the output port \verb|data_valid_o|:  Default is high (\verb|data_valid_o| will be always asserted in this case).
\item \verb|en_i|: optional input enable.  Can be connected to \verb|dout_valid_o| of the encoder to propagate a valid signal to the output port \verb|data_valid_o|:  Default is high (\verb|data_valid_o| will be always asserted in this case).
\item \verb|data_i|: input data.  It must be connected to the \verb|data_o| of the decoder.  Lenght equal to MESSAGE\_LENGTH.
\item \verb|data_i|: input data.  It must be connected to the \verb|data_o| of the decoder.  Length equal to MESSAGE\_LENGTH.
\item \verb|parity_i|: input parity bits.  It must be connected to the \verb|parity_o| of the decoder.
\item \verb|parity_i|: input parity bits.  It must be connected to the \verb|parity_o| of the decoder.
\item \verb|data_o|: output data.  Lenght equal to MESSAGE\_LENGTH.
\item \verb|data_o|: output data.  Length equal to MESSAGE\_LENGTH.
\item data\_valid\_o: output valid signal for data\_o.  This is just en\_i delayed by the core latency.
\item data\_valid\_o: output valid signal for data\_o.  This is just en\_i delayed by the core latency.
\item \verb|cnt_errors_corrected_o|: counter of single errors corrected.  It is always zero if the generic \verb|CORRECT| is false.
\item \verb|cnt_errors_corrected_o|: counter of single errors corrected.  It is always zero if the generic \verb|CORRECT| is false.
\item \verb|cnt_errors_detected_o|: counter of errors detected.  It includes single, double and triple errors (not there's no way to distinguish between a single and a triple error), if the generic \verb|CORRECT| is false, otherwise it only counts double errors.
\item \verb|cnt_errors_detected_o|: counter of errors detected.  It includes single, double and triple errors (not there's no way to distinguish between a single and a triple error), if the generic \verb|CORRECT| is false, otherwise it only counts double errors.
\item \verb|log_wrong_bit_pos_data_o|: position of the single error in \verb|data_o|.  Zero if the generic \verb|CORRECT| is false or if it's not a single error.
\item \verb|log_wrong_bit_pos_data_o|: position of the single error in \verb|data_o|.  Zero if the generic \verb|CORRECT| is false or if it's not a single error.
\item \verb|log_wrong_bit_pos_data_o|: position of the single error in \verb|parity_o|.  Zero if the generic \verb|CORRECT| is false or if it's not a single error.
\item \verb|log_wrong_bit_pos_data_o|: position of the single error in \verb|parity_o|.  Zero if the generic \verb|CORRECT| is false or if it's not a single error.
Line 227... Line 227...
 
 
The generic \verb|EXTRA_PARITY_BITS| set to true (default) adds a parity bit so that the Hamming distance is $4$ between two codewords (number of bits to flip in a codeword to obtain another codeword).  With \verb|EXTRA_PARITY_BITS| set to false the Hamming distance will be $3$.
The generic \verb|EXTRA_PARITY_BITS| set to true (default) adds a parity bit so that the Hamming distance is $4$ between two codewords (number of bits to flip in a codeword to obtain another codeword).  With \verb|EXTRA_PARITY_BITS| set to false the Hamming distance will be $3$.
 
 
The generic \verb|CORRECT| set to true (default) corrects for single bit errors.  It can be set to false if only error detection is needed.  This allows triple error detection with \verb|EXTRA_PARITY_BIT| set to true.  Indeed, a triple error is indistinguishable from a single error with an Hamming distance 4 and the correction would be wrong in this case.  Similarly, with \verb|EXTRA_PARITY_BIT| set to false, hence with Hamming distance 3, a double error is indistinguishable from a single error and the correction would be wrong.  Note that if \verb|CORRECT| is false, the port \verb|cnt_errors_detected_o| provides the value of a counter that sums up any kind of error detected (single, double and triple).
The generic \verb|CORRECT| set to true (default) corrects for single bit errors.  It can be set to false if only error detection is needed.  This allows triple error detection with \verb|EXTRA_PARITY_BIT| set to true.  Indeed, a triple error is indistinguishable from a single error with an Hamming distance 4 and the correction would be wrong in this case.  Similarly, with \verb|EXTRA_PARITY_BIT| set to false, hence with Hamming distance 3, a double error is indistinguishable from a single error and the correction would be wrong.  Note that if \verb|CORRECT| is false, the port \verb|cnt_errors_detected_o| provides the value of a counter that sums up any kind of error detected (single, double and triple).
 
 
For most applications, SEC-DED configuration (the default) is the preferred choice.  A communicaiton channel can be considered reliable if the probability of double error is negligible.   A noisy channel showing double errors detected is not to be trusted because event a corrected single error may be a triple error and the correction would be wrong.
For most applications, SEC-DED configuration (the default) is the preferred choice.  A communication channel can be considered reliable if the probability of double error is negligible.   A noisy channel showing double errors detected is not to be trusted because event a corrected single error may be a triple error and the correction would be wrong.
 
 
 
 
\printindex
\printindex
 
 
\end{document}
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.