Section 8.2
RTL for the CSC-1

Following is the complete instruction set of the CSC-1 along with the RTL (register transfer language) expressions that define what the instructions do.

LOD     load direct              A <- m[x]            Sets CNVZ bits

STD     store direct             m[x] <- A

LDI     load immediate           A <- x               Sets CNVZ bits

LDS     load indirect            A <- m[S]            Sets CNVZ bits

STS     store indirect           m[S] <- A

ADD     add                      A <- A + m[x]        Sets CNVZ bits

SUB     subtract                 A <- A - m[x]        Sets CNVZ bits

AND     and                      A <- A & m[x]        Sets CNVZ bits

OR      or                       A <- A | m[x]        Sets CNVZ bits

NOT     not                      A <- ~m[x]           Sets CNVZ bits

A2S     A to S                   S <- A

S2A     S to A                   A <- S               Sets CNVZ bits

SHL     shift left (logical)     A <- A << 1          Sets CNVZ bits

SHR     shift right (logical)    A <- A >> 1          Sets CNVZ bits

JMP     jump                     PC <- x

JZ      jump if zero             if Z=1 then PC <- x

JC      jump if carry            if C=1 then PC <- x

JV      jump if overflow         if V=1 then PC <- x

JN      jump if negative         if N=1 then PC <- x

JP      jump if positive         if N=0 then PC <- x

CAL     call subroutine          S <- PC; PC <- x

RET     return from subroutine   PC <- S

NOP     no operation             (nothing)

HLT     halt                     (stop the computer)

The symbol <- means "gets a copy of" so A <- S means that S's value is copied into A.

"x" stands for the lower 12 bits of the IR register, since the machine instruction consists of a 4-bit opcode followed by a 12-bit value. Thus, for LDI, A <- x means that the 12-bit value is directly copied into A. For LOD, A <- m[x] means that x is used as the address of a word of memory that is copied into the A register. Eight of CSC-1's instructions do not have a memory operand, so x does not appear in these instructions' RTL.

Main memory is treated as a large one-dimensional array of 16-bit values. M[x] means use the 12-bit value x from the instruction as the address of the word to either retrieve or change. In two cases, the value from the S register is used to address memory. Though S is 16 bits long, only the lower 12 are used when memory is addressed.

The C operators for Boolean bitwise AND (&), Boolean bitwise OR (|) and Boolean bitwise negation (~) are used in the RTL description, as also the two shift operations. These are strictly logical 1-bit shifts in the CSC-1, however, not arithmetic or circular.

The conditional jumps should be obvious given the if statements in the RTL. In these RTL statements, = means "equals to" rather than "gets assigned."

The CAL instruction is the only one in the CSC-1 machine language that uses a sequence of simpler RTL statements:

S <- PC; PC <- x

The semicolon separates the two primitive RTL segments in this block, sort of like C's semicolon. However, this is not the way it is really done in real circuits. Both reading the current value out of a register and inserting a new value into it can be done in one swoop due to the fact that flip-flops are used. The wires going from PC to S will have PC's current value, and the wires from the low part of IR (denoted by "x") going into PC will have PC's next value. If we strobe the LD wires on both S and PC at the same time, we will effect the desired transfer. The edge-triggered nature of flip-flops ensures that the contents of the registers only change during either the rising or falling edge, a very short period of time which occurs only once when LD is strobed.