<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Performance on Bits &amp; pieces - Sven Wehrend</title><link>https://wehrend.github.io/tags/performance/</link><description>Recent content in Performance on Bits &amp; pieces - Sven Wehrend</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 02 Dec 2026 00:00:00 +0100</lastBuildDate><atom:link href="https://wehrend.github.io/tags/performance/index.xml" rel="self" type="application/rss+xml"/><item><title>Measuring Performance</title><link>https://wehrend.github.io/pages/31_performance/</link><pubDate>Wed, 02 Dec 2026 00:00:00 +0100</pubDate><guid>https://wehrend.github.io/pages/31_performance/</guid><description>&lt;div class="paragraph"&gt;&#10;&lt;link rel="stylesheet" href="https://wehrend.github.io/katex/katex.min.css" /&gt;&lt;script defer src="https://wehrend.github.io/katex/katex.min.js"&gt;&lt;/script&gt;&lt;script defer src="https://wehrend.github.io/katex/auto-render.min.js" onload="renderMathInElement(document.body, {&amp;#34;delimiters&amp;#34;:[{&amp;#34;left&amp;#34;:&amp;#34;$$&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;$$&amp;#34;,&amp;#34;display&amp;#34;:true},{&amp;#34;left&amp;#34;:&amp;#34;\\(&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;\\)&amp;#34;,&amp;#34;display&amp;#34;:false},{&amp;#34;left&amp;#34;:&amp;#34;\\[&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;\\]&amp;#34;,&amp;#34;display&amp;#34;:true},{&amp;#34;left&amp;#34;:&amp;#34;\\$&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;\\$&amp;#34;,&amp;#34;display&amp;#34;:false}]});"&gt;&lt;/script&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect1"&gt;&#10;&lt;h2 id="_measuring_performance"&gt;Measuring Performance&lt;/h2&gt;&#10;&lt;div class="sectionbody"&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;In our last part of this cpu course, part 3, we introduced the HDL Verilog and showed how to build the different components&#10;with those basic blocks. That CPU was working, but not fast. In this upcoming part 4, we will focus on performance and how to improve it.&#10;We can improve what’s measurable, so we will start with measuring the performance (of our CPU) and in general. &amp;#34;Faster&amp;#34; must become a number,&#10;not just a feeling.&#10;We will introduce the CPU performance equation and Amdahl’s law, which will help us to understand how to improve the performance of our CPU.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="admonitionblock tip"&gt;&#10;&lt;table&gt;&#10;&lt;tbody&gt;&lt;tr&gt;&#10;&lt;td class="icon"&gt;&#10;&lt;div class="title"&gt;Tip&lt;/div&gt;&#10;&lt;/td&gt;&#10;&lt;td class="content"&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;All examples of this chapter are in the folder &lt;code&gt;31_performance&lt;/code&gt; of our repository &lt;a href="https://github.com/wehrend/hdl-training"&gt;hdl-training&lt;/a&gt;:&#10;&lt;code&gt;00-instruction-mix&lt;/code&gt;.&#10;If you cloned it earlier, &lt;code&gt;git pull&lt;/code&gt; fetches the latest version.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_what_does_fast_mean"&gt;What does &amp;#34;fast&amp;#34; mean?&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;We start with two different questions:&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="ulist"&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;How long does ONE task take (latency)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;and how many tasks are finished per second (throughput).&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The best analogy here is a car vs. a bus from A to B: the car has lower latency, but the bus has higher throughput.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;For a CPU, we can think of the time an instruction needs vs. how many instructions are finished per second.&#10;Pipelining (we will discuss that in chapter 33) will improve throughput - and not latency!&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Measured in numbers: The performance of a CPU is defined as the reciprocal of the execution time.&#10;If we say &amp;#34;A is n times faster than B&amp;#34;, we mean that the execution time of B divided by the execution time of A equals n.&lt;/p&gt;&#10;&lt;/div&gt;&#10;\[\large \text{Performance} = \frac{1}{t_\text{execution}}\]&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The only honest measure of performance is the time a real program needs.&#10;Clock frequency alone says little, as we will see in the next chapters.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_the_cpu_performance_equation_or_iron_law_of_performance"&gt;The CPU performance equation (or iron law of performance)&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The central formula of this chapter is the CPU performance equation, which relates the execution time of a program to three factors: the number of instructions executed, the average number of clock cycles per instruction, and the clock period.&#10;Later on we will meet another law, Amdahl’s law, which will help us to understand how to improve the performance of our CPU. But first things fist.&lt;/p&gt;&#10;&lt;/div&gt;&#10;\[\large {t_{\text{CPU}}} = IC \cdot CPI \cdot T = IC \cdot \frac{CPI}{f}\]&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Each factor is explained in the following:&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="ulist"&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;IC: instruction count, the number of instructions executed by the program.&#10;It depends on the program itself, the compiler, and the instruction set architecture (ISA).&#10;For example, a complex instruction may take fewer instructions to accomplish a task than a simpler one.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;CPI: cycles per instruction, the average number of clock cycles each instruction takes to execute.&#10;This is influenced by the microarchitecture of the CPU. A single-cycle CPU has a CPI of 1,&#10; while a multi-cycle CPU may have a higher CPI due to multiple stages in instruction execution.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;T: clock period, the duration of one clock cycle. It is determined by the critical path of the&#10;circuit and the technology used. A shorter clock period means a higher clock frequency (f = 1/T), which can lead to faster execution times.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;div class="admonitionblock note"&gt;&#10;&lt;table&gt;&#10;&lt;tbody&gt;&lt;tr&gt;&#10;&lt;td class="icon"&gt;&#10;&lt;div class="title"&gt;Note&lt;/div&gt;&#10;&lt;/td&gt;&#10;&lt;td class="content"&gt;&#10;&lt;div class="title"&gt;The critical path&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Every gate needs a short time until its output reacts to a change at its inputs - the &lt;strong&gt;propagation delay&lt;/strong&gt;.&#10;On a path through several gates, these delays add up.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;In a clocked circuit, every path starts at a register and ends at the next register (the RTL picture from&#10;&lt;a href="https://wehrend.github.io/pages/24_sequential_verilog/"&gt;chapter 24&lt;/a&gt;). The &lt;strong&gt;critical path&lt;/strong&gt; is the slowest of all these paths.&#10;Within one clock period, three things must happen on it:&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="ulist"&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;the first register passes on its new value (&lt;strong&gt;clock-to-Q&lt;/strong&gt; time),&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;the signal runs through the combinational logic,&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;and it must arrive at the next register a little before the clock edge (&lt;strong&gt;setup time&lt;/strong&gt;).&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;\[T \geq t_\text{clk-to-Q} + t_\text{logic} + t_\text{setup}\]&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The critical path therefore determines the shortest possible clock period. In our single-cycle CPU, it is the path&#10;of &lt;code&gt;lw&lt;/code&gt;: instruction fetch, register read, ALU, data memory and write back - 800 ps&#10;(&lt;a href="https://wehrend.github.io/pages/17_cpu_control/"&gt;chapter 17&lt;/a&gt;). In &lt;a href="https://wehrend.github.io/pages/27_code_to_chip/"&gt;chapter 27&lt;/a&gt;, nextpnr found it&#10;for us on the FPGA.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;\[\cancel{\text{instructions}} \times \frac{\cancel{\text{cycles}}}{\cancel{\text{instruction}}} \times \frac{\text{seconds}}{\cancel{\text{cycle}}} = \text{seconds}\]&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The units confirm it: instructions × cycles per instruction × seconds per cycle = seconds.&#10;It is exact, not just a simple approximation:&#10;every speedup must reduce at least one of the three factors. The three factors are not independent, though.&#10;Shortening T often increases CPI, and vice versa. This trade-off runs through the whole part 4.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;This whole law is known as the &amp;#34;classic CPU performance equation&amp;#34; (Patterson/Hennessy);&#10;in some lectures also called the &amp;#34;iron law of performance&amp;#34;.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_our_single_cycle_cpu_in_numbers"&gt;Our single-cycle CPU in numbers&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The counter program, we introduced in chapter 15, is a good example to illustrate the performance equation.&#10;It consists of 3 &lt;code&gt;addi&lt;/code&gt; instructions followed by 10 iterations of a loop containing &lt;code&gt;add&lt;/code&gt;, &lt;code&gt;sw&lt;/code&gt;, and &lt;code&gt;bne&lt;/code&gt;.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Where does the program end?&#10;The counting loop ends when x1 = 10 (bne no longer jumps back).&#10;Then the CPU reaches &amp;#34;beq x0, x0, done&amp;#34; at 0x18, which jumps to itself forever: RISC-V has no halt&#10;instruction, so the program ends with an endless loop (&lt;a href="https://wehrend.github.io/pages/15_RISC_V/"&gt;chapter 15&lt;/a&gt;).&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;So the instruction count is 33. The single-cycle CPU has a CPI of 1, and the clock period is 800 ps (see table from chapter 17).&#10;That equates to a CPU time of 33 × 1 × 800 ps = 26.4 ns&#10;Here is the table from chapter 17 again, which shows the time each instruction type takes in our single-cycle CPU:&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;table class="tableblock frame-all grid-all stretch"&gt;&#10;&lt;colgroup&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2857%;"/&gt;&#10;&lt;col style="width: 14.2858%;"/&gt;&#10;&lt;/colgroup&gt;&#10;&lt;tbody&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Instruction&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Instruction memory&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Register read&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;ALU&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Data memory&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Register write&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Total&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;R-type&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;-&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;600 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;&lt;code&gt;lw&lt;/code&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;&lt;strong&gt;800 ps&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;&lt;code&gt;sw&lt;/code&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;-&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;700 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;&lt;code&gt;beq&lt;/code&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;100 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;200 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;-&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;-&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;500 ps&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The instruction mix of the counter program is as follows:&#10; addi 3 × 600 ps, add 10 × 600 ps, sw 10 × 700 ps, bne 10 × 500 ps ⇒ on average 600 ps per instruction.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Conclusion: 25 % of the time the CPU only waits. And the clock is set by &lt;code&gt;lw&lt;/code&gt; - which does not even occur in this program!&#10;So the single-cycle CPU wastes time in two ways: the slowest instruction sets the pace for all, and while one part works (e.g. the ALU), all other parts are idle.&#10;So the next question is: how can we improve this?&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect3"&gt;&#10;&lt;h4 id="_measuring_the_instruction_mix_in_simulation"&gt;Measuring the instruction mix in simulation&lt;/h4&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;We are starting with the example of the counter program, which we already know from chapter 15.&#10;The instruction mix is the share of each instruction type in the program.&#10;The program runs forever as it does not have a halt instruction,&#10;so we can only count the instructions until the program reaches the endless loop at 0x18.&#10;The expected output of the simulation is: addi 3, add 10, sw 10, bne 10, IC = 33, CPU time = 26.4 ns&#10;In simulation, we can count the instructions by type (from the opcode) and compute the CPU time with the performance equation.&#10;That is exactly how designs are evaluated before they are built in real chip development.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_amdahls_law"&gt;Amdahl’s law&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Now, as we know WHERE the time goes (instruction mix, 25 % waiting), the natural next question is:&#10; if I make one part faster, how much faster does the whole program get?&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;The formula for the total speedup of a program is given by Amdahl’s law:&lt;/p&gt;&#10;&lt;/div&gt;&#10;\[\large \text{Speedup}_{total} = \frac{1}{((1-p) + p/s)}\]&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;with p = fraction of the time that benefits, s = speedup of that part.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Example 1: 30 % of the time is spent in memory accesses, they get 2× faster ⇒ 1.18× (not 2×).&#10;Even with infinitely fast memory: at most 1 / 0.7 = 1.43×.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Example 2 with our CPU: a 2× faster ALU (200 ⇒ 100 ps) shortens the single-cycle clock from 800 to 700 ps&#10; ⇒ only 1.14×, because the ALU is only one of five steps on the critical path.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Lesson: make the common case fast. Optimize what takes the most time, not what is easiest to optimize.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_why_the_clock_frequency_alone_is_misleading"&gt;Why the clock frequency alone is misleading&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;We take a peek into the next chapters to see how the performance equation works out for the same program on different CPU designs.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="ulist"&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;single-cycle CPU: T = 800 ps (1.25 GHz), 33 cycles, CPI 1.0 ⇒ 26.4 ns&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;multi-cycle CPU: T = 200 ps (5 GHz), 122 cycles, CPI 3.7 ⇒ 24.4 ns (4× the clock, only 8 % faster!)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;pipeline CPU: T = 200 ps (5 GHz), 37 cycles, CPI 1.12 ⇒ 7.4 ns (3.6× faster)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;(multi-cycle step counts: R-type/addi 4, sw 4, branch 3 - will be derived and explained in chapter 32)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The multi-cycle CPU has a 4× higher clock frequency, but is hardly faster - CPI ate up the gain.&#10;The pipeline keeps the short clock AND gets CPI close to 1. That is the plan for part 4.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Historical note (short): the &amp;#34;megahertz myth&amp;#34; - processors were sold by clock frequency for a long time,&#10;although the frequency alone does not say how fast a program runs.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Also: MIPS (million instructions per second) as a measure is problematic - it ignores what an instruction does.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_the_ways_to_a_faster_cpu"&gt;The ways to a faster CPU&lt;/h3&gt;&#10;&lt;table class="tableblock frame-all grid-all stretch"&gt;&#10;&lt;colgroup&gt;&#10;&lt;col style="width: 33.3333%;"/&gt;&#10;&lt;col style="width: 33.3333%;"/&gt;&#10;&lt;col style="width: 33.3334%;"/&gt;&#10;&lt;/colgroup&gt;&#10;&lt;tbody&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Idea&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Factor&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;Chapter&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;shorter clock, several steps&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;T down, CPI up&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;32 multi-cycle&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;steps overlap (assembly line)&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;T down, CPI ~1&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;33 pipelining&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;resolve conflicts in the pipeline&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;CPI closer to 1&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;34 data hazards, 35 control hazards&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;execute out of order&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;CPI below the in-order limit&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;36 Tomasulo&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;execute before it is certain&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;CPI&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;37 speculation&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;faster technology / shorter critical path&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;T&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;(chapter 27: routing vs. logic)&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;better compiler, more powerful instructions&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;IC&lt;/p&gt;&lt;/td&gt;&#10;&lt;td class="tableblock halign-left valign-top"&gt;&lt;p class="tableblock"&gt;(outside this course)&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_try_it_yourself"&gt;Try it yourself&lt;/h3&gt;&#10;&lt;div class="ulist"&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;A program with lw: change the counter so that it loads the value from memory each time (lw, add, sw, bne).&#10;Compute the CPU time for single-cycle and multi-cycle (lw = 5 steps).&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;At which share of branch instructions would the multi-cycle CPU be faster than the single-cycle CPU?&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Amdahl: a program spends 80 % of its time in a loop. How much faster must the loop get for the whole program to be 2× faster? 4× faster?&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Our CPU on the iCE40 (chapter 27) runs at 30.31 MHz max: how long would the counter program take? (≈ 1.09 µs) -&#10;and why is that so much slower than the 800 ps per instruction from chapter 17? (FPGA vs. ASIC, ALU built from single cells, routing - chapter 27)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;FPGA vs. ASIC: why is the FPGA so much slower than the ASIC? (FPGA: ALU built from single cells, routing - chapter 27)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="sect2"&gt;&#10;&lt;h3 id="_summary"&gt;Summary&lt;/h3&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;In conclusion, we have learned that performance is the reciprocal of execution time, and that the CPU performance equation&#10;relates execution time to instruction count, cycles per instruction, and clock period.&#10;Amdahl’s law shows that the speedup of a program is limited by the portion that does not benefit from optimization.&#10;Our single-cycle CPU has a long clock period due to the slowest instruction, leading to wasted time.&#10;To improve performance, we can shorten the clock period, overlap instruction execution through pipelining, and optimize the most time-consuming parts of the program.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;Outlook: In the next chapters, we will explore multi-cycle and pipelined CPU designs, which will allow us to shorten the clock period and improve performance significantly.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;div class="paragraph"&gt;&#10;&lt;p&gt;(Outlined with Claude AI, written by Sven Wehrend)&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;</description></item></channel></rss>