This page does not represent the most current semester of this course; it is present merely as an archive.
In this homework you'll implement the rest of the Y86 instruction set.
The due date for this assignment has been postponed due to snow-canceled office hours.
You should create a file named hw4.hcl and work in that. It should contain a working lab4.hcl, either your own or our example solution.
By the end of this homework, you will have a fully functioning Y86 simulator.
Review the list of built-in signals in the README.md bundled with hcl2d. You'll use them all for this assignment:
dread and dwrite specify if the memory system is to read or write a value; addr is the address it will read or write; and wdval is th value it will write (ignored for reads).dstE is not REG_NONE then wvalE is written to the dstE register; likewise, if dstM is not REG_NONE then wvalM is written to the dstM register. You will need to use both E and M for popl.srcA is not REG_NONE then rvalA is read from the srcA register; likewise, if srcB is not REG_NONE then rvalB is read from the srcB register.StatThe Stat should be
STAT_ADR if the addr output was larger than 0xfff (this will kep the simulator from eating up too much memory).STAT_INS if the icode is not one of the ones the book discusses.STAT_HLT if the icode is halt.STAT_AOK otherwise.jXXNote that the immediate value is in bits [8, 40) not [16, 48).
Nothing to do in decode, execute, memory, or writeback; simply update the PC to the immediate value if (and only if) the conditions are met (you should already have a wire conditionsMet:1 from lab).
If jXX is correctly implemented, the following should run for 19 steps, visiting hex addresses 0, 6, c, 17, 19, 11, c, 17, 19, 11, c, 17, 19 11, c, 17, 19, 11, and 16, then halting at address 16:
irmovl $3, %eax
irmovl $-1, %ebx
a:
jmp b
c:
jge a
halt
b:
addl %ebx, %eax
jmp c
rmmovl and mrmovlMemory is accessed by setting addr to the memory address in question and either
dread to 0, dwrite to 1, and wdval to the value to write to memory, which will cause the memory system to write a 4-byte value to memory; ordread to 1 and dwrite to 0, which will cause the memory system to read a 4-byte value from memory into rvalM.You will also need to compute the memory address as rvalB + valC (the book suggests you do this in the ALU, meaning the same mux you used for OPl's adding and subtracting).
If both memory moves are implemented correctly, the following should result in edx containing 0x20000 and address 0xa2 containing byte 0x02.
mrmovl 2, %eax
rmmovl %eax, 160(%eax)
mrmovl 158(%eax), %edx
pushlDecode: read rA and %esp
Execute: add −4 to %esp
Memory: write rvalA to the address computed by that subtraction
Writeback: write the result of the subtraction back into %esp
The following code
irmovl $3, %eax
irmovl $256, %esp
pushl %eax
should leave a 0x03 in address 0xfc and an 0xfc in esp
poplDecode: read %esp
Execute: add 4 to %esp
Memory: read from the pre-added %esp address
Writeback: write both (1) the result of the addition back into %esp and (2) the results of the read into rA
The following code
irmovl $4, %esp
popl %eax
should leave a 0x08 in esp and a 0xfb00000 in eax
callcall is like pushl and jmp in general form
Decode: read %esp
Execute: add −4 to %esp
Memory: write the next instruction address (valP) to the address computed by that subtraction
Writeback: write the result of the subtraction back into %esp
PC Update: the new PC (p_pc) should be valC, not valP.
The following code
irmovl $256, %esp
call a
addl %esp, %esp
a:
halt
should leave 0xfc in esp and a 0x0b in address 0xfc
retret is like popl and jmp in general form
Decode: read %esp
Execute: add +4 to %esp
Memory: read from the pre-added %esp address
Writeback: write the result of the addition back into %esp
PC Update: the new PC (p_pc) should be the value read from memory (rvalM), not valP.
The following code
irmovl $256, %esp
irmovl a, %ebx
rmmovl %ebx, (%esp)
ret
halt
a:
irmovl $258, %eax
halt
should run 6 cycles, leave eax as 0x102, and esp as 0x104
In addition to the tests above, your code should behave the same as yis when run on anything in the y86/ folder except asuml.yo and asumi.yo (which use instructions not in the y86 basic set) and pushquestion.yo (which is ambiguous and may or may not work the same as yis; we don't care either way).
Submit a file named hw4.hcl on the submission page.