Skip to content

4. Fish: A Calculator with code memory

Fish is “programmable invertebrate”: In fish, rather than supplying control signals and clock edges by a human hand, we record all the control signals required for the desired computation in a memory chip and replace the pushbutton with a clock. After doing that, the memory chip supplies the required control signals automatically and sequentially to the processor at every clock cycle. These recorded control signals are called “machine code”.

4.1 Structure of Memory

Before going on connecting a memory chip to our processor, we have to develop a notation to explain memory operations. Software sees memory as a one dimensional array of 2^k locations, where k is the number of address bits. Hence such memory operations as

M[47] = 0xabcd

are legitimate.

4.2 “Machine Language” for Fish

Recall that each instruction of invertebrate must generate four control signals, ie,

  1. ALUOp (4 bits) ,
  2. Ra (3bits),
  3. Rb (3 bits)
  4. Rc (3 bits)

If these four control signals are concatenated together into an 13 bit entity, the result is called “a machine instruction” for fish. In each machine instruction, we have fields for ALUOp, Ra, Rb and Rc. The order of concatenation is arbitrary. We will use the order indicated in Figure below. Other orderings are also possible. But once we choose an ordering, we must stick with it, as the hardware is to be designed with this particular ordering in mind, and it will not understand any other ordering.

Each assembly language instruction has a corresponding machine language instruction and vice versa. Hence it is possible to translate between them.

In the following table, we give some assembly language instructions and their corresponding machine language translations as examples:

ASSEMBLY LANGUAGE MACHINE LANGUAGE INSTRUCTION (binary) MACHINE LANGUAGE INSTRUCTION (hex)
and 3 1 2 001 010 0010 010 0x512
or 0 3 0 000 011 0011 000 0x198
inc 5 101 ddd
dec 2
not 0 3
mov 5 7
sub 7 2 1
xor 1 1 1

In Fish, we needed a human operator to enter the commands REG1CHOOSE, REG2CHOOSE, ALUOP and REGSELECT at every clock cycle. In frog, we store these commands into a memory chip whose data bus width 13 bits. At every clock cycle

  1. A Memory chip: 

Exercise: Assume that we use a different concatenation ordering. How would the diagram change?

4.3 Programming the Fish

Contrary to Fish, Frog is programmable.

The program must be already loaded into the memory at the start of the operation. Each location in memory

How the program is loaded into memory is left unspecified.

4.4 Example programs

 

4.5 Assembler for Fish

This assembler converts Fish assembly code into Fish machine code. Fill in the missing parts. Also, ordering of the fields ALUOP, Ra, Rb and Rc is wrong. Correct it.

 

Questions

Your email address will not be published. Required fields are marked *