Computer Architecture Lab/Winter2006/HoeftPirkWeirHuang/InstructionSetII/More

VHDL-Source for NORISK-Chip (hardware-programmer, CPU)

Features

 * 32-bit Harvard processor architecture
 * Dual-ported Instruction Memory
 * Word addresses
 * Memory Mapped IO
 * On Chip-Memory programmer
 * 16 general purpose registers
 * 16-bit instructions
 * Instruction preprocessing
 * 3-stage piplining
 * 1 cycle relative conditional branches
 * 1 cycle absolute jumps

Three Operands
The 8-bit immediate values are unsigned, 11-bit branch values are signed.

Two Operands
All 4-bit immediate values are unsigned.

Pipelining
The NORISK Processor implements three-stage pipelining:
 * Instruction fetching and simple branch logic
 * Decoding
 * Execution and Memory Access

Macro Assembler
The macro assembler was written using flex and yacc. The goal was to produce an intuitive assembler. It allows C-style usage of assembly operations.

C/C++, Flex, Yacc-Sources for assembler and instruction set simulator. Assembler-Sources for example assembly programs.

Data memory initialization
word identifier[size] word identifier[]=word1,word2,word3,... word identifier[size]=word1,word2,word3,... word identifier[]="string" word identifier[size]="string"
 * Zero initialized 32bit words:
 * User initialized 32bit words: (size determined by assembler)
 * User initialized 32bit words: (size determined by programmer)
 * String:
 * String: (size determined by programmer)

Data transfer
rXX = rYY rXX = rYY[disp] rXX[disp] = rYY Displacement values above zero are not possible with the current NORISK instruction-set. rXX = immediate Immediate values can be numeric (0x for hexadecimal), labels or storage variables.
 * Register-Register:
 * Register-Memory and Memory-Register
 * Register-Immediate

Arithmetic Operations
rXX is source and destination
 * Possible operations are &,|,^,<<,>>, R> (rotate right), >A> (arithmetic shift right)
 * Syntax 1: rXX = rYY op rZZ
 * Syntax 2: rXX op=rZZ
 * For some operations (depending on the instruction set) immediate values instead of rZZ are possible.

Control flow
This type of conditions produce a CMP operation before the branch.
 * Labels: identifier followed by :
 * Branch: goto label
 * Conditional branch: goto label if condition
 * Flag conditions: carry, !carry, zero, !zero
 * Compare conditions: rXX {< or <= or > or >= or == or !=} {rYY or immediate}
 * Relative call: rcall label. Saves next PC in register 15 and performs a relative jump.
 * Return: return

Example program: bubble-sort
word test[]={20,20,21,19,15,1,10,12,6,7,3,100, 99,98,97}

r5 = sizeof(test) r5 = r5+r0 ; calculate end

outer_loop: r1 = test ; memory address of 1st operand r2 = test ; memory address of 2nd operand r2 += 1 r6 = 0 ; flag if sort is completed

inner_loop: r3 = r1[0] ; load operands r4 = r2[0]

goto next if r3 <= r4 ; decide whether it is necessary to swap them r2[0] = r3 ; swap elements r1[0] = r4 r6 += 1   ; set not-done flag

next: r1 += 1 r2 += 1 ; next index goto inner_loop if r2 < r5 ; repeat if end not reached goto outer_loop if r6 != 0 ; repeat if sort not finished

r0 = 0x80000000 ; IO-address for leds r1 = 0xF r0[0] = r1 ; illuminate four leds

infinite: goto infinite ; loop forever

Call Parameters
ass prgm_file bin_out [bin_data_out]
 * prgm_file is the source code file
 * bin_out is the binary code output
 * bin_data_out is the binary data output. If this parameter is omitted, a default value (based on the bin_out parameter) is used.

Call Parameters
iss prgmmem datamem [datamem_out]
 * prgmmem is the filename of assembly program code output
 * datamem is the filename of assembly data output
 * datamem_out is optional. If specified the contents of the data memory after quit are written to that file.

During Operation

 * Enter executes next instruction
 * Sometimes IO input is requested (prompt: [IO@ address]:) the value specified is returned for this load operation. 0x for hexadecimal is allowed.
 * q stops execution and writes data file

On chip-memory programmer
Visual C++ Source for Programmer using a serial com port.

Console operation
Sends input from keys to the serial interface and displays received data.
 * programmer com_port_number con

Read memory
Reads first number_of_words words of program or data memory and writes file.
 * programmer com_port_number read {prgm|data} file number_of_words

Write specific memory
Writes a maximum of max_number_of_words words of program or data memory from file. If max_number_of_words is omitted it writes the whole file.
 * programmer com_port_number write {prgm|data} file [max_number_of_words]

Write whole program
Writes basename.mif to program memory and basename_data.mif to data memory.
 * programmer com_port_number writeall basename