CSE141L Lab 3, Part 1: Designing an ISA - How To Talk To Your CPU


CSE 141L Homepage | Lab Overview | Lab Description


Deadline: May 2 at 6PM
Changes:
  1. None.

Lab Overview:

Things are getting hectic here at AwesomeCore, Inc. While we are excited that our new processor front-end is now complete, we still have a lot of work to do before we are ready to send the chips off to be fabricated. Things are a bit more complicated than that, though. As our industry analysts have told us (see
letter below), if we are going to have any hope of cracking the dominance of Lenti and AND, then we need to create a unique processor that everyone will want. We don't have a lot of time to do this either; there have been rumors at CPUaddict.com that Lenti and AND are both planning to announce new CPUs at the end of June. We'll need to have our chip ready to ship before then in order to steal their thunder and send our stocks skyrocketing!

Before we can get started on designing the backend, we need to know what kind of instructions it is going to execute. In this lab, you will be designing an ISA that will dictate what instructions your back-end execution unit needs to handle. You will need to make it general enough to execute some benchmark programs we will give you. It should also be simple enough to allow for a speedy implementation.

As we here at AwesomeCore are big proponents of the "Xtreme Hardware Design" philosophy, we will be asking you to find a partner to work with for this and all subsequent labs. Make sure you choose wisely though as you must keep the same partner for the rest of the class and if your partner drops the class, you will have to finish the project alone. You can use the WebBoard to try to find a partner if you don't meet one in class.

Lab Deliverables:

For part 1 of this lab, you will need to create a document that describes both the details of and the reasoning behind the design decisions of your ISA. While there is no demonstration for this part of the lab, part 2 will require an interview. Make sure that both you and your partner are well-versed in all aspects of your design.


Lab Description:

Jump to: Letter to the CEO | ISA Goals | ISA Requirements | I/O Instructions | Benchmark Programs | Feasibility of P&R | Useful Resources

A Letter to the AwesomeCore, Inc CEO

From: Jake Irving, CTO (UnicationITY, Inc)
To: Cob Bolwell, CEO (AwesomeCore, Inc.)

Re: New AwesomeCore Processor Design

Dear Cob,

As you might have heard, Lenti and AND are both planning on making a major announcement at the end of June. Our analysts have indicated that they are likely to be announcing powerful new CPUs that could further strengthen their grip on the processor design market. The business strategist at Orerson Consulting says that if we are to have any hope of succeeding with our next processor design, it needs to come out quickly. Futhermore, our other competitor, Moon, Inc., is too well established in the area of MIPS/SPARC design for us to be able to rely on designing our next CPU around that. We need to come up with a unique design that will create some excitment among our potential customers. By making it unique enough, we can also patent many aspects of the design so no one will be able to encroach on our slice of the market.

We are hoping that you can pull together a team that can provide us with a new instruction set architecture that looks novel enough that we will have ample material to patent. We suggest as a start that you use a 17-bit fixed instruction size and 34-bit word size; that combination may help you explore a new design space. Furthermore, Moon has access to the MIPS and SPARC patent portfolio, so try not to be too similar to them. Of course, our products still need to be competitive, so the ISA should be general purpose and reasonably efficient. Also, since the fuse is relatively short on this, you will need to keep it simple. Your compensation will be based on the correctness, novelty and efficiency of the end product. But most importantly, you must deliver a preliminary ISA by May 2 (1.5 weeks), the validated ISA by May 6 (0.5 weeks), and a final FPGA prototype by May 27 (3 weeks).

Thanks in advance,
Jake


ISA Goals:

While the ultimate goal is always correctness of our design, your ISA and your processor implementation will be judged based on the following criteria:
  1. General Purpose - Your processor should be able to execute all of the given benchmark programs as well as other general programs.
  2. Novelty - Your ISA should not be a clone of an existing ISA (such as MIPS or SPARC). While there will obviously need to be some overlap with these other ISAs, the overlap should be minimized.
  3. Performance - Programs should execute reasonably quickly on your processor.

ISA Requirements:

While you have a great deal of flexibility when it comes to designing your ISA, it must satisfy the following constraints for it to be considered a valid ISA:

Input/Output Instructions:

Your ISA should support two I/O instructions - in and out (see requirements above). These instructions allow a processor to communicate with the external world via 16 channels. All channels have a 34-bit width. The in instruction reads data from a specified channel while the out instruction writes data to a specified channel.

I/O instructions have blocking semantics. If there is no data available to read by the in instruction, the processor simply waits until there is available data. Similarly, upon an out instruction, the processor must wait until the write operation completes; it might need to wait for available buffer space. You can freely use channels for various purposes such as debugging and multicore interface.

Benchmark Programs:

The following benchmarks are provided for you to guide the development of your ISA. If your ISA is able to encode these programs, it is a good (although not perfect) indicator that your ISA is general purpose. For this lab you will need to convert each of these benchmarks to assembly code (with copious amounts of helpful comments included).

For the following benchmarks, you should assume that all data and address pointers are 34-bit.

Program Loader

// function loader:
//    load a program in the data memory into the specified address of
//    the instruction memory
// 
// src:  source address of the program in the data memory
// dest: destination address of the program in the instruction memory
// size: number of instructions to load, assume an even number
// part0(dptr *src):return 17-bit of the 34-bit data at src
// part1(dptr *src):return the remaining 17-bit of the 34-bit data at src
//
// note: this program does not need to run fast; but it does need to run. 
//       dptr means data pointer which points to a 34-bit data, 
//       while iptr means instruction pointer which points to a 17-bit instruction. 
//       Since a data is 34-bit and an instruction is 17-bit, one data location contains 
//       two instructions; part0 and part1 returns one of the two instructions, respectively.

void loader(dptr *src, iptr *dest, int size)
{
    int i
    for (i = 0; i < size; i+=2)
    {
        *dest++ = part0(src);
        *dest++ = part1(src);
        src++;
    }
    return;
}

Virtual Machine

// function virtualmachine:
//    emulates the execution of a very simple ISA
// 
// opcodes
// 0: subtract
// 1: right shift
// 2: nor
// 3: swap
// 4: in
// 5: out
// 6: conditional jump with link
// 7: halt
//
// note: int is 34 bits

struct inst {
	int op;
	int srcA;
	int srcB;
	int dest;
};

int VirtualMachine(int pc, int *mem)
{
	while(1)
	{
		struct inst *instruction = mem[pc];
		int op = instruction->op;
		int srcA = instruction->srcA;
		int srcB = instruction->srcB;
		int dest = instruction->dest;
		pc = pc + 4;
						    
		switch(op) {
			case 0: mem[dest] = mem[srcA] - mem[srcB]; break;
			case 1: mem[dest] = mem[srcA] >> 1; break;
			case 2: mem[dest] = ~(mem[srcA] | mem[srcB]); break;
			case 3: temp = mem[srcB]; mem[dest] = mem[mem[srcA]]; mem[mem[srcA]] = temp; break;
			case 4: in  mem[dest], mem[srcA]; break; // in  mem, channel #
			case 5: out mem[srcA], mem[srcB]; break; // out data, channel#
			case 6:
				mem[dest] = pc;
				if (mem[srcA] < 0) pc = mem[srcB];
				break;
			case 7: return pc;
		}
	}
}

Fibonacci Number

// Recursive Fibonacci
//  get 'n'th fibonacci number
// You should not alter the algorithm

int fib(int n)
{
	if (n < 0)
		return 0x3DEADBEEF;
	else if (n <= 2)
		return 1;
	else if (n == 29)
		return 514229;
	else if (n == 30)
		return 832030;
	else if (n == 48)
		return 4807526976;
	else if (n == 49)
		return 7778742049;
	else return fib(n-1) + fib(n-2);
}

Feasibility of Place & Route

While you are not using Xilinx for this lab, you need to plan ahead for when you start using it to implement the back-end of your processor. As you found in lab 1, some designs may not fit into a specific ISA because of resource constraints. It is therefore important that you make sure your design can fit into one of the FPGAs that the Xilinx ISE WebPack can synthesize to. We recommend that you try to target the Virtex4 XC4VLX25.

In order to get a better idea on the resource available for different devices, you can check out the Xilinx product tables. Note that a logic cell is roughly equivalent to a logic gate. In any event, you should keep your design to well under 10,000 flip flops, and under 15,000 logic gates. So, for instance, a 32-element 16-bit register file is likely to have at least 32x16 = 512 flip-flops, and probably at least one gate per flip flop to control it. The instruction and data memories will be mapped to separate block-rams which are available on the Xilinx part. These will be between 2 and 100 kilobytes, however you should not assume anything about their size. Make sure your ISA design can support an instruction and data address space of the full 34-bit range. Overly small address spaces is the #1 reason ISA's fail! Multipliers are fairly big, but the latest Xilinx parts include on-chip multipliers, which are fair game, but possibly unnecessary. Some Xilinx parts have on-board PowerPC processors; you should not assume these will be available to you.

Of course, you want your ISA to be portable to future Xilinx generations (and indeed, it is not clear which Xilinx part we will be able to run your design on at the end of the class), so we recommend against optimizing your design too much for any one Xilinx part.

Good luck!

Useful Resources


This lab created by Donghwan Jeon, 2007. Modified by Sat Garcia, 2008.