|
| 1 | +% listings is a package that supports encapsulating source code in LaTeX conveniently |
| 2 | +\usepackage{listings} |
| 3 | + |
| 4 | +\def\expandparam\lstinputlisting[#1]#2{\edef\tmp{\noexpand\lstinputlisting[#1]{#2}}\tmp} |
| 5 | + |
| 6 | +%%%%%%%%%%%%%%%%%%%% Source Code Formatting %%%%%%%%%%%%%%%%%%%% |
| 7 | +\definecolor{globalCommentColour}{rgb}{0.588,0.588,0.588} |
| 8 | + |
| 9 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 10 | +% Defining language style |
| 11 | +% NiosII ASM |
| 12 | +\lstdefinelanguage[NiosII]{Assembler} { |
| 13 | + morekeywords={add, addi, and, andhi, andi, beq, bge, bgeu, bgt, bgtu, ble, bleu, blt, bltu, bne, br, break, |
| 14 | + bret, call, callr, cmpeq, cmpeqi, cmpge, cmpgei, cmpgeu, cmpgeui, cmpgt, cmpgti, cmpgtu, cmpgtui, cmple, |
| 15 | + cmplei, cmpleu, cmpleui, cmplt, cmplti, cmpltu, cmpltui, cmpne, cmpnei, custom, div, divu, eret, flushd, |
| 16 | + flushda, flushi, flushp, initd, initda, initi, jmp, jmpi, ldb, ldbio, ldbu, ldbuio, ldh, ldhio, ldhu, ldhuio, |
| 17 | + ldw, ldwio, mov, movhi, movi, movia, movui, mul, muli, mulxss, mulxsu, mulxuu, nextpc, nop, nor, or, orhi, ori, |
| 18 | + rdctl, rdprs, ret, rol, roli, ror, sll, slli, sra, srai, srl, srli, stb, stbio, sth, sthio, stw, stwio, |
| 19 | + sub, subi, sync, trap, wrctl, wrtcl, wrprs, xor, xori, xorhi, xori}, |
| 20 | + morekeywords=[2]{.abort, .ABORT, .align, .app-file, .ascii, .asciz, .balign, .byte, .comm, .data, .def, |
| 21 | + .desc, .dim, .double, .eject, .else, .end, .endef, .endif, .equ, .equiv, .err, .extern, .file, .fill, .float, |
| 22 | + .global, .globl, .hword, .ident, .if, .include, .int, .irp, .irpc, .lcomm, .lflags, .line, .linkonce, .ln, |
| 23 | + .list, .long, .macro, .mri, .nolist, .octa, .org, .p2align, .psize, .quad, .rept, .sbttl, .scl, .section, |
| 24 | + .set, .short, .single, .size, .sleb128, .skip, .space, .stadb, .stabn, .stabs, .string, .symver, .tag, |
| 25 | + .text, .title, .type, .val, .uleb128, .word}, |
| 26 | + morekeywords=[3]{et, bt, gp, sp, fp, ea, sstatus, ra, pc, status, estatus, bstatus, ienable, ipending, cpuid, |
| 27 | + exception, pteaddr, tlbacc, tlbmisc, eccinj, badaddr, config, mpubase, mpuacc}, |
| 28 | + sensitive=t, |
| 29 | + alsoletter=., |
| 30 | + morestring=[b]", |
| 31 | + morecomment=[s]{/*}{*/}, |
| 32 | + morecomment=[l]\#, |
| 33 | +}[keywords,comments,strings] |
| 34 | + |
| 35 | +%% NOTE: morekeywords=[2] are GNU directives. |
| 36 | + |
| 37 | +\definecolor{niosInstructionColour}{rgb}{0.000,0.608,0.000} |
| 38 | +\definecolor{niosDirectiveColour}{rgb}{0.000,0.000,0.902} |
| 39 | +\definecolor{niosSpecialRegColour}{rgb}{0.000,0.000,0.000} |
| 40 | +\definecolor{niosStringColour}{rgb}{0.808,0.482,0.000} |
| 41 | + |
| 42 | +%% NOTE: To make bold use: =\bfseries\color{<colour>} |
| 43 | +\lstdefinestyle{defaultNiosStyle} { |
| 44 | + language=[NiosII]{Assembler}, |
| 45 | + stringstyle=\color{niosStringColour}, |
| 46 | + keywordstyle=\color{niosInstructionColour}, |
| 47 | + keywordstyle=[2]\color{niosDirectiveColour}, |
| 48 | + keywordstyle=[3]\itshape\color{niosSpecialRegColour} |
| 49 | +} |
| 50 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 51 | + |
| 52 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 53 | +% Defining language style |
| 54 | +% ArmA9 ASM |
| 55 | +\lstdefinelanguage[ArmA9]{Assembler} { |
| 56 | + morekeywords={ADC, ADD, ADDS, AND, ANDS, B, BAL, BEQ, BGE, BGT, BL, BLT, BIC, BKPT, BLX, BNE, BX, CDP, CLZ, CMN, CMP, EOR, |
| 57 | + EORS, LDC, LDM, LDR, LDRB, LDRBT, LDRH, LDRSB, LDRSH, LDRT, LSL, MCR, MLA, MOV, MOVW, MOVT, MRC, MRS, MSR, MUL, MVN, ORR, PLD, |
| 58 | + ROR, RSB, RSC, SBC, SMLAL, SMULL, STC, STM, STR, STRB, STRBT, STRH, STRT, SUB, SUBS, SWI, SWP, SWPB, TEQ, UMLAL, |
| 59 | + PUSH, POP, MOVS, RORS, LSR}, |
| 60 | + morekeywords=[2]{.abort, .ABORT, .align, .app-file, .ascii, .asciz, .balign, .byte, .comm, .data, .def, |
| 61 | + .desc, .dim, .double, .eject, .else, .end, .endef, .endif, .equ, .equiv, .err, .extern, .file, .fill, .float, |
| 62 | + .global, .globl, .hword, .ident, .if, .include, .int, .irp, .irpc, .lcomm, .lflags, .line, .linkonce, .ln, |
| 63 | + .list, .long, .macro, .mri, .nolist, .octa, .org, .p2align, .psize, .quad, .rept, .sbttl, .scl, .section, |
| 64 | + .set, .short, .single, .size, .sleb128, .skip, .space, .stadb, .stabn, .stabs, .string, .symver, .tag, |
| 65 | + .text, .title, .type, .val, .vectors, .uleb128, .word}, |
| 66 | + morekeywords=[3]{SP, PC, MIDR, CTR, TCMTR, TLBTR, MPIDR, ID_PFR0, ID_PFR1, ID_DFR0, ID_MMFR0, ID_MMFR1, ID_MMFR2, |
| 67 | + ID_MMFR3, ID_ISAR0, ID_ISAR1, ID_ISAR2, ID_ISAR3, ID_ISAR4, CCSIDR, CLIDR, AIDR, CSSELR, TTBR0, TTRB1, TTBR2, DACR, |
| 68 | + DFSR, IFSR, ADFSR, AIFSR, DFAAR, IFAR, ICIALLUIS, BPIALLIS, PAR, ICIALLU, ICIMVAU, BPIALL, DCIMVAC, DCISW, V2PCWPR, |
| 69 | + DCCVAC, DCCSW, DDIMVAC, DCISW, TLBALLIS, TLBIMVAIS, TLBIASIDIS, TLBIMVAAIS, TLBIALL, TLBIMVA, TLBIASID, TLBIMVAA, |
| 70 | + PMCR, PMCNTENSET, PMCNTENCLR, PMOVSR, PMSWINC, PMSELR, PMXEVTYPER, PMXEVCNTR, PMUSERENR, PMINTENSET, PMINTENCLR, |
| 71 | + PRRR, NRRR, PLEIDR, PLEASR, PLEFSR, PLEUAR, PLEPCR, VBAR, MVBAR, ISR, FCSEIDR, CONTEXTIDR, TPIDRURW, TPIDRURO, TPIDRPRW}, |
| 72 | + sensitive=f, |
| 73 | + alsoletter=., |
| 74 | + morestring=[b]", |
| 75 | + morecomment=[s]{/*}{*/}, |
| 76 | + morecomment=[l]{//}, |
| 77 | +}[keywords,comments,strings] |
| 78 | + |
| 79 | +%% NOTE: morekeywords=[2] are GNU directives. |
| 80 | + |
| 81 | +\definecolor{armInstructionColour}{rgb}{0.000,0.608,0.000} |
| 82 | +\definecolor{armDirectiveColour}{rgb}{0.000,0.000,0.902} |
| 83 | +\definecolor{armSpecialRegColour}{rgb}{0.000,0.000,0.000} |
| 84 | +\definecolor{armStringColour}{rgb}{0.808,0.482,0.000} |
| 85 | + |
| 86 | +\lstdefinestyle{defaultArmStyle} { |
| 87 | + language=[ArmA9]{Assembler}, |
| 88 | + stringstyle=\color{armStringColour}, |
| 89 | + keywordstyle=\color{armInstructionColour}, |
| 90 | + keywordstyle=[2]\color{armDirectiveColour}, |
| 91 | + keywordstyle=[3]\itshape\color{armSpecialRegColour} |
| 92 | +} |
| 93 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 94 | + |
| 95 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 96 | +% Defining language style |
| 97 | +% FPGAcademy ASM |
| 98 | +\lstdefinelanguage{ASM}{ |
| 99 | + morekeywords = [1]{mv, mvt, mvne, mvcc, add, sub, st, ld, and, b, bne, beq, bcc, bcs}, |
| 100 | + morekeywords = [2]{word, define}, |
| 101 | + keywordstyle = [1]\color{ForestGreen}, |
| 102 | + keywordstyle = [2]\color{blue}, |
| 103 | + sensitive = true, |
| 104 | + morecomment = [l]{//}, |
| 105 | +} |
| 106 | + |
| 107 | +\lstset{ |
| 108 | + language = ASM, |
| 109 | + basicstyle=\small\color{black}\ttfamily, |
| 110 | + commentstyle=\small\color{Brown}\itshape\ttfamily, |
| 111 | + showstringspaces=false, |
| 112 | + frame=none, %lines % boxed listings |
| 113 | + breaklines=true, |
| 114 | + breakatwhitespace=true, |
| 115 | + tabsize=3 |
| 116 | +} |
| 117 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 118 | + |
| 119 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 120 | +% Defining language style |
| 121 | +% Java |
| 122 | +\definecolor{javaStringColour}{rgb}{0.808,0.482,0} |
| 123 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 124 | + |
| 125 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 126 | +% Defining language style |
| 127 | +% C |
| 128 | +\definecolor{CStringColour}{rgb}{0.808,0.482,0} |
| 129 | + |
| 130 | +\lstset{ |
| 131 | + language = C, |
| 132 | + basicstyle=\small\color{black}\ttfamily, |
| 133 | + commentstyle=\small\color{PineGreen}\itshape\ttfamily, |
| 134 | + keywordstyle=\small\color{blue}\bfseries\ttfamily, |
| 135 | + showstringspaces=false, |
| 136 | + frame=none, %lines % boxed listings |
| 137 | + breaklines=true, |
| 138 | + breakatwhitespace=true, |
| 139 | + tabsize=3 |
| 140 | +} |
| 141 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 142 | + |
| 143 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 144 | +% Defining language style |
| 145 | +% Verilog |
| 146 | +\definecolor{verilogCommentColour}{rgb}{0.000,0.502,0.000} |
| 147 | + |
| 148 | +\lstdefinestyle{defaultVerilogStyle} { |
| 149 | + language={Verilog}, |
| 150 | + keywordstyle=\color{blue}, |
| 151 | + commentstyle=\color{verilogCommentColour} |
| 152 | +} |
| 153 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 154 | + |
| 155 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 156 | +% Defining language style |
| 157 | +% VHDL |
| 158 | +\lstdefinestyle{defaultVHDLStyle} { |
| 159 | + language={VHDL}, |
| 160 | + keywordstyle=\color{blue}, |
| 161 | + commentstyle=\color{verilogCommentColour} |
| 162 | +} |
| 163 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 164 | + |
| 165 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 166 | +% Defining language style |
| 167 | +% LaTeX |
| 168 | +\lstdefinelanguage[LocalLaTeX]{TeX}[LaTeX]{TeX}{moretexcs={bf, it, sf, lstset},} |
| 169 | + |
| 170 | +\lstdefinestyle{defaultLocalLatexStyle} { |
| 171 | + language=[LocalLatex]{TeX}, |
| 172 | + keywordstyle=\color{blue}\bfseries, |
| 173 | + keywordstyle=[2]\color{blue}, |
| 174 | + keywordstyle=[3]\color{blue}\bfseries |
| 175 | +} |
| 176 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 177 | + |
| 178 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 179 | +% Defining language style |
| 180 | +% Default |
| 181 | +\lstset{ |
| 182 | + basicstyle=\small\color{black}\ttfamily, |
| 183 | + commentstyle=\small\color{globalCommentColour}\itshape\ttfamily, |
| 184 | + keywordstyle=\small\color{blue}\bfseries\ttfamily, |
| 185 | + showstringspaces=false, |
| 186 | + frame=none, %lines % boxed listings |
| 187 | + breaklines=true, |
| 188 | + breakatwhitespace=true, |
| 189 | + tabsize=3 |
| 190 | +} |
| 191 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 commit comments