I'm having some difficulty with getting the listings package to properly format code snippets. In particular, it does not consistently bold keywords and italicize comments.
The code I am currently using is:
\usepackage{listings}
\lstset{language=C,
morekeywords= {*,rule,endrule,module,endmodule,Action,interface,endinterface,method,endmethod,case,endcase,matches},
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
%frame=single, % adds a frame around the code
tabsize=2, % sets default tabsize to 2 spaces
breaklines=true, % sets automatic line breaking
breakatwhitespace=true, % sets if automatic breaks should only happen at whitespace
}
\begin{lstlisting}[caption={code},label={lst:code}]
// 1: t1 = Py - Qy
rule op1_ctrl(oper == 4'd1 && fire_cond);
pa0.loadAddSub(0, 5, 7, 1, vecCnt);
pa1.loadAddSub(0, 5, 7, 1, vecCnt);
pa2.loadAddSub(0, 5, 7, 1, vecCnt);
pa3.loadAddSub(0, 5, 7, 1, vecCnt);
endrule
// 2: t2 = Px - Qx
rule op2_ctrl(oper == 4'd2 && fire_cond);
pa0.loadAddSub(0, 4, 6, 2, vecCnt);
pa1.loadAddSub(0, 4, 6, 2, vecCnt);
pa2.loadAddSub(0, 4, 6, 2, vecCnt);
pa3.loadAddSub(0, 4, 6, 2, vecCnt);
endrule
\end{lstlisting}
For example, my code snippet should be displayed like this:
// 1: t1 = Py - Qy
rule op1_ctrl(oper == 4'd1 && fire_cond);
pa0.loadAddSub(0, 5, 7, 1, vecCnt);
pa1.loadAddSub(0, 5, 7, 1, vecCnt);
pa2.loadAddSub(0, 5, 7, 1, vecCnt);
pa3.loadAddSub(0, 5, 7, 1, vecCnt);
endrule
// 2: t2 = Px - Qx
rule op2_ctrl(oper == 4'd2 && fire_cond); pa0.loadAddSub(0, 4, 6, 2, vecCnt);
pa1.loadAddSub(0, 4, 6, 2, vecCnt);
pa2.loadAddSub(0, 4, 6, 2, vecCnt);
pa3.loadAddSub(0, 4, 6, 2, vecCnt);
endrule
What I actually get is:
// 1: t1 = Py - Qy
rule op1_ctrl(oper == 4'd1 && fire_cond);
pa0.loadAddSub(0, 5, 7, 1, vecCnt);
pa1.loadAddSub(0, 5, 7, 1, vecCnt);
pa2.loadAddSub(0, 5, 7, 1, vecCnt);
pa3.loadAddSub(0, 5, 7, 1, vecCnt);
endrule
// 2: t2 = Px - Qx
rule op2_ctrl(oper == 4'd2 && fire_cond); pa0.loadAddSub(0, 4, 6, 2, vecCnt);
pa1.loadAddSub(0, 4, 6, 2, vecCnt);
pa2.loadAddSub(0, 4, 6, 2, vecCnt);
pa3.loadAddSub(0, 4, 6, 2, vecCnt);
endrule
Any ideas why this is happening or how I can fix it?
