Course: Computer Architectures
Laboratory: 0x02
Date measured: 12 October 2026
Deadline: 13 October 2026
Status: Program, experiments, report and ZIP complete; university submission not performed

Objective

Implement a single-precision neuron computation in RISC-V, measure its memory footprint and execution cost, compare forwarding settings, and evaluate independent FP latency improvements using Amdahl’s law.

The final program and every current result below use the corrected 268-instruction computation. Earlier 267- and 269-instruction versions have different sources and must not be mixed with these results.

Assignment and submission

The original assignment requires a program_1 project and completed lab_02.pdf in a ZIP named SURNAME_NAME_MATRICOLA_lab_02.zip. The user supplied a concrete filename ending in lab02.zip; the prepared archive retains that requested spelling. No upload to the university was authorized or performed.

Personalized deliverables and the unchanged assignment are stored under 40 Projects/Computer Architectures/Lab 02 Submission/, outside the study website’s published folders. See that folder’s README for the exact files and archive contents. The source and study evidence are indexed in Lab 02 - Program Sources.

Setup

Local ASE Studio project: lab_02_program_1. Existing Lab 01 projects program_1 and program_2 were preserved. The report/package source is named program_1.s inside its own program_1 folder.

SettingInitial value
Integer ALU / multiply / divide1 / 3 / 8 cycles
FP ALU / multiply / divide4 / 6 / 30 cycles
FP precisionSingle, 32 bits
Arithmetic pipeliningEnabled except FP division
Compressed instructionsOff
Out-of-order executionOn
MemoryDirect memory
Instruction / read / write memory latency1 / 1 / 1 cycles
Forwarding for Table 2Off
Forwarding for Tables 3 and 5On

The assignment’s prose says in-order, while its configuration image checks out-of-order execution. The user explicitly chose out-of-order on. This is a documented experiment choice; the recorded results do not establish an in-order result. The pipeline UI still labels fetch and issue as in-order.

The assignment’s 15 MHz is used to convert cycles to CPU time. It is not a claim about wall-clock simulation duration or an independently verified simulator clock.

Program and expected output

Inputs and weights each contain 30 copies of 1.0. Bias 0xAB is interpreted numerically as 171 and stored as .float 171.0.

The program accumulates the dot product from zero, then adds the bias. Thus x = 30 + 171 = 201. The raw biased IEEE-754 exponent of 201 is 0x86, so the normal path computes y = 1/201.

ObservationVerified value
f0 and stored x201.0
f6 and stored y0.0049751243
Bias register f7171.0
Loop counter t20
Extracted normal-path exponent134 = 0x86

Every final performance run showed the expected f0 and f6. The last forwarding-on baseline also verified both output memory writes.

Memory footprint

DataBytes
Inputs120
Weights120
b4
x4
y4
one4
Total declared data256

The assignment’s five named entries total 252 bytes; the reciprocal numerator constant one adds four. The final memory map has no extra data padding.

Final memory map: data 0x11134 through 0x11233; x at 0x11228, y at 0x1122c. Text occupies 160 bytes: 148 pipeline-visible bytes plus a protected 12-byte End block (0x10128 through 0x10133). Addresses belong to this assembled version and can change when code changes.

Counting scope

All current timing tables cover 268 executed computation instructions, excluding the protected End block (li a0,0, li a7,93, ecall). Wrong-path fetched instructions that never execute and the skipped set_zero move are excluded. The UI log’s completion message supplies no separately established full-run cycle total.

Pseudo-instructions expand before counting: each la becomes auipc plus addi; li, bnez, beqz and j use their executed machine instructions in the CSV.

Machine instructionExecuted countInitial EX cycles each
auipc61
addi981
flw621
fmul.s306
fadd.s314
bne301
beq21
fsw21
fmv.w.x14
fmv.x.w14
slli / srli / andi1 each1
fdiv.s130
jal11
Total268

CSV rows with no E stage are not executed instructions. Counting all displayed rows would also count discarded wrong-path work. The two FP moves use the configured FP ALU latency, verified from their E cells.

Table 1 Manual EX timing

The assignment defines each instruction’s CPI as its functional-unit EX latency. This produces a sum of EX work, not elapsed pipeline time.

There are 33 FP ALU operations (31 adds and two moves), 30 FP multiplications, one division and 204 remaining instructions with one EX cycle each.

Independent configurationEX cyclesTime at 15 MHz (µs)
Initial 4 / 6 / 3054636.4000
Faster MUL 4 / 2 / 3042628.4000
Faster DIV 4 / 6 / 1052635.0667

Loads and stores use one EX cycle for address calculation here; MEM stages and pipeline waits are not added. Including the three protected exit instructions under a one-EX-cycle-each convention would give 549 / 429 / 529, but these are optional estimates, not the table’s scope. OS syscall handling is outside that manual model.

Table 2 Simulator with forwarding off

Each case changes only the named latency and resets the other FP units to initial values. Out-of-order remains on. All runs execute 268 computation instructions and show the correct normal numerical results.

FP ALU / MUL / DIVMeasured cyclesCPIIPCTime at 15 MHz (µs)
4 / 6 / 307202.6865670.37222248.0000
4 / 2 / 306002.2388060.44666740.0000
4 / 6 / 107002.6119400.38285746.6667

The net measured-minus-EX difference is 174 cycles in all three runs. It combines stages, filling/draining, memory, dependencies and overlap; 174 is not a raw sum of independent stalls. Faster multiply saves 30 × (6 − 2) = 120 cycles. Faster divide saves 30 − 10 = 20 cycles.

The baseline CSV is retained. Faster-MUL and faster-DIV values were read directly from completed UI runs; those two final runs have no retained CSV snapshot. Do not describe every measurement as backed by an export.

Table 3 Forwarding enabled

Restoring 4 / 6 / 30 and enabling forwarding gives:

MetricResult
Cycles574
Instructions268
CPI2.141791
IPC0.466899
Time at 15 MHz38.2667 µs
Cycles saved versus forwarding off146
Execution-time reduction20.2778%
Speedup720/574 = 1.254355

Forwarding bypasses register writeback for available results. It does not eliminate the multiply-to-add dependency, the running-sum dependency, finite execution latency, load-use waits or pipeline resource conflicts. No exact stall-category partition was established.

Table 5 Amdahl prediction and experiment

With forwarding on, start every case independently from 4 / 6 / 30. The manual baseline is 546 summed EX cycles; the measured baseline is 574 elapsed cycles.

Here s is the unit speedup and f must describe the fraction of the same baseline cost being modeled. Manual fractions below describe EX work, not measured elapsed time.

ConfigurationManual fraction fUnit speedup sNew EX sumManual speedupMeasured cyclesMeasured speedup
FP ALU 4 → 3132/5464/35131.0643275750.998261
FP MUL 6 → 4180/5466/44861.1234575141.116732
FP DIV 30 → 1030/54635261.0380235541.036101

Configuration 1 was repeated and again took 575 cycles. The nominal 33-cycle reduction in summed EX work does not become an elapsed-time saving. In the baseline export, the initial FP move reaches M at cycle 12 and the second load reaches M at cycle 11. With FP ALU latency 3, the move reaches M at 11 and the load waits until 12; the dependent multiply starts one cycle later. Subsequent resource waits and overlap lead to the final store completing at 575 instead of 574.

This is an observed scheduling effect. Amdahl’s fixed unaffected-time assumption does not describe this whole pipeline change, so a speedup below one does not refute the law. The exports establish the stage shift, but not a complete internal simulator-cause analysis.

For multiply and divide, measured savings are 60 and 20 cycles. A fixed-remainder elapsed-time model with fractions 180/574 and 30/574 reproduces these two measurements. This agreement is specific to the observed runs; it does not justify treating overlapping EX occupancy as disjoint elapsed-time fractions in general.

Activation diagnostics and zero-branch workaround

The earlier version used:

fmv.w.x f4, zero
feq.s t4, f0, f4
bnez t4, set_zero

This is valid RISC-V code. However, with bias -30 and all products equal to one, the simulator produced x = 0 and fell through to division, giving Infinity. The behavior reproduced with forwarding on and off. An additional diagnostic preserved the comparison’s destination register and showed t4 = 1 despite the fallthrough. The exact simulator implementation cause remains unresolved.

The final source checks the magnitude bits using integer dependencies:

fmv.x.w t3, f0
slli t4, t3, 1
beqz t4, set_zero

In RV32, shifting left discards the sign bit. Both signed zeros therefore produce zero; every nonzero binary32 magnitude remains nonzero. The unshifted raw word in t3 remains available for exponent extraction.

Separate diagnosticChanged biasVerified stored xVerified stored yForwarding
Zero activation-30.000Passed off and on
Exponent 0x7F-29.010Passed on

The negative-zero bit pattern is handled by inspection of the RV32 shift logic; no separate negative-zero simulator run is claimed. Diagnostic inputs and timings are excluded from the performance tables. Normal data/settings were restored afterward.

Comparison with the other report

See Lab 02 - Comparison with Alternate Implementation for the supplied 267-instruction source, its report’s assumptions, and why its timings cannot be substituted for the final 268-instruction program.

Superseded measurements

The earlier bias-after-loop program with feq.s executed 269 instructions. It measured 730 / 610 / 710 cycles with forwarding off; forwarding on gave 582 initially and 581 / 522 / 562 for the three Table 5 changes. Normal numerical outputs were correct, but the zero diagnostic motivated the correction. These values are historical and are not current report results.

What I learned

  • Validate every activation condition separately; a correct normal result does not prove branch correctness.
  • Record source, input, settings and counting scope together with each performance result.
  • Read actual functional-unit stage counts instead of assuming all move instructions cost one EX cycle.
  • A latency reduction may expose a different resource conflict; fewer summed EX cycles do not guarantee fewer elapsed cycles.
  • Preserve original assignment material and separate diagnostic runs from required performance runs.

Completion checklist

  • Final source and normal output checked
  • Memory footprint and manual timing calculated
  • Tables 2, 3 and 5 measured using the final source
  • Both zero-output conditions checked in separate diagnostics
  • Final PDF exported and all six pages visually inspected
  • ZIP contents and integrity checked
  • Source, evidence and comparison documented
  • Upload the ZIP to the university

Sources and limits

Assignment: supplied lab_02_2026-27.docx, retained unchanged in the non-published submission folder. Results: local ASE Studio observations from 12 October 2026, five retained final pipeline CSV exports, and the final checked PDF. The peer comparison is based on a separately supplied PDF and pasted assembly, not independently repeated peer runs. Temporary browser access restrictions affected earlier work; current final experiments were subsequently completed through the supported browser UI.