<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Code Farmer</title>
        <link>https://velog.io/</link>
        <description>System Software Engineer</description>
        <lastBuildDate>Mon, 25 Aug 2025 15:54:17 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Code Farmer</title>
            <url>https://velog.velcdn.com/images/sangs_o/profile/8dfe124f-e6c1-4a95-a2de-3e3ba9d98cf8/social_profile.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. Code Farmer. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/sangs_o" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[Representation of Data (3)]]></title>
            <link>https://velog.io/@sangs_o/Representation-of-Data-3</link>
            <guid>https://velog.io/@sangs_o/Representation-of-Data-3</guid>
            <pubDate>Mon, 25 Aug 2025 15:54:17 GMT</pubDate>
            <description><![CDATA[<h2 id="section-02-representation-of-data">[Section 02] representation of data</h2>
<h3 id="ascii-to-unicode--how-text-is-stored-and-moved">ASCII to Unicode — How Text Is Stored and Moved</h3>
<br>

<blockquote>
<p>A concise, practical guide to <strong>ASCII</strong>, its limits, and how <strong>Unicode</strong> (UTF-8/16/32) solves them. Examples use C.</p>
</blockquote>
<hr>
<h3 id="ascii-in-one-page">ASCII in One Page</h3>
<p><strong>ASCII (American Standard Code for Information Interchange)</strong> encodes characters with <strong>7 bits</strong> (0–127).</p>
<pre><code>+-- zone (3 bits) --+--- digit (4 bits) ---+
 b6      b5     b4      b3  b2  b1   b0</code></pre><ul>
<li><p>Historically, links and memory often used an extra <strong>8th bit</strong> (parity or just 0).</p>
</li>
<li><p>Character sets included:</p>
<ul>
<li><strong>Control characters</strong>: 0–31 and 127 (NUL, BEL, CR, LF, ESC, DEL)</li>
<li><strong>Printable</strong>: space (32), punctuation, digits <code>0–9</code>, <code>A–Z</code>, <code>a–z</code></li>
</ul>
</li>
</ul>
<p><strong>Reading the classic table</strong></p>
<ul>
<li>Column gives the <strong>zone</strong> (upper 3 bits), row gives the <strong>digit</strong> (lower 4 bits).
Example for <code>&#39;A&#39;</code>: zone <code>100</code>, digit <code>0001</code> → <code>1000001₂</code> → <code>0x41</code> → decimal <strong>65</strong>.</li>
</ul>
<hr>
<h3 id="common-ranges-youll-use-these-daily">Common Ranges (you’ll use these daily)</h3>
<table>
<thead>
<tr>
<th>Group</th>
<th align="right">Range (hex)</th>
<th>Notes</th>
</tr>
</thead>
<tbody><tr>
<td>Control chars</td>
<td align="right"><code>0x00–0x1F</code>, <code>0x7F</code></td>
<td>NUL, BEL, CR, LF, ESC, DEL</td>
</tr>
<tr>
<td>Space</td>
<td align="right"><code>0x20</code></td>
<td><code>&#39; &#39;</code></td>
</tr>
<tr>
<td>Digits <code>0–9</code></td>
<td align="right"><code>0x30–0x39</code></td>
<td><code>&#39;0&#39; = 0x30</code></td>
</tr>
<tr>
<td>Uppercase <code>A–Z</code></td>
<td align="right"><code>0x41–0x5A</code></td>
<td><code>&#39;A&#39; = 0x41</code></td>
</tr>
<tr>
<td>Lowercase <code>a–z</code></td>
<td align="right"><code>0x61–0x7A</code></td>
<td><code>&#39;a&#39; = 0x61</code></td>
</tr>
</tbody></table>
<p><strong>Case bit trick</strong>
Upper/lower differ by <strong>0x20</strong> (bit 5).</p>
<ul>
<li><code>&#39;a&#39; - &#39;A&#39; == 32</code></li>
<li><code>c ^ 0x20</code> toggles case when <code>c</code> is an ASCII letter.</li>
</ul>
<hr>
<h3 id="c-snippets">C Snippets</h3>
<h4 id="print-ascii-code-of-a-character">Print ASCII code of a character</h4>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main(void) {
    char c = &#39;A&#39;;
    printf(&quot;char: %c, dec: %d, hex: 0x%02X, bin: &quot;, c, (unsigned char)c, (unsigned char)c);

    unsigned char u = (unsigned char)c;
    for (int i = 7; i &gt;= 0; --i) {
        putchar((u &amp; (1u &lt;&lt; i)) ? &#39;1&#39; : &#39;0&#39;);
    }
    putchar(&#39;\n&#39;);
    return 0;
}</code></pre>
<h4 id="lowercaseuppercase-ascii-only">Lowercase/uppercase (ASCII only)</h4>
<pre><code class="language-c">#include &lt;stdbool.h&gt;

static inline bool is_upper_ascii(char c) { return c &gt;= &#39;A&#39; &amp;&amp; c &lt;= &#39;Z&#39;; }
static inline bool is_lower_ascii(char c) { return c &gt;= &#39;a&#39; &amp;&amp; c &lt;= &#39;z&#39;; }

static inline char to_lower_ascii(char c) {
    return is_upper_ascii(c) ? (char)(c | 0x20) : c;   // set bit 5
}

static inline char to_upper_ascii(char c) {
    return is_lower_ascii(c) ? (char)(c &amp; ~0x20) : c;  // clear bit 5
}</code></pre>
<h4 id="minimal-ascii-table-printables-only">Minimal ASCII table (printables only)</h4>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main(void) {
    for (int i = 32; i &lt;= 126; ++i) {
        printf(&quot;%3d 0x%02X &#39;%c&#39;%s&quot;, i, i, (char)i, (i % 8 == 7) ? &quot;\n&quot; : &quot;   &quot;);
    }
    printf(&quot;\n&quot;);
    return 0;
}</code></pre>
<hr>
<h3 id="why-ascii-wasnt-enough">Why ASCII Wasn’t Enough</h3>
<p>ASCII covers <strong>128 symbols</strong>. That’s fine for basic English, but it cannot represent:</p>
<ul>
<li>Accented Latin letters (é, ü), math symbols, emoji</li>
<li>Non-Latin scripts (한국어, 日本語, العربية, …)</li>
</ul>
<p>Historic workarounds:</p>
<ul>
<li><strong>Extended ASCII (8-bit code pages)</strong>: incompatible sets above <code>0x7F</code></li>
<li><strong>EBCDIC</strong> (IBM mainframes): different 8-bit layout</li>
<li><strong>BCD</strong> (Binary-Coded Decimal): encodes digits in 4 bits; not a character set</li>
</ul>
<p>These lacked global interoperability.</p>
<hr>
<h3 id="unicode-one-code-space-for-all-writing-systems">Unicode: One Code Space for All Writing Systems</h3>
<p><strong>Unicode</strong> assigns a unique <strong>code point</strong> to each character:
<code>U+0041 &#39;A&#39;</code>, <code>U+AC00 &#39;가&#39;</code>, <code>U+1F600 &#39;😀&#39;</code>, …</p>
<p>Unicode is a catalog of code points; you still need an <strong>encoding</strong> to store/transmit:</p>
<h4 id="utf-8">UTF-8</h4>
<ul>
<li><strong>Variable length (1–4 bytes)</strong></li>
<li><strong>ASCII 0x00–0x7F</strong> maps to <strong>exactly the same single byte</strong> → backward compatible</li>
<li>Dominant on the web and UNIX-like systems</li>
</ul>
<h4 id="utf-16">UTF-16</h4>
<ul>
<li>2 or 4 bytes (surrogate pairs)</li>
<li>Common in Windows and some language runtimes</li>
</ul>
<h4 id="utf-32">UTF-32</h4>
<ul>
<li>Fixed 4 bytes per code point (simple, larger memory footprint)</li>
</ul>
<p><strong>Rule of thumb:</strong> use <strong>UTF-8</strong> unless a legacy interface requires otherwise.</p>
<hr>
<h3 id="ascii-vs-unicode-in-practice">ASCII vs Unicode in Practice</h3>
<ul>
<li>ASCII is a <strong>subset</strong> of Unicode: <code>U+0000–U+007F</code>.</li>
<li>In UTF-8, those code points use the <strong>same bytes</strong> as ASCII.</li>
<li>The moment you need anything beyond ASCII (accents, CJK, emoji), store and serve text as <strong>UTF-8</strong>.</li>
</ul>
<hr>
<h3 id="quick-reference">Quick Reference</h3>
<pre><code>ASCII   : 7-bit (0x00–0x7F). Often stored in 8 bits.
EBCDIC  : IBM 8-bit alternative; different assignments.
BCD     : Decimal digits in 4 bits (not a character set).
Unicode : Universal code points (U+0000…); needs an encoding.
UTF-8   : 1–4 bytes, ASCII-compatible. Default choice today.
UTF-16  : 2/4 bytes with surrogates.
UTF-32  : 4 bytes fixed width.</code></pre><hr>
<h3 id="decode-practice">Decode (practice)</h3>
<ol>
<li><code>0x41</code> → <code>0100 0001₂</code> → <code>&#39;A&#39;</code></li>
<li><code>0x30–0x39</code> → <code>&#39;0&#39;…&#39;9&#39;</code></li>
<li><code>0x61</code> (<code>0110 0001₂</code>) → <code>&#39;a&#39;</code>; toggle case: <code>0x61 ^ 0x20 = 0x41</code> (<code>&#39;A&#39;</code>)</li>
</ol>
]]></description>
        </item>
        <item>
            <title><![CDATA[Representation of Data (2)]]></title>
            <link>https://velog.io/@sangs_o/Representation-of-Data-2-k5hilt5c</link>
            <guid>https://velog.io/@sangs_o/Representation-of-Data-2-k5hilt5c</guid>
            <pubDate>Wed, 20 Aug 2025 16:01:29 GMT</pubDate>
            <description><![CDATA[<h2 id="section-02-representation-of-data">[Section 02] representation of data</h2>
<h3 id="binary-representation-of-numbers--a-practical-guide-integers--floats">Binary Representation of Numbers — A Practical Guide (Integers &amp; Floats)</h3>
<br>

<h3 id="why-multiple-representations">Why multiple representations?</h3>
<p>Computers store values in fixed-width bit strings. For signed integers we need a way to encode “−” as well as magnitude. Three classic schemes exist:</p>
<ul>
<li><strong>Sign–Magnitude</strong></li>
<li><strong>One’s Complement</strong></li>
<li><strong>Two’s Complement</strong> (what modern CPUs use)</li>
</ul>
<p>They agree on non-negative encodings but differ in how they encode negatives and how arithmetic works.</p>
<br>

<h3 id="signmagnitude">Sign–Magnitude</h3>
<ul>
<li>Layout (for an <em>n</em>-bit word):
<strong>[ sign (1 bit) | magnitude (n−1 bits) ]</strong>
sign <code>0</code> = “+”, sign <code>1</code> = “−”.</li>
<li>Example (8-bit):
<code>+21  = 0 | 0010101₂</code>
<code>−21  = 1 | 0010101₂</code></li>
<li><strong>Pros</strong>: Intuitively mirrors human notation.</li>
<li><strong>Cons</strong>: Two zeros (<code>+0 = 0|000…0</code>, <code>−0 = 1|000…0</code>), and hardware must treat sign separately for addition/subtraction.</li>
</ul>
<p><strong>Value range (n bits)</strong>: <code>−(2^(n−1)−1) … + (2^(n−1)−1)</code> (note: both +0 and −0 exist)</p>
<br>

<h3 id="ones-complement-1s-complement">One’s Complement (1’s complement)</h3>
<ul>
<li><p>Rule: Represent a negative number by <strong>bitwise inverting</strong> the positive pattern.</p>
</li>
<li><p>Example (8-bit):</p>
<pre><code>+21 = 0001 0101
−21 = ~0001 0101 = 1110 1010</code></pre></li>
<li><p><strong>Pros</strong>: Subtraction can be implemented as “add the one’s complement”.</p>
</li>
<li><p><strong>Cons</strong>: Still has <strong>−0 = 1111 1111</strong>, so there are two zeros; arithmetic needs end-around carry fix-ups.</p>
</li>
</ul>
<p><strong>Value range (n bits)</strong>: <code>−(2^(n−1)−1) … + (2^(n−1)−1)</code> (with ±0)</p>
<br>

<h3 id="twos-complement-2s-complement">Two’s Complement (2’s complement)</h3>
<ul>
<li><p>Rule: Represent <code>−x</code> by <strong>invert</strong> the bits of <code>x</code> and <strong>add 1</strong> (modulo 2^n).</p>
</li>
<li><p>Example (8-bit):</p>
<pre><code>+21 = 0001 0101
~   = 1110 1010
+1  = 1110 1011  -&gt; −21</code></pre></li>
<li><p><strong>Pros</strong>: A <strong>single zero</strong>, and the same adder does both addition &amp; subtraction. Simple sign extension.</p>
</li>
<li><p><strong>Cons</strong>: Asymmetric range (one extra negative value).</p>
</li>
</ul>
<p><strong>Value range (n bits)</strong>: <code>−2^(n−1) … + (2^(n−1)−1)</code>
(e.g., 8-bit: −128 … +127)</p>
<br>

<h3 id="worked-example-±21-in-8-bits">Worked example: ±21 in 8 bits</h3>
<table>
<thead>
<tr>
<th>Scheme</th>
<th><code>+21</code> (binary)</th>
<th><code>−21</code> (binary)</th>
<th>Notes</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td>Sign–Magnitude</td>
<td>`0</td>
<td>0010101`</td>
<td>`1</td>
<td>0010101`</td>
<td>sign bit + 7-bit magnitude</td>
</tr>
<tr>
<td>One’s Complement</td>
<td><code>00010101</code></td>
<td><code>11101010</code></td>
<td>invert for negatives</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Two’s Complement</td>
<td><code>00010101</code></td>
<td><code>11101011</code></td>
<td>invert + 1</td>
<td></td>
<td></td>
</tr>
</tbody></table>
<blockquote>
<p>Tip: <strong>Sign extension</strong> (two’s complement): when widening, copy the sign bit into the new upper bits.
Example: <code>1110 1011</code> (−21, 8-bit) → <code>1111 1111 1110 1011</code> (−21, 16-bit).</p>
</blockquote>
<br>

<h3 id="quick-comparison">Quick comparison</h3>
<table>
<thead>
<tr>
<th>Representation</th>
<th>Zero(s)</th>
<th>Integer Range (n bits)</th>
<th>Arithmetic Hardware</th>
<th>Notes</th>
</tr>
</thead>
<tbody><tr>
<td>Sign–Magnitude</td>
<td><code>+0</code> and <code>−0</code></td>
<td><code>−(2^(n−1)−1)</code> … <code>+(2^(n−1)−1)</code></td>
<td>Complex (separate sign)</td>
<td>Conceptually simple; not used in CPUs</td>
</tr>
<tr>
<td>1’s Complement</td>
<td><code>+0</code> and <code>−0</code></td>
<td><code>−(2^(n−1)−1)</code> … <code>+(2^(n−1)−1)</code></td>
<td>Needs end-around carry</td>
<td>Historical systems (e.g., early CDC)</td>
</tr>
<tr>
<td>2’s Complement</td>
<td>Single <code>0</code></td>
<td><code>−2^(n−1)</code> … <code>+(2^(n−1)−1)</code></td>
<td>Simple, unified adder</td>
<td>Ubiquitous in modern hardware</td>
</tr>
</tbody></table>
<br>

<h3 id="self-check-encode-−39-in-3-bytes-24-bits">Self-check: encode −39 in 3 bytes (24 bits)</h3>
<p>Let <code>n = 24</code>.</p>
<ol>
<li><strong>Sign–Magnitude</strong></li>
</ol>
<ul>
<li>Magnitude of 39 = <code>…000100111₂</code>.</li>
<li>Result: <code>1 | 000000000000000000100111</code></li>
</ul>
<ol start="2">
<li><strong>One’s Complement</strong></li>
</ol>
<ul>
<li><code>+39 = 00000000 00000000 00100111</code></li>
<li>Invert → <strong><code>11111111 11111111 11011000</code></strong> (hex <code>0xFFFFD8</code>)</li>
</ul>
<ol start="3">
<li><strong>Two’s Complement</strong></li>
</ol>
<ul>
<li>Take one’s complement and add 1 → <strong><code>11111111 11111111 11011001</code></strong> (hex <code>0xFFFFD9</code>)</li>
</ul>
<hr>
<h3 id="real-numbers-fixed-point-vs-floating-point">Real numbers: fixed-point vs floating-point</h3>
<p>Computers also need fractions. Two main approaches:</p>
<h4 id="fixed-point">Fixed-point</h4>
<ul>
<li>The <strong>binary point</strong> is at a fixed, agreed position.</li>
<li>Great for DSP/embedded when range and scaling are known.</li>
<li>Simple hardware, predictable overflow, but <strong>limited dynamic range</strong>.</li>
</ul>
<h4 id="floating-point-ieee-754">Floating-point (IEEE-754)</h4>
<ul>
<li>Scientific-notation style:
<code>value = (−1)^sign × 1.fraction × 2^(exponent − bias)</code> (for normalized numbers)</li>
<li>Much <strong>wider dynamic range</strong> than fixed-point.</li>
<li>Standard layouts:</li>
</ul>
<p><strong>Single precision (32-bit)</strong></p>
<pre><code>[ sign (1) | exponent (8, bias=127) | fraction (23) ]</code></pre><p><strong>Double precision (64-bit)</strong></p>
<pre><code>[ sign (1) | exponent (11, bias=1023) | fraction (52) ]</code></pre><blockquote>
<p>The implicit leading <code>1.</code> is not stored for normalized numbers; the <strong>fraction</strong> field holds the bits <strong>after</strong> the point.</p>
</blockquote>
<br>

<h3 id="converting-a-binary-fraction-to-ieee-754">Converting a binary fraction to IEEE-754</h3>
<p>Example: convert <strong><code>100010.101₂</code></strong> to single &amp; double precision.</p>
<ol>
<li><p><strong>Normalize</strong> so the leading bit is <code>1</code>:</p>
<pre><code>100010.101₂ = 1.00010101₂ × 2^5</code></pre></li>
<li><p><strong>Sign</strong>: <code>0</code> (positive)</p>
</li>
<li><p><strong>Exponent</strong>:</p>
<ul>
<li>Single: <code>5 + 127 = 132 = 1000 0100₂</code></li>
<li>Double: <code>5 + 1023 = 1028 = 100 0000 0100₂</code></li>
</ul>
</li>
<li><p><strong>Fraction</strong> (drop the leading <code>1.</code> and fill right with zeros):</p>
<ul>
<li>From <code>1.00010101₂</code> → fraction bits <code>00010101…</code></li>
</ul>
</li>
</ol>
<p><strong>Final encodings</strong></p>
<ul>
<li><p><strong>Single (32-bit)</strong>
Bits: <code>0 | 10000100 | 00010101000000000000000</code>
Hex: <strong><code>0x420A8000</code></strong></p>
</li>
<li><p><strong>Double (64-bit)</strong>
Bits: <code>0 | 10000000100 | 0001010100000000000000000000000000000000000000000000</code>
Hex: <strong><code>0x4041500000000000</code></strong></p>
</li>
</ul>
<br>

<h3 id="quick-reference--formulas">Quick reference &amp; formulas</h3>
<ul>
<li><p><strong>One’s complement</strong> (n bits)</p>
<pre><code>encode(+x) = binary(x)
encode(−x) = (2^n − 1) − binary(x)</code></pre></li>
<li><p><strong>Two’s complement</strong> (n bits)</p>
<pre><code>encode(+x) = binary(x)
encode(−x) = 2^n − binary(x)  = (~binary(x) + 1) mod 2^n</code></pre></li>
<li><p><strong>Sign extension (two’s complement)</strong></p>
<pre><code>from n→m bits (m&gt;n): replicate sign bit into the new high (m−n) bits</code></pre></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Pin a Package Version Installed via .deb or apt on Ubuntu]]></title>
            <link>https://velog.io/@sangs_o/Pin-a-Package-Version-Installed-via-.deb-or-apt-on-Ubuntu</link>
            <guid>https://velog.io/@sangs_o/Pin-a-Package-Version-Installed-via-.deb-or-apt-on-Ubuntu</guid>
            <pubDate>Thu, 14 Aug 2025 15:38:28 GMT</pubDate>
            <description><![CDATA[<p>Keep a specific app version even when you run <code>apt update</code> / <code>apt upgrade</code>.
<br></p>
<ul>
<li><strong>Quick &amp; simple:</strong> <code>sudo apt-mark hold &lt;package&gt;</code></li>
<li><strong>Strict version pin:</strong> create <code>/etc/apt/preferences.d/&lt;package&gt;.pref</code> with <code>Pin: version &lt;x.y.z&gt;</code></li>
<li>(Optional) <strong>Disable the vendor repo</strong> if it keeps offering newer builds.</li>
</ul>
<h2 id="why-pin">Why pin?</h2>
<p>If updating a package (e.g., FortiClient) breaks your workflow, you can <strong>freeze</strong> that package at a working version while keeping the rest of the system updated.</p>
<p>This works whether you installed the app via:</p>
<ul>
<li><code>apt install ./file.deb</code> (local <code>.deb</code>)</li>
<li><code>apt install &lt;package&gt;</code> (from a repo)</li>
</ul>
<h2 id="1-easiest-apt-mark-hold">1) Easiest: <code>apt-mark hold</code></h2>
<pre><code class="language-bash"># Freeze the package at its current version
sudo apt-mark hold forticlient

# Verify
apt-mark showhold
# (shows: forticlient)

# Later, to allow upgrades again
sudo apt-mark unhold forticlient</code></pre>
<p>After this, <code>sudo apt upgrade</code> will <strong>skip</strong> <code>forticlient</code>.</p>
<p><strong>Tip – simulate an upgrade to confirm:</strong></p>
<pre><code class="language-bash">apt -s upgrade | grep -i forticlient || echo &quot;forticlient not scheduled for upgrade&quot;</code></pre>
<h2 id="2-pin-a-specific-version-apt-pinning">2) Pin a specific version (APT pinning)</h2>
<p>Use this when you want to lock to an <strong>exact</strong> version.</p>
<pre><code class="language-bash"># Create a pin file for this package/version
sudo tee /etc/apt/preferences.d/forticlient.pref &gt;/dev/null &lt;&lt;&#39;EOF&#39;
Package: forticlient
Pin: version 7.4.0.1636
Pin-Priority: 1001
EOF

# Refresh and inspect policies
sudo apt update
apt policy forticlient</code></pre>
<ul>
<li><code>Pin-Priority: 1001</code> ensures your chosen version wins over newer ones.</li>
<li>To upgrade later, <strong>remove the pin</strong>:</li>
</ul>
<pre><code class="language-bash">sudo rm /etc/apt/preferences.d/forticlient.pref
sudo apt update

# Optionally install a specific version when you&#39;re ready
sudo apt install forticlient=7.4.3.1736</code></pre>
<h2 id="3-optional-disable-a-vendor-repo">3) (Optional) Disable a vendor repo</h2>
<p>If a <strong>vendor repo</strong> keeps pushing newer versions, it will still be ignored by <code>hold</code>/pinning, but you can disable it for cleanliness:</p>
<pre><code class="language-bash"># Check for vendor list files
ls /etc/apt/sources.list.d | grep -i forti

# Example: comment out entries inside that list file
sudo sed -i &#39;s/^\s*deb /# deb /&#39; /etc/apt/sources.list.d/fortinet.list
sudo apt update</code></pre>
<h2 id="example-forticlient">Example: FortiClient</h2>
<p>If <code>apt list --installed</code> shows:</p>
<pre><code class="language-bash">forticlient/now 7.4.0.1636 amd64 [installed,upgradable to: 7.4.3.1736]</code></pre>
<p><strong>Option A – hold:</strong></p>
<pre><code class="language-bash">sudo apt-mark hold forticlient
apt-mark showhold</code></pre>
<p><strong>Option B – exact version pin:</strong></p>
<pre><code class="language-bash">sudo tee /etc/apt/preferences.d/forticlient.pref &gt;/dev/null &lt;&lt;&#39;EOF&#39;
Package: forticlient
Pin: version 7.4.0.1636
Pin-Priority: 1001
EOF

sudo apt update
apt policy forticlient</code></pre>
<h2 id="notes--tips">Notes &amp; Tips</h2>
<ul>
<li><code>apt update</code> only refreshes indexes; <strong>upgrades happen</strong> on <code>apt upgrade</code> / <code>apt full-upgrade</code>.</li>
<li><code>hold</code> applies to the package name you specify. If the vendor changes the package name, re-apply the hold for the new name.</li>
<li>To hold <strong>multiple</strong> packages:</li>
</ul>
<pre><code class="language-bash">sudo apt-mark hold pkg1 pkg2 pkg3</code></pre>
<ul>
<li>You can always <strong>force-install</strong> a specific version (if available in any enabled repo or local cache):</li>
</ul>
<pre><code class="language-bash">sudo apt install package=VERSION</code></pre>
<h2 id="unfreeze-later">Unfreeze later</h2>
<p>When the vendor fixes the issue and you&#39;re ready to upgrade:</p>
<pre><code class="language-bash"># If you used hold:
sudo apt-mark unhold forticlient

# If you used pinning:
sudo rm /etc/apt/preferences.d/forticlient.pref

sudo apt update
sudo apt upgrade</code></pre>
<p>That&#39;s it—your system stays updated while your problematic app version remains stable.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[RTL Simulation and QEMU]]></title>
            <link>https://velog.io/@sangs_o/RTL-Simulation-and-QEMU</link>
            <guid>https://velog.io/@sangs_o/RTL-Simulation-and-QEMU</guid>
            <pubDate>Thu, 14 Aug 2025 13:52:16 GMT</pubDate>
            <description><![CDATA[<h3 id="rtl-simulation">RTL simulation</h3>
<p><a href="https://wikidocs.net/170339">https://wikidocs.net/170339</a></p>
<p>DPI-C &amp; UVM
<img src="https://velog.velcdn.com/images/sangs_o/post/138d05fb-867c-4eaa-81b8-35bb596bc8bd/image.png" alt=""></p>
<ul>
<li>DPI is an interface between SystemVerilog and a foreign programming language.</li>
<li>Two layers, both sides of DPI are fully isolated<ul>
<li>the SystemVerilog layer</li>
<li>a foreign language layer</li>
</ul>
</li>
<li>For now, SystemVerilog defines a foreign language layer only for the C programming language</li>
</ul>
<h3 id="uvm">UVM</h3>
<p>Universial Verification Methodology
<a href="https://wikidocs.net/170314">https://wikidocs.net/170314</a>!
<img src="https://velog.velcdn.com/images/sangs_o/post/5a3b19b5-3fea-4db5-ae74-053a0492f387/image.png" alt=""></p>
<p><a href="https://systemc.org/">https://systemc.org/</a>
SystemC™ addresses the need for a system design and verification language that spans hardware and software. It is a language built in standard C++ by extending the language with the use of class libraries. The language is particularly suited to model system&#39;s partitioning, to evaluate and verify the assignment of blocks to either hardware or software implementations, and to architect and measure the interactions between and among functional blocks.<img src="https://velog.velcdn.com/images/sangs_o/post/27a31758-ab5f-4c1c-af18-20c51634d8c2/image.png" alt=""></p>
<p>An SoC is literally a system on a chip, consisting of both silicon and embedded software. Its design involves complex algorithm and architecture development and analysis similar to that performed in system design – a trade-off process that determines critical metrics, such as SOC performance, functionality, and power consumption.</p>
<p>Consequently, design tools must deliver orders-of-magnitude improvement in productivity at both architectural and implementation (RT and physical) levels. Moreover, tools must support a methodology that enables the early development of embedded application and system software, long before the availability of the RTL design or silicon prototype. Failure to achieve the requisite improvements in design productivity would result in missed market windows, and exploding design costs.</p>
<p>SystemC is a single, unified design and verification language that expresses architectural and other system-level attributes in the form of open-source C++ classes. It enables design and verification at the system level, independent of any detailed hardware and software implementation, as well as enabling co-verification with RTL design. This higher level of abstraction enables considerably faster, more productive architectural trade-off analysis, design, and redesign than is possible at the more detailed RT level. Furthermore, verification of system architecture and other system-level attributes is orders of magnitude faster than that at the pin-accurate, timing-accurate RT level.</p>
<p>The SystemC community consists of a large and growing number of system design companies, semiconductor companies, intellectual property providers, and EDA tool vendors who have joined together to support and promote the standard.</p>
<h3 id="qemu">QEMU</h3>
<p><a href="https://www.qemu.org/docs/master/">https://www.qemu.org/docs/master/</a>
QEMU is a generic and open source machine emulator and virtualizer.</p>
<p>QEMU can be used in several different ways. The most common is for System Emulation, where it provides a virtual model of an entire machine (CPU, memory and emulated devices) to run a guest OS. In this mode the CPU may be fully emulated, or it may work with a hypervisor such as KVM, Xen or Hypervisor.Framework to allow the guest to run directly on the host CPU.</p>
<p>The second supported way to use QEMU is User Mode Emulation, where QEMU can launch processes compiled for one CPU on another CPU. In this mode the CPU is always emulated.
QEMU also provides a number of standalone command line utilities, such as the qemu-img disk image utility that allows you to create, convert and modify disk images.
When operating in user mode, only the user-level code is translated. In system mode, the entire system, including kernel-level code is translated.</p>
<ol>
<li><p>Execute
QEMU is not an RTL‑accurate simulator.
It is a full‑system emulator that translates a guest CPU&#39;s binary code into host instructions at run‑time, drives that code from a software‑defined &quot;soft‑MMU,&quot; and connects the resulting virtual machine to an extensive catalogue of device models. This approach gives near‑native speed on a developer laptop while remaining completely architecture‑agnostic.</p>
</li>
<li><p>Dynamic binary translation with TCG Stage
Because translation is demand‑driven, hot paths stay cached while cold code never incurs compilation cost. With this &quot;Tiny Code Generator&quot; (TCG) design, a new host CPU needs only a ~2 kLOC back‑end, while each new guest ISA needs a front‑end translator. This split is why QEMU today supports more than 20 architectures without exploding in size.</p>
</li>
</ol>
<table>
<thead>
<tr>
<th>Stage</th>
<th>What happens</th>
<th>Key data-structures / APIs</th>
</tr>
</thead>
<tbody><tr>
<td>Front-end decode</td>
<td>When the guest PC points at code QEMU has never seen, the &quot;translator&quot; for that ISA decodes a <em>translation block</em> (TB)—roughly one basic block of guest instructions.</td>
<td><code>DisasContext</code>, per-ISA translate functions</td>
</tr>
<tr>
<td>TCG IR build</td>
<td>Each guest instruction is lowered into a small, RISC-like TCG op sequence. The IR is architecture-neutral, which is why the translator back-ends are small and easy to port.</td>
<td><code>tcg/optimize.c</code>, <code>TCGOp</code>, <code>TCGTemp</code></td>
</tr>
<tr>
<td>Local optimisation</td>
<td>Peephole passes (constant folding, dead-code elimination, simple CSE) trim the IR.</td>
<td><code>tcg/optimize.c</code></td>
</tr>
<tr>
<td>Back-end code-gen</td>
<td>The IR is emitted as host machine code (x86-64 in your scenario). The generated code plus a short prologue/epilogue is copied into a global code cache.</td>
<td><code>tcg/target/x86/tcg-target.c.inc</code></td>
</tr>
<tr>
<td>Execution &amp; chaining</td>
<td>The host CPU jumps into the cache. At TB exit, QEMU can <em>direct-chain</em> to the next TB to remove dispatcher overhead.</td>
<td><code>cpu_exec()</code>, TB links</td>
</tr>
<tr>
<td><br></td>
<td></td>
<td></td>
</tr>
</tbody></table>
<ol start="3">
<li><p>The Soft‑MMU and memory‑mapped I/O</p>
<p>3.1 Address translation
Every guest memory access issued by generated code is wrapped in a helper that goes through QEMU&#39;s soft‑MMU TLB. The TLB entries are patched directly into the host code, so the fast path is just a couple of host instructions. A miss traps back into C, performs page‑table walks, and repatches the TB‑‑exactly mirroring real hardware, but in software.</p>
<p>3.2 MMIO hooks
If the physical address lies inside a MemoryRegion flagged as device, the load/store is re‑routed to an emulated callback (, ). Device authors therefore implement register‑level side‑effects in standard C while the common memory API handles endianness, burst limitations, coalesced writes, and KVM ioeventfd plumbing.</p>
<br>
</li>
<li><p>Device modelling architecture</p>
<ul>
<li>QOM (QEMU Object Model). All devices, buses and even CPUs are QOM objects, enabling run‑time type checking, property wiring and hot‑plug.</li>
<li>Bus hierarchy. Templates exist for PCI, USB, VirtIO, SPI, I²C, AXI, etc. A MemoryRegion can be placed behind any bus master to create bridges, address windows or DMA engines.</li>
<li>Firmware integration. ACPI tables or Flattened Device Tree blobs are generated automatically so that unmodified kernels &quot;see&quot; the devices exactly as hardware would present them.</li>
</ul>
<p>Compared with cycle‑accurate simulators, the timing model is intentionally loosely timed: the goal is functional correctness plus &quot;good enough&quot; latency to boot real OSes and run benchmarks.</p>
<br></li>
<li><p>Acceleration paths: pure TCG vs. KVM/HVF/WHPX
Pure TCG – portable, single‑binary, no privileges required; speed is 10‑30 × slower than hardware but fast enough for firmware bring‑up, CI and fuzzing.
KVM/Hypervisor.framework/WHPX – when the host supports hardware virtualisation for the same ISA, QEMU can skip TCG for most user code and let the CPU run it natively. Device emulation, soft‑MMU for MMIO, and snapshot logic remain identical, preserving the portable machine description.
Switching between these modes is often just on the command line.-accel kvm:tcg</p>
<br>
</li>
<li><p>How it differs from RTL simulation Aspect</p>
</li>
</ol>
<table>
<thead>
<tr>
<th>Aspect</th>
<th>QEMU (TCG)</th>
<th>RTL simulator (e.g., Verilator, Synopsys VCS)</th>
</tr>
</thead>
<tbody><tr>
<td><em>Granularity</em></td>
<td>Instruction / basic-block; ignores clock phases</td>
<td>Signal-accurate, delta-cycle</td>
</tr>
<tr>
<td><em>Performance</em></td>
<td>Near native when JIT cached</td>
<td>&lt;1 kHz for SoC-scale designs</td>
</tr>
<tr>
<td><em>Fidelity</em></td>
<td>Architectural state + programmer&#39;s view of devices</td>
<td>Flip-flop accurate; includes metastability, CDC</td>
</tr>
<tr>
<td><em>Use-cases</em></td>
<td>OS bring-up, driver dev, CI, fuzzing, co-simulation</td>
<td>SoC/Micro-architecture validation, timing closure</td>
</tr>
<tr>
<td><em>Build artefacts</em></td>
<td>Plain C and host assembly</td>
<td>Elaborated netlists, SDF, waveform dumps</td>
</tr>
</tbody></table>
<p>Because QEMU does not model wire‑level timing, it cannot expose hazards like hold‑time violations or DDR read levelling errors. Conversely, RTL cannot realistically boot Linux in seconds on a laptop. Many silicon teams therefore run both‑‑QEMU for software velocity, RTL for hardware sign‑off.
<br></p>
<ol start="7">
<li>Typical workflow for an Arm‑on‑x86 project</li>
</ol>
<pre><code class="language-bash"># Build
$ ../configure --target-list=aarch64-softmmu --enable-debug
$ make -j$(nproc)
# Run U‑Boot and Linux kernel under TCG
$ qemu-system-aarch64 \
    -machine virt,secure=on,gic-version=3 \
    -cpu cortex-a55 \
    -m 2G \
    -bios u-boot.elf \
    -kernel Image \
    -append &quot;earlycon console=ttyAMA0&quot; \
    -device loader,file=rootfs.cpio,addr=0x84000000
# Attach gdb to inspect MMIO registers
(gdb) target remote :1234</code></pre>
<p>Device events () will fire in the host process every time the guest kernel touches an emulated register, letting you printf‑trace firmware interactions without hardware.readfn/writefn</p>
<h3 id="virtualization">Virtualization?</h3>
<p><a href="https://www.slideshare.net/GauravSuri1/virtualization-and-hypervisors">https://www.slideshare.net/GauravSuri1/virtualization-and-hypervisors</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[How to install gitlab CLI]]></title>
            <link>https://velog.io/@sangs_o/How-to-install-gitlab-CLI</link>
            <guid>https://velog.io/@sangs_o/How-to-install-gitlab-CLI</guid>
            <pubDate>Wed, 26 Feb 2025 04:51:49 GMT</pubDate>
            <description><![CDATA[<p><code>glab</code> is an open-source CLI tool that allows you to interact with GitLab directly from your terminal.</p>
<hr>
<h2 id="why-use-glab">Why Use <code>glab</code>?</h2>
<p>Using <code>glab</code>, you can:</p>
<ul>
<li>List, view, and create <strong>Merge Requests</strong> </li>
<li>Manage <strong>Issues</strong></li>
<li>Clone repositories</li>
<li>Automate GitLab workflows</li>
<li>Merge, rebase, and approve MRs directly from the terminal</li>
</ul>
<p>This is especially useful for <strong>developers and DevOps engineers</strong> who frequently work with GitLab.</p>
<hr>
<h2 id="installation-methods-for-ubuntudebian">Installation Methods for Ubuntu/Debian</h2>
<p>There are several ways to install <code>glab</code> on Debian-based systems. Below are the most reliable methods:</p>
<h3 id="1-install-via-wakemeops-repository-recommended"><strong>1. Install via WakeMeOps Repository</strong> (Recommended)</h3>
<p>This is one of the easiest ways to install <code>glab</code> using a package manager.</p>
<pre><code class="language-sh"># Add the WakeMeOps repository
curl -sSL &quot;https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository&quot; | sudo bash

# Install glab
sudo apt install glab</code></pre>
<p>After installation, verify the version:</p>
<pre><code class="language-sh">glab --version</code></pre>
<hr>
<h3 id="2-install-via-prebuilt-mpr-repository"><strong>2. Install via Prebuilt-MPR Repository</strong></h3>
<p>If you prefer using a prebuilt <code>.deb</code> package instead of compiling from source, follow these steps:</p>
<pre><code class="language-sh"># Add the Prebuilt-MPR repository
wget -qO - &#39;https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub&#39; | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1&gt; /dev/null

echo &quot;deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)&quot; | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list

# Update package lists
sudo apt update

# Install glab
sudo apt install glab</code></pre>
<p>After installation, check the version:</p>
<pre><code class="language-sh">glab --version</code></pre>
<hr>
<h3 id="3-install-from-source-via-makedeb-advanced-users"><strong>3. Install from Source via Makedeb (Advanced Users)</strong></h3>
<p>If you want to compile <code>glab</code> from source, use <code>makedeb</code>:</p>
<pre><code class="language-sh">git clone &#39;https://mpr.makedeb.org/glab&#39;
cd glab/
makedeb -si</code></pre>
<p>This method ensures you have the latest version but requires additional dependencies.</p>
<hr>
<h2 id="how-to-use-glab">How to Use <code>glab</code></h2>
<p>Once installed, you can authenticate and start using <code>glab</code>.</p>
<h3 id="login-to-gitlab"><strong>Login to GitLab</strong></h3>
<pre><code class="language-sh">glab auth login</code></pre>
<ul>
<li>Select <code>gitlab.com</code> (or your self-hosted GitLab instance).</li>
<li>Enter your <strong>Personal Access Token</strong> (which can be generated from GitLab under Settings → Access Tokens).</li>
</ul>
<h3 id="list-open-merge-requests"><strong>List Open Merge Requests</strong></h3>
<pre><code class="language-sh">glab mr list</code></pre>
<h3 id="view-a-specific-merge-request"><strong>View a Specific Merge Request</strong></h3>
<pre><code class="language-sh">glab mr view &lt;MR-ID&gt;</code></pre>
<p>Example:</p>
<pre><code class="language-sh">glab mr view 42</code></pre>
<h3 id="merge-a-merge-request"><strong>Merge a Merge Request</strong></h3>
<pre><code class="language-sh">glab mr merge &lt;MR-ID&gt;</code></pre>
<h3 id="list-issues"><strong>List Issues</strong></h3>
<pre><code class="language-sh">glab issue list</code></pre>
<hr>
<h3 id="reference">Reference</h3>
<p><a href="https://docs.gitlab.com/editor_extensions/gitlab_cli/#install-the-cli">https://docs.gitlab.com/editor_extensions/gitlab_cli/#install-the-cli</a>
<a href="https://gitlab.com/gitlab-org/cli/#installation">https://gitlab.com/gitlab-org/cli/#installation</a>
<a href="https://gitlab.com/gitlab-org/cli/-/blob/main/docs/installation_options.md#linux">https://gitlab.com/gitlab-org/cli/-/blob/main/docs/installation_options.md#linux</a>
<a href="https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository">https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Representation of Data (1)]]></title>
            <link>https://velog.io/@sangs_o/Representation-of-Data</link>
            <guid>https://velog.io/@sangs_o/Representation-of-Data</guid>
            <pubDate>Tue, 19 Nov 2024 15:33:18 GMT</pubDate>
            <description><![CDATA[<h3 id="section-02-representation-of-data">[Section 02] representation of data</h3>
<h4 id="understanding-decimal-representation-in-computers-zoned-decimal-and-packed-decimal">Understanding Decimal Representation in Computers: Zoned Decimal and Packed Decimal</h4>
<p>The way computers store and calculate numbers is crucial, especially in environments like mainframes or embedded systems where decimal formats such as &#39;Zoned Decimal&#39; and &#39;Packed Decimal&#39; are often used. In this article, we&#39;ll explain the differences between these two formats and provide examples to help you understand their characteristics.</p>
<p>What is Zoned Decimal?</p>
<p>Zoned Decimal is a method of representing decimal numbers by converting each digit into an ASCII or EBCDIC character code. Each position combines a &#39;zone bit&#39; and a &#39;digit bit,&#39; making it easier for humans to read. For example, if we represent the number &quot;1234&quot; in Zoned Decimal, it would look like this:</p>
<p>Zoned Decimal Example (using EBCDIC code)</p>
<p>1: <code>F1</code> (in binary <code>11110001</code>)</p>
<p>2: <code>F2</code> (in binary <code>11110010</code>)</p>
<p>3: <code>F3</code> (in binary <code>11110011</code>)</p>
<p>4: <code>F4</code> (in binary <code>11110100</code>)</p>
<p>Here, <code>F</code> represents the zone bits, while <code>1</code>, <code>2</code>, <code>3</code>, and <code>4</code> are the digit bits. The zone bits are typically fixed as <code>F</code> (1111), and the digit bits represent the value of each digit. Thus, &quot;1234&quot; uses a total of 4 bytes. This type of data storage is easy for humans to interpret.</p>
<p>The key feature of Zoned Decimal is its high readability. Since each digit is clearly represented as a character, it&#39;s easy for people to understand when debugging or maintaining the data. However, this comes at the cost of memory efficiency. Since each digit takes up 1 byte, more memory is required.</p>
<p>What is Packed Decimal?</p>
<p>Packed Decimal is a method that compresses numeric data to optimize memory usage. In this format, two digits are stored in a single byte. By using Packed Decimal, you can represent the same number with fewer bytes. For instance, representing the number &quot;213&quot; in Packed Decimal would be as follows:</p>
<p>Packed Decimal Example</p>
<p><code>21</code>: Stored in the first byte (in binary <code>00100001</code>)</p>
<p><code>3</code>: Stored in the second byte, including the sign (for positive numbers, <code>00111100</code>, where the last 4 bits <code>C</code> indicate a positive value)</p>
<p>Thus, +213 is represented as <code>00100001 00111100</code> in binary. The last 4 bits <code>C</code> indicate that the number is positive.</p>
<p>Packed Decimal Example (for -213)</p>
<p><code>21</code>: Stored in the first byte (in binary <code>00100001</code>)</p>
<p><code>3</code>: Stored in the second byte, including the sign (for negative numbers, <code>00111101</code>, where the last 4 bits <code>D</code> indicate a negative value)</p>
<p>Thus, -213 is represented as <code>00100001 00111101</code> in binary. The last 4 bits <code>D</code> indicate that the number is negative.</p>
<p>The main advantage of Packed Decimal is memory efficiency. You can store the same number with fewer bytes, which is beneficial when dealing with large amounts of data. However, since the numbers are stored in a format that is harder for humans to interpret, the readability is lower.</p>
<p>Summary of Differences Between Zoned Decimal and Packed 
<img src="https://velog.velcdn.com/images/sangs_o/post/6e17ee8e-6754-4ecf-8a15-01913e97c5fe/image.png" alt=""></p>
<p>When to Use Which?</p>
<p>Zoned Decimal is useful in situations where human readability or debugging is important. The high readability makes it easy to understand the state of the numeric data.</p>
<p>Packed Decimal is preferable in environments with limited memory or when handling large amounts of numeric data. The efficient use of memory allows you to store more data.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[How to set-up Vim for C/C++ intelligence]]></title>
            <link>https://velog.io/@sangs_o/How-to-set-up-Vim-for-CC-intelligence</link>
            <guid>https://velog.io/@sangs_o/How-to-set-up-Vim-for-CC-intelligence</guid>
            <pubDate>Thu, 17 Oct 2024 16:48:34 GMT</pubDate>
            <description><![CDATA[<p>This guide will help you set up Vim as a C/C++ development environment similar to VSCode&#39;s C/C++ extension. It includes setting up key plugins like YouCompleteMe, Ctags, Cscope, and more. Additionally, we will cover common errors and their solutions.</p>
<h4 id="1-prerequisites-tools-installation">1. Prerequisites: Tools Installation</h4>
<p>Before configuring Vim, you need to install essential tools like Vim, Ctags, Cscope, and a plugin manager.</p>
<p>1.1) Install Vim
If Vim is not already installed, you can install it using your package manager. Make sure to use a version that supports plugins like YouCompleteMe (Vim 9.1+).</p>
<pre><code>sudo apt install vim # For Ubuntu</code></pre><p>1.2) Install Ctags
Ctags helps index your code symbols so that you can jump to their definitions.</p>
<pre><code>sudo apt install exuberant-ctags</code></pre><p>1.3) Install Cscope
Cscope allows for advanced code navigation, such as finding all references of a function.</p>
<pre><code>sudo apt install cscope</code></pre><p>1.4) Install a Plugin Manager (Vim-Plug)
<a href="https://github.com/junegunn/vim-plug">Vim-Plug</a> is a lightweight plugin manager for Vim.</p>
<pre><code>curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim</code></pre><h4 id="2-configure-vimrc-file">2. Configure <code>.vimrc</code> File</h4>
<p>Your <code>.vimrc</code> file is where you will configure Vim and set up all the plugins. You can open this file for editing by running:</p>
<pre><code>vim ~/.vimrc</code></pre><p>Below is an example configuration that you can add to your <code>.vimrc</code>.</p>
<pre><code>call plug#begin(&#39;~/.vim/plugged&#39;)

&quot; YouCompleteMe: Code completion
Plug &#39;ycm-core/YouCompleteMe&#39;

&quot; Gutentags: Automatically manage Ctags
Plug &#39;ludovicchabant/vim-gutentags&#39;

&quot; Cscope integration
Plug &#39;mtth/scratch.vim&#39;

&quot; NERDTree: File explorer
Plug &#39;preservim/nerdtree&#39;

&quot; FZF: Fuzzy file finder
Plug &#39;junegunn/fzf.vim&#39;

call plug#end()</code></pre><p>After adding this, save and close the file, then run the following command in Vim to install the plugins:</p>
<pre><code>vim 
:PlugInstall</code></pre><h4 id="3-plugin-configuration">3. Plugin Configuration</h4>
<p>3.1) YouCompleteMe Setup (Code Completion)
YouCompleteMe is a powerful code completion plugin. After installation, it requires compilation.</p>
<ol>
<li>Navigate to the YouCompleteMe directory:<pre><code>cd ~/.vim/plugged/YouCompleteMe</code></pre></li>
<li>Compile YouCompleteMe with support for C/C++:<pre><code>python3 install.py --clangd-completer</code></pre></li>
<li>Add this line to your <code>.vimrc</code> for enhanced functionality:<pre><code>vim
let g:ycm_auto_hover = 1 &quot; Automatically display code completion popup</code></pre></li>
</ol>
<p>3.2) Gutentags Setup (Ctags Management)
Gutentags automatically generates and updates Ctags for your project.</p>
<p>Add the following configuration to your <code>.vimrc</code>:</p>
<pre><code>let g:gutentags_project_root = [&#39;.git&#39;, &#39;.hg&#39;, &#39;.svn&#39;, &#39;Makefile&#39;]
let g:gutentags_ctags_auto_settags = 1</code></pre><p>Gutentags will automatically manage and update the <code>tags</code> file in your project directories.</p>
<p>3.3) Cscope Setup
Cscope allows you to navigate code and find function definitions, callers, text search, etc.</p>
<p>Add the following to your <code>.vimrc</code> to enable Cscope:</p>
<pre><code>if has(&quot;cscope&quot;)
    set csprg=/usr/bin/cscope
    set csto=1
    set cst
    set nocsverb
    if filereadable(&quot;cscope.out&quot;)
        cs add cscope.out
    endif
    set csverb
    nmap &lt;C-\&gt;s :cs find s &lt;C-R&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
    nmap &lt;C-\&gt;g :cs find g &lt;C-R&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
    nmap &lt;C-\&gt;c :cs find c &lt;C-R&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
    nmap &lt;C-\&gt;t :cs find t &lt;C-R&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
    nmap &lt;C-\&gt;e :cs find e &lt;C-R&gt;=expand(&quot;&lt;cword&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
    nmap &lt;C-\&gt;f :cs find f &lt;C-R&gt;=expand(&quot;&lt;cfile&gt;&quot;)&lt;CR&gt;&lt;CR&gt;
endif</code></pre><p>To generate the Cscope database (cscope.out), run the following in your project root:</p>
<pre><code>cscope -Rbq</code></pre><p>3.4) NERDTree Setup (File Explorer)
NERDTree provides a side panel for file navigation.</p>
<p>Add this to your <code>.vimrc</code>:</p>
<pre><code>vim
nmap &lt;C-n&gt; :NERDTreeToggle&lt;CR&gt;</code></pre><p>Press <C-n> (Control + n) to toggle the file explorer on and off.</p>
<p>3.5) FZF Setup (Fuzzy Finder)
FZF is a fuzzy finder that allows quick file navigation.
sangs_o.log
Add this to your <code>.vimrc</code>:</p>
<pre><code>vim
nnoremap &lt;C-p&gt; :Files&lt;CR&gt;</code></pre><p>Press <C-p> (Control + p) to open the file finder.</p>
<h4 id="4-ctags-and-cscope-usage-in-vim">4. Ctags and Cscope Usage in Vim</h4>
<p>4.1) Ctags Usage
Once Ctags is generated, you can navigate to function definitions in Vim:</p>
<p><code>Ctrl-]</code>: Jump to the definition of the symbol under the cursor.</p>
<p><code>Ctrl-t</code>: Jump back to the previous position.</p>
<p>4.2) Cscope Usage
You can use Cscope to perform several useful searches:</p>
<p><code>Ctrl-\ s</code>: Find all references of the symbol under the cursor.</p>
<p><code>Ctrl-\ g</code>: Find the definition of the symbol under the cursor.</p>
<p><code>Ctrl-\ c</code>: Find all calls to the function under the cursor.</p>
<p><code>Ctrl-\ t</code>: Find all occurrences of the text under the cursor.</p>
<h4 id="5-troubleshooting-common-issues">5. Troubleshooting Common Issues</h4>
<p><code>Error: YouCompleteMe unavailable: requires Vim 9.1.0016+</code>
This occurs when your Vim version is below 9.1. You will need to upgrade Vim to 9.1 or higher.</p>
<p>Upgrading Vim:
Remove the old Vim version:</p>
<pre><code>sudo apt remove vim vim-runtime gvim
sudo apt autoremove</code></pre><p>Install dependencies:</p>
<pre><code>sudo apt install libncurses5-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev ruby-dev lua5.1 lua5.1-dev \ libperl-dev git build-essential</code></pre><p>Clone the Vim repository and build it:</p>
<pre><code>cd ~
git clone https://github.com/vim/vim.git
cd vim
make distclean ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes \ --enable-rubyinterp=yes --enable-luainterp=yes --enable-perlinterp=yes \ --enable-cscope --prefix=/usr/local
make
sudo make install</code></pre>]]></description>
        </item>
    </channel>
</rss>