Your task

  1. Submit your solutions to Problem Set-1 as a scanned PDF document on Gradescope. Problem Set-1 may be found in Collab under the resources folder. Alternatively, you may also get a physical copy of the assignment from me during lecture or office hours (Tu/Th 12:30pm at Rice 312).

  2. Start from the single-cycle processor you implemented in the previous lab. Alternately, we will supply a seqlab solution (in Collab under the resources folder; after the lab is due) in case you did not finish all of the lab. Make a copy of this file called seqhw.hcl.

  3. Implement all the remaining Y86 instructions in seqhw.hcl:
    • jXX (conditional jumps)
    • mrmovq
  4. Test your code with make test-seqhw.

  5. Submit to kytos.

Advice/Hints

Stat

The Stat should be

Implementing jXX

To add conditional support to JXX, you should update the PC to the immediate value (valC) only if the conditions are met. You should already have something like wire conditionsMet:1 from implementing cmovXX in lab.

Testing jXX

If jXX is correctly implemented, the following (which is found in y86/jxx.yo) should run for 19 steps, visiting hex addresses 0, a, 14, 27, 29, 1d, 14, 27, 29, 1d, 14, 27, 29 1d, 14, 27, 29, 1d, and 26, then halting at address 26:

      	irmovq $3, %rax
	irmovq $-1, %rbx
a:
	jmp b
c:
	jge a
	halt
b:
	addq %rbx, %rax
	jmp c

    

You can test this by running the output of the simulator through the grep tool to select out just a subset of lines:

      linux> ./hclrs seqhw.hcl y86/jxx.yo | grep 'pc ='
pc = 0x0; loaded [30 f0 03 00 00 00 00 00 00 00 : irmovq $0x3, %rax]
pc = 0xa; loaded [30 f3 ff ff ff ff ff ff ff ff : irmovq $0xffffffffffff, %rbx]
pc = 0x14; loaded [70 27 00 00 00 00 00 00 00 : jmp 0x27]
pc = 0x27; loaded [60 30 : addq %rbx, %rax]
pc = 0x29; loaded [70 1d 00 00 00 00 00 00 00 : jmp 0x1d]
pc = 0x1d; loaded [75 14 00 00 00 00 00 00 00 : jge 0x14]
pc = 0x14; loaded [70 27 00 00 00 00 00 00 00 : jmp 0x27]
pc = 0x27; loaded [60 30 : addq %rbx, %rax]
pc = 0x29; loaded [70 1d 00 00 00 00 00 00 00 : jmp 0x1d]
pc = 0x1d; loaded [75 14 00 00 00 00 00 00 00 : jge 0x14]
pc = 0x14; loaded [70 27 00 00 00 00 00 00 00 : jmp 0x27]
pc = 0x27; loaded [60 30 : addq %rbx, %rax]
pc = 0x29; loaded [70 1d 00 00 00 00 00 00 00 : jmp 0x1d]
pc = 0x1d; loaded [75 14 00 00 00 00 00 00 00 : jge 0x14]
pc = 0x14; loaded [70 27 00 00 00 00 00 00 00 : jmp 0x27]
pc = 0x27; loaded [60 30 : addq %rbx, %rax]
pc = 0x29; loaded [70 1d 00 00 00 00 00 00 00 : jmp 0x1d]
pc = 0x1d; loaded [75 14 00 00 00 00 00 00 00 : jge 0x14]
pc = 0x26; loaded [00 : halt]

    

Implementing mrmovq

  1. Memory is accessed by setting mem_addr to the memory address in question and either
    • setting mem_readbit to 0, mem_writebit to 1, and mem_input to the value to write to memory, which will cause the memory system to write a 4-byte value to memory; or
    • setting mem_readbit to 1 and mem_writebit to 0, which will cause the memory system to read a 4-byte value from memory into mem_output.
  2. You will also need to compute the memory address as reg_outputB + valC (the book suggests you do this in the ALU, meaning the same mux you used for OPq’s adding and subtracting). This is the same calculation used for rmmovq.

Testing mrmovq

If both memory moves are implemented correctly, the following (y86/rrmr.yo) should result in %rdx containing 0x20000 and address 0xa2 containing byte 0x02.

      mrmovq 2(%rax), %rax
rmmovq %rax, 160(%rax)
mrmovq 158(%rax), %rdx

    

The first instruction relies on %rax initially being 0.

General Testing

You can run the command make test-seqhw to test your processor over almost all the .yo files in the y86/ folder, comparing the output to supplied outputs in testdata/seq-reference and testdata/seq-traces. If your processor disagrees, you may find the traces in testdata/seq-traces helpful for debugging.

In addition, your code should behave the same as tools/yis when run on anything in the y86/ folder except