\documentclass{article}

\usepackage[utf-8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{color}
\usepackage{listings}

\definecolor{darkgreen}{rgb}{0,.3,0}
\definecolor{darkblue}{rgb}{0,0,.3}
\definecolor{brown}{rgb}{.4,.2,0}
\definecolor{purple}{rgb}{.5,0,.5}
\lstdefinestyle{mystyle}{
    identifierstyle={\itshape},
    stringstyle={\color{darkgreen}},
    keywordstyle=[1]{\color{brown}\texttt},
    keywordstyle=[2]{\color{darkblue}\textbf},
    keywordstyle=[3]{\color{purple}},
}
\lstset{extendedchars=true,style=mystyle}

\title{Exemple d'inclusion de code CHP dans un document \LaTeX}
\author{Vivian Brégier}
\date{10 août 2007}

\begin{document}
\maketitle

Voici un code CHP :

\begin{lstlisting}[language=chp]

component mux4 port (
    S  : OUT DI PASSIVE DR;
    C  : IN  DI ACTIVE  MR[4][1];
    I0 : IN  DI ACTIVE  DR;
    I1 : IN  DI ACTIVE  DR;
    I2 : IN  DI ACTIVE  DR;
    I3 : IN  DI ACTIVE  DR)

begin
    process mux4 port (
        S  : OUT DI PASSIVE DR;
        C  : IN  DI ACTIVE  MR[4][1];
        I0 : IN  DI ACTIVE  DR;
        I1 : IN  DI ACTIVE  DR;
        I2 : IN  DI ACTIVE  DR;
        I3 : IN  DI ACTIVE  DR)
    variable x   : DR;
    variable cmd : MR[4][1];
    begin
    [
        C?cmd;
        @[
            cmd="0"[4] => I0?x; S!x; break
            cmd="1"[4] => I1?x; S!x; break
            cmd="2"[4] => I2?x; S!x; break
            cmd="3"[4] => I3?x; S!x; break
        ];
        loop
    ];
    end;
end;
\end{lstlisting}
\end{document}
