Professional Documents
Culture Documents
OF A SIMPLE COMPUTER
Dr. Kasim M. Al-Aubidy, Ra'ed F. Al-Bader, Ala'a A. Smadi
Computer Eng. Dept,
Philadelphia University,P O Box 1,
Jordan, 19392
E-mail: kma@philadelphia.edu.jo
PC
LD
The basic computer has three basic instruction code formats. AC
ALU
A memory-reference instruction uses ten bits to specify
either an address or an operand and two bits to specify the LD
addressing mode (I0,I1). For immediate addressing it is 00, OPR
01 for direct addressing, and 11 for indirect address. The LD
register-reference instructions are recognized by the OUTR
operation code 1111 and a 00 in the left most bits of the
instruction. A register-reference instruction specifies an LD
operation on the AC register. An operand from memory is CR
CLK
not needed; therefore, the other 10 bits are used to specify
the operation to be executed. Similarly, an input-output 16-bit common bus
instruction does not need a reference to memory and is
recognized by the operation code 1111 and 11 in the left
most bits of the instruction. The remaining 10 bits are used Figure 2: Basic computer registers connected to a common
to specify the type of the input-output operation. This bus.
technique allows having up to 35 different operations, as
given in Table 3.
Timing and Control: Indirect Cycle
The timing for all registers in the basic computer is At this cycle, the effective address of the operand is to be
controlled by a master clock generator. The control signals read from memory. The AR holds the address of memory
are generated by the control unit and provide control inputs word which contains the effective address of the operand.
for the multiplexer in the common bus, control inputs in
processor registers, and micro-operations for the C1 T0 : AR MAR
accumulator. The control unit, Fig. 3, consists of three C1 T1 : M(MAR) MBR
decoders, a sequence counter, and a number of control logic
C1 T2 : MBR < Address > AR
gates. The control unit gets the operation code from the OPR
C1 T3 : 0 R, 1 F, 0 G (Direct Cycle)
through a 4x16 decoder. Bits 14 & 15 of the instruction code
are transferred to two flip-flops designated by the symbols
I1 & I 0 . Bits 0 through 9 are applied to the control logic Direct Cycle
gated directly from the MBR through the common bus. The
The effective address of the operand may be read during two
outputs of the counter are decoded into 4 timing signals T0
time pulses. Therefore, to disable the delay of waiting for
through T3. The sequence counter (SC) can be incremented
T3, the sequence counter may be cleared at time T2. Thus,
or cleared. Most of the time, the counter is incremented to
the next time pulse will be T0 of the execution cycle and not
provide the sequence of timing signals out of the 2x4
T3 of the indirect cycle.
decoder. Once, the counter is cleared, causing the next active
timing signal to T0. The decoder is used to determine the
cycle to be performed. C 2 T 0 : AR MAR
C 2 T1 : M(MAR) MBR,
INSTRUCTION CYCLES C 2 T2 : 1 R, 1 F, 0 G,
0 CC (Execution Cycle)
A program residing in the memory unit of the computer
consists of a sequence of instructions. Each instruction cycle Execute cycle
is subdivided into a sequence of sub-cycles. The value of
three flip-flops is entered into a decoder to determine the
At this cycle, the fetched instruction (register-reference,
cycle to be served, as illustrated in Table 4. In this computer
memory reference, or input-output-reference) is executed.
each instruction cycle is divided into the following five sub-
The type of the instruction is decided according to the
cycles:
following table:
Table 4: Cycles Combination.
Table 5: Combinations of Instruction Types
Flip-flops
q15 I0 I1 Instruction Type
G F R Cycle
0 X X MRI
0 0 0 Fetch & Decode
1 0 0 RRI
0 0 1 Indirect
1 0 1 IOI
0 1 0 Direct
0 1 1 Execution
1 0 0 Interrupt
Interrupt Cycle
Fetch and Decode Cycle
The interrupt cycle is initiated after the execute cycle if the
interrupt flip-flop (INF) is equal to 1. The flip-flop is set to 1
Initially, the program counter is loaded with the address of manually using a switch, and it may be set during the
the first instruction in the program. The sequence counter is execution of the program by the instruction ION. The flip-
cleared to 0, providing a decoded timing signal T0. After flop is reset to 0 whenever the interrupt is served or by the
each clock pulse, sequence counter is incremented by one, so instruction IOF.
that the timing signals go through a sequence T0, T1, T2 and This basic computer serves the interrupt by saving the next
T3. The micro-operations for the fetch and decode cycle can sequential instruction in memory address 0, and then it starts
be specified by the following statements: execution from address 1 in the memory. The micro-
operations required for this instruction are:
C 0 T0 : PC MAR
C 0 T1 : M(MAR) MBR, PC + 1 PC C 4 T0 : PC MBR < Data >, 0 INF
C 0 T2 : MBR < I 0 , I1 > (I 0 , I1 ),
C 4 T1 : 0 PC, 0 MAR
MBR < OP_Code > OPR,
C 4 T2 : MBR < Data > M(MAR), PC + 1 PC
MBR < Address > AR
C 4 T3 : 0 R, 0 F, 0 G (Fetch Cycle)
I 0 C 0 T3 : 1 R, 1 F, 0 G (ExecuteCycle)
I I I 0 C 0 T3 : O R, 1 F, 0 G (DirectCycle)
I1 I 0 C 0 T3 : 1 R, 0 F, 0 G (IndirectCycle)
Table 6: Micro-operations of all instructions. Complete Computer Description
Instr. Micro-operations.
Memory Reference Instructions (MRIs) The instruction cycle flowchart is shown in Fig. 4. Figure 5
shows the schematic diagram of the basic computer. It is
NOP No micro-operation
compound of one 16-bit register, three 10-bit registers, four
ADD q 0 C 3T0 : AC + MBR < Data > AC
8-bit registers, one 4-bit register, eight D-Flip-flops, one
SUB q1C 3T0 : AC MBR < Data > AC 1024x16-bit RAM, one ALU, one 8-bit inverter, two 2-to-1
AND q 2 C3T0 : AC I MBR < Data > AC Multiplexer, one 4-to-1 Multiplexer, one 4-to-16 decoder,
OR q 3C 3T0 : AC U MBR < Data > AC one 3-to-8 decoder, one 2-to-4 decoder, and one 2-bit
sequence counter.
XOR q 4 C 3 T0 : AC MBR < Data > AC
LDA q 5C3T0 : MBR < Data > AC Start
STA q 6 C3T0 : AR MAR, AC MBR < Data > Fetch Cycle
q 6 C3T1 : MBR < Data > M(MAR) T0
PC MAR (Direct) =0 =1 (Indirect)
BUN q 7 C 3 T0 : AR PC T1
I1
M(MAR) MBR, PC + 1 PC
BSA q8 C3T0 : PC MBR < Address>, AR MAR T2 T0
T0
MBR < I 0 , I1 > (I 0 , I 1 )
q8 C3T1 : MBR < Address> M(MAR), AR MAR AR MAR
MBR < OP_Code> OPR,
T1
AR + 1 AR MBR < Address > AR M(MAR) MBR
T1
M(MAR) MBR
q8 C3T2 : AR PC =0 (Indirect T2
=1 or direct)
DSZ q9C3T0 : MBR < Data > 1 MBR < Data > Execute Cycle I0 MBR< Address> AR
SLA rB4 T0 : SHL(AC) AC, 0 AC(0) MBR < Data > M(MAR), PC + 1 PC
INC rB 5 T0 : AC + 1 AC
HALT rB6 T0 : 0 StartIndex
Figure 4: Flowchart of instruction cycle.
16-bit
LD
AR LD
LD MBR sub Immediate data/Add. Subtract operand from AC
2-to-1
MUX
LD
16-bit
10-bit INC INC 16-bit
b2 b1 b0 CR
INP OUT and Immediate data/Add. AND operand to AC
16-bit
10-bit
8-bit m or Immediate data/Add. OR operand to AC
16 Bits
xor Immediate data/Add. XOR operand to AC
8-bit a1 a0
4-bit LD 8-bit lda Immediate data/Add. Load operand to AC
Inverter sta Address Store AC content in memory
OPR 8-bit
4-to-1 MUX
prog1.asm
Assembler Instructions
FPGA IMPLEMENTATION
Simple Computer
Design Specifications
Verilog
Description
Top Level
Circuit Entry
Sub-Circuit
Entry
Preliminary Choices
of Leaf Parts
Simulation