Computer Architecture Lab/Winter2006/HoeftPirkWeirHuang/InstructionSetII/More

< Computer Architecture Lab < Winter2006 < HoeftPirkWeirHuang < InstructionSetII

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

Features

Block Diagram of the NORISK Processor

Instruction Set

Three Operands

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

3 Operands
Name OpCode Operands Note Decoding
ADD 0000 ddddrrrraaaa D = R + A; 00000
ADC 0001 ddddrrrraaaa D = R + A + C 00001
SUB 0010 ddddrrrraaaa D = R - A 00010
SBC 0011 ddddrrrraaaa D = R - A - c 00011
AND 0100 ddddrrrraaaa D = R and A 00100
OR 0101 ddddrrrraaaa D = R or A 00101
CMPI 0110 rrrriiiiiiii R - I => flags 10000
XOR 0111 ddddrrrraaaa D = R xor A 00110
LDB0 1000 rrrriiiiiiii R(31~8) = 0, R(7~0) = I 01000
LDB1 1001 rrrriiiiiiii R(31~16) = 0, R(15~8) = I 01001
LDB2 1010 rrrriiiiiiii R(31~24) = 0, R(23~16) = I 01010
LDB3 1011 rrrriiiiiiii R(31~24) = I 01011
RJMP 11000 iiiiiiiiiii PC = PC + I 100xx (not 10000)
RCALL 11001 iiiiiiiiiii R15 = PC; PC = PC + I 100xx (not 10000)
BRNE 11010 iiiiiiiiiii if(!zero) PC = PC + I 100xx (not 10000)
BREQ 11011 iiiiiiiiiii if(zero) PC = PC + I 100xx (not 10000)
BRCC 11100 iiiiiiiiiii if(!carry) PC = PC + I 100xx (not 10000)
BRCS 11011 iiiiiiiiiii if(carry) PC = PC + I 100xx (not 10000)

Two Operands

All 4-bit immediate values are unsigned.

2 Operands (2 instructions available)
Name OpCode Operands Note Decoding
ADDI 11110000 rrrriiii R = R + I 00000
ADCI 11110001 rrrriiii R = R + I + C 00001
SUBI 11110010 rrrriiii R = R - I 00010
SBCI 11110011 rrrriiii R = R - I - C 00011
LSL 11110100 rrrrssss R <<= S 01110
ASL 11110101 rrrrssss R >>>= S 01111
CMP 11110110 rrrraaaa R = A => zero flag 10000
11110111
ROL 11111000 rrrrssss 01100
ROR 11111001 rrrrssss 01101
ST 11111010 ddddaaaa [A] = D 100xx (not 10000)
LD 11111011 ddddaaaa D = [A] 11xxx
LSLI 11111100 rrrriiii R <<= I 01110
ASRI 11111101 rrrriiii R >>>= I 01111
MOV 11111110 ddddssss D = S 10101
11111111

One Operand

1 Operand (9 instructions available)
Name OpCode Operand Note Decoding
JMP 111111110000 rrrr PC = R
CALL 111111110001 rrrr PC => [SP], SP--, PC = R
PUSH 111111110010 rrrr R => [SP], SP--
POP 111111110011 rrrr SP++, [SP] => R
NEG 111111110100 rrrr R = -R 10101
COM 111111110101 rrrr R = not R 00111
PAR 111111110110 rrrr 1s in R
111111110111

Non Operand

0 Operand (3 instructions available)
Name OpCode Note Decoding
RET 1111111111110000 SP++, [SP] => PC
RETI 1111111111110001
CLI 1111111111110010 Interrupt flag = 0
SEI 1111111111110011 Interrupt flag = 1
SKIPCC 1111111111110100
SKIPCS 1111111111110101
SKIPNE 1111111111110110
SKIPEQ 1111111111110111
SKIPNO 1111111111111000
SKIPOV 1111111111111001
SKIPNOTNEG 1111111111111010
SKIPNEG 1111111111111011
1111111111111100
1111111111111101
1111111111111110
NOP 1111111111111111 100xx (not 10000)

Pipelining

The NORISK Processor implements three-stage pipelining:

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'"

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.

Arithmetic Operations

rXX is source and destination

Control flow

This type of conditions produce a CMP operation before the branch.

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]

Instruction Set Simulator

Call Parameters

iss prgmmem datamem [datamem_out]

During Operation

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.

Read memory

Reads first number_of_words words of program or data memory and writes file.

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.

Write whole program

Writes basename.mif to program memory and basename_data.mif to data memory. escort bayan escortbayan

This article is issued from Wikiversity - version of the Saturday, August 16, 2014. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.