S2.4.3 Follow an Add Through the Datapath

EasyImplement12 minIcarus Verilog · serverReview the topic

Seven instructions run on the datapath of the lesson. Follow the fields, the operands and the control signals of each.

Hardware context: The datapath of ap_rv32_sc for an arithmetic instruction: a PC, the real register file and the real ALU of ap_rv32, an operand select and a write back, with given control signals. Reading the datapath of any processor core

The program below starts at address 0, with 0 in every register. It runs on the datapath of the lesson: a PC, a register file, an operand select and an ALU. Addresses are in decimal here, so that you can enter them as they are.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
The program
The instruction slli shifts left. A shift by 2 multiplies by 4.
Address, in decimalInstruction
0addi x5, x0, 9
4addi x6, x0, 5
8add x7, x5, x6
12sub x8, x7, x6
16slli x9, x6, 2
20add x0, x7, x7
24or x10, x9, x6
28ebreak

Enter every value in decimal. A control signal is 0 or 1, as in the table of the lesson.

EntryYour decision
RS1_FIELD_AT_8Which register number is on the first read port for the instruction at address 8?
RS2_FIELD_AT_8Which register number is on the second read port for the instruction at address 8?
ALU_B_SELECT_AT_8What is alu_b_select for the instruction at address 8?
ALU_B_SELECT_AT_4What is alu_b_select for the instruction at address 4?
OPERAND_B_AT_4What value is on alu_operand_b for the instruction at address 4?
OPERAND_A_AT_16What value is on rs1_data for the instruction at address 16?
ALU_RESULT_AT_16What is alu_result for the instruction at address 16?
PC_NEXT_AT_12What is pc_next while the instruction at address 12 executes?
REG_WRITE_AT_20What is reg_write for the instruction at address 20?
X0_AFTER_20What does x0 hold after the instruction at address 20?
X8_AT_STOPWhat does x8 hold when the program stops?
X10_AT_STOPWhat does x10 hold when the program stops?
CYCLESHow many clock cycles do the seven instructions before the ebreak take on a single-cycle datapath?
X7_FOR_KThe first instruction becomes addi x5, x0, K. Give x7 when the program stops, as an expression in K.

Examples

Example 1

RS1 FIELD AT 8
Input
Which register number is on the first read port for the instruction at address 8?
Output
matches = 1

The add at 8 names x5 as rs1. That field goes straight to the first read port.

Example 2

RS2 FIELD AT 8
Input
Which register number is on the second read port for the instruction at address 8?
Output
matches = 1

The add names x6 as rs2.

Example 3

ALU B SELECT AT 8
Input
What is alu_b_select for the instruction at address 8?
Output
matches = 1

An add takes its second operand from a register: the select is 0.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For X7_FOR_K, enter a constant expression using K. Only this entry changes with the parameter. The supported integer range is 9 through 200, inclusive.

Hints

Hint 1

For each instruction, write down rs1, rs2 and rd before anything else.

Hint 2

Ask of each instruction: does its second operand come from a register or from the word itself?

Hint 3

A register changes only at the clock edge that ends the cycle of the instruction that writes it.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

14 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 3 problems on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

RS1 FIELD AT 8

Input
Which register number is on the first read port for the instruction at address 8?
Expected output
matches = 1

The add at 8 names x5 as rs1. That field goes straight to the first read port.

Run samples executes all 3 public checks. Check all tests runs 14 checks on the server.

Icarus Verilog · server