Assignment 1: Tangled Assembly

Instruction set design is hard. Prof. Dietz has designed dozens of instruction sets in the three decades he's been a professor, and it still isn't easy for him to get things right. Thus, rather than giving you complete freedom to design your own instruction set, we're going to walk through the design logic for a reasonably well-crafted one that has more researchy, state-of-the-art, synergyistic buzzword goodness than any he's built for CPE480 before.

Don't worry -- it's not really as scary as it sounds. However, this design is not complete -- each student must devise their own encoding of the instructions and implement their own assembler using AIK. The instruction set architecture specification for Fall 2020, missing the instruction encoding, is Tangled.

Overview Of The Instruction Set

I'm not going to repeat here all the info about this instruction set. It's described in detail at Tangled, and I think it's really important to have just one place to look for all the info about the instruction set -- and I may be updating that document throughout the semester. However, here's what's special about Tangled:

That's really the big picture. You just need to determine an appropriate instruction encoding for Tangled and implement it using AIK.

Pseudos

Most assembly pseudo-instructions for Tangled can simply use the AIK defaults. You don't need to worry about things like renaming .equate. For example, .word is used for allocating an initialized 16-bit word and .origin is used for setting the location counter in the currently active segment. Of course, don't forget to define the two segments and define the register names using .const.

However, the table of Tangled assembly language instructions given here also includes some things that look like instructions, but aren't. They're pseudo instructions that you're supposed to translate into efficient sequences of one of more instructions each. Like the MIPS li pseudo-instruction, each of these are supposed to generate the shortest possible implementation using one or more of the "real" instructions. In effect, they're span-dependent instructions, generating a variable-size encoding depending on the operand value.

In this project, you do not need to have each pseudo generate the shortest possible instruction sequence. They just need to generate code that works in the general case. What should that look like?

Keep in mind that the way AIK specifies pattern right sides doesn't look like assembly instructions, but a list of field values and sizes. To output a sequence of two instruction bit patterns, you need to list values for twice as many (32 bits total) on the right side of the pattern. The pattern that generates four words worth of instructions thus specifies values for a total of 64 bits on the right hand side.

Ok, I imagine about now you're looking at the above and wondering what a nightmare this is going to be. Get your assembler working without these pseudo-instructions first. You can still get a good grade if these aren't implemented, but not if the core instruction set doesn't work.... Also, as I indicated above, I do NOT expect you to do the span-dependent optimizations in order to get full credit.

Also keep in mind that bits don't have types -- operations on them impose typed interpretations of the bit patterns. As long as the bit pattern in the register ends up as it should be, type doesn't matter. This is particular significant in that the assembler doesn't understand float constants. However, that's OK, because you can simply enter the hexadecimal integer value that has the same bit pattern. In other words, don't worry about float constants for now....

Your Project

Your project is simply to design the instruction set encoding and implement an assembler using AIK. Here's a simple test case:

	.text
start:
	add	$1, $2
	addf	$1, $2
	and	$1, $2
	br	start
	brf	$1, start
	brt	$1, start
	copy	$1, $2
	float	$1
	int	$1
	jump	more
	jumpf	$1, start
	jumpr	$1
	jumpt	$1, start
	lex	$1, -1
	lhi	$1, 0x42
	load	$1, $2
	load	$1, 480
	mul	$1, $2
	mulf	$1, $2
	neg	$1
	negf	$1
	not	$1
	or	$1, $2
	recip	$1
	shift	$1, $2
	slt	$1, $2
	sltf	$1, $2
	store	$1, $2
	sys
	xor	$1,$2
	.data			; switch to data segment
	.word	0x42
	.text			; back to text segment
more:	and	@1, @2, @3
	ccnot	@1, @2, @3
	cnot	@1, @2
	cswap	@1, @2, @3
	had	@1, 0
	meas	$1, @1
	next	$1, @1
	not	@1
	or	@1, @2, @3
	one	@1
	swap	@1, @2
	xor	@1, @2, @3
	zero	@1

No, the above isn't a useful program. Worse still, I obviously can't show you sample output without giving-away how I've encoded the instructions.... Honestly, testing your assembler is virtually impossible; it'll be easy when you have Verilog code implementing the machine to execute these instructions, but not now. So, make sure that the logic behind your encoding is clear, either by the structure of your AIK code or by actual documentation of your reasoning in your Implementor's Notes. Make the TA's grading job easy.

Due Dates

The recommended due date for this assignment is before class, Friday, September 25, 2020. As noted in an announcement on Canvas, there was a minor typo in the Tangled instruction set write-up involving .const. Thus, this submission window will close when class begins on Friday, October 2, 2020 (extended from September 28, 2020). You may submit as many times as you wish, but only the last submission that you make before class begins on Wednesday, Friday, October 2, 2020 will be counted toward your course grade.

Note that you can ensure that you get at least half credit for this project by simply submitting a tar of an "implementor's notes" document explaining that your project doesn't work because you have not done it yet. Given that, perhaps you should start by immediately making and submitting your implementor's notes document? (I would!)

Submission Procedure

For each project, you will be submitting a tarball (i.e., a file with the name ending in .tar or .tgz) that contains all things relevant to your work on the project. Minimally, each project tarball includes the source code for the project and a semi-formal "implementors notes" document as a PDF named notes.pdf. It also may include test cases, sample output, a make file, etc., but should not include any files that are built by your Makefile (e.g., no binary executables). For this particular project, name the AIK source file tangled.aik.

Submit your tarball below. The file can be either an ordinary .tar file created using tar cvf file.tar yourprojectfiles or a compressed .tgz file file created using tar zcvf file.tgz yourprojectfiles. Be careful about using * as a shorthand in listing yourprojectfiles on the command line, because if the output tar file is listed in the expansion, the result can be an infinite file (which is not ok).

Your account is
Your password is


CPE480 Advanced Computer Architecture.