SRISC5 CPU

Comparison Instructions

R-FormatI-Format codedescription
signedunsignedsignedunsigned
cmpeq
cmpeqi
==a equals b
cmpne
cmpnei
!=a not equal to b
cmpltcmpltucmplticmpltui <a less than b
cmpgtcmpgtu cmpgticmpgtui >a greater than b
cmplecmpleu cmpleicmpleui <=a not greater than b
cmpgecmpgeucmpgeicmpgeui >=a not less than b

 pseudo-instruction

 cmplt rC, rA, rB if (signed) rA < (signed) rB then rC ← 1 else rC ← 0 cmplti rB, rA, IMM16 if (signed) rA < (signed) se(IMM16) then rB ← 1 else rB ← 0 cmpltu rC, rA, rB if (unsigned) rA < (unsigned) rB then rC ← 1 else rC ← 0 cmpltui rB, rA, IMM16 if (unsigned) rA < (unsigned) {0x0000, IMM16} then rB ← 1 else rB ← 0

Comparison Operations

controlinstcodedescription
00cmpeq ==a equals b
01cmpne !=a not equal to b
10cmplt <a less than b
11cmpge >=a not less than b

Set ALU control for either signed subtraction (001) or unsigned subtraction (011), depending on the value of control[2]. Then check the status of the result:

cmp = (control[1]? neg: zero)^control[0];

control[2]? unsigned: signed

Data Output Multiplexer (version 2)

control[4:0]operation
00xxxALU operations
010xxcompare, signed
011xxcompare, unsigned
10xxxshift
11xxxshift - immediate

control[4:3] is the data multiplexer control.

Maintained by John Loomis, last updated 24 October 2008