Title: November 8th 10th 2006
1COE 328 Digital Systems and MicroprocessorsLab
7 Final ProjectProgrammable Processor Module
(PPM)
- Raymond Phan
- ENG 460
- http//www.ee.ryerson.ca/rphan
2Outline of Lecture
- Objectives
- Introduction
- Levels of abstraction
- Basic Computer Architecture
- Overview of Customized Ryerson Microprocessor
(CRM) - Datapath Unit on CRM
- Architecture
- Control Signals
3Outline of Lecture (2)
- Instruction set on CRM
- Details on each instruction available
- Control Unit on CRM
- Architecture
- Control Signals
- Procedure for Final Project
- Preparing EPROM Files
- Microinstructions ? EPROM Format
- Microinstruction Tables and Examples
- Format for code and addressing
- Conversion of EPROMs ? .asc to .hex
4Outline of Lecture (3)
- What youre required to do
- Whats due for marks
- Format of Formal Lab Report
- End thank goodness right?
5Objectives
- Get familiar with the basic elements that make up
a microprocessor - Working with a microprocessor that Ryerson Profs
designed many years ago - Derive the behaviour of the instruction set for a
microprocessor (more on this later)
6Objectives (2)
- Understand programs at the microprocessor level
- You get to code your very own custom program at
this level! - Things you need to know before we start
- Absolutely NO VHDL seen in this lab (yay?)
- No more work on the CPLDs for this lab (bigger
yay?) - Electrical guys ? No more VHDL for the rest of
your life (YAY!) unless you want to get into
digital design
7Objectives (3)
- Also dont be scared! You might be scared of
this project for the following reasons - First time youll be programming at a lower level
(lower than C or Java) - First time youll see the things that make up any
microprocessor that exists today - You will be required to understand how exactly a
microprocessor works.
8Outline of Lecture
- Objectives
- Introduction
- Levels of abstraction
- Basic Computer Architecture
- Overview of Customized Ryerson Microprocessor
(CRM) - Datapath Unit on CRM
- Architecture
- Control Signals
9Introduction Levels of Abstraction
- Microprocessor on your computer is responsible
for the execution of your program. - For any high-level language, when want to create
an executable program, you use a compiler. - Compiler ? Turns your high-level language
statements into a format that the microprocessor
can understand
10Introduction Levels of Abstraction (2)
- Heres a nice drawing I made!
- Very simple example ? A B C at the high
level - On the microprocessor end, it does this addition
by a form of instructions
11Introduction Levels of Abstraction (3)
- Example of the use of instructions
- Cooking! Lets say you wanted to make scrambled
eggs how would you do it? -
- Crack eggs open and put them into bowl
- Whip and beat them using a fork
- Throw them on a pan and fry them
12Introduction Levels of Abstraction (4)
- This is EXACTLY the same as what the
microprocessor is trying to accomplish on its end - Take a high level language piece of code and
you break it down into instructions - Processor carries out lines of code as a sequence
of instructions
13Introduction Levels of Abstraction (5)
- Lets look at the figure again
- You want to add the variables B and C and store
them into the variable A - You could do this by registers and memory
- All microprocessors that exist today have
registers - Registers ? Quick access memory storage elements
for computation
14Introduction Levels of Abstraction (6)
- So, look at the diagram again
- Procedure on how to do A B C
- Load a register with the value stored in memory
location B - Add the value of stored in memory location C to
this register - Store this new value to memory location A
15Introduction Levels of Abstraction (7)
- But! The microprocessor can ONLY understand 0s
and 1s! Look at the diagram again - Once you compile, your program is turned into a
series of instructions - The assembler must now take these instructions
and turn them into machine code (0s and 1s)
16Introduction Levels of Abstraction (8)
- Look at the diagram again below
- Look at the instructions. You can see that there
are two things associated to it The
instruction, and the parameter for the
instruction - LDR B ? Use the load register command and load it
with the contents of memory location B
17Introduction Levels of Abstraction (9)
- An instruction requires two pieces of information
in order to execute - Opcode The actual instruction itself (LDR, STR)
- Operand The parameter to this instruction (A,
B, C) - This is pretty much like a function in C or Java
? int number gimmeSome(value)
18Introduction Levels of Abstraction (10)
- You could have instructions that have no operands
at all, just the opcode. - C or Java equivalent spaceCadet()
- Now back to the figure
- Look at the machine code part of the diagram
- Takes the OpCode and Operand and turns them into
0s and 1s - Now, the microprocessor is ready to run the
program
19Introduction Levels of Abstraction (11)
- Let me mess up your minds a bit
- Instructions like load, store, add, etc these
also need to perform instructions to perform the
instructions! These are called
micro-instructions - Heres your time to go huh?????
- Back to cooking example
- Scrambled Eggs Youre performing
micro-instructions without even knowing it!
20Introduction Levels of Abstraction (12)
- First step ? Crack eggs and put them into a bowl.
You need to do small things (microinstructions)
in order to perform this step. What are they? - Get eggs out of fridge
- Get bowl out of cupboard
- Place both on the table
- Hit eggs against surface
- Crack open and place eggs into bowl
21Introduction Levels of Abstraction (13)
- Second step ? Whip and beat the eggs with a fork.
Whatre the microinstructions? - Get the fork out of the cupboard
- Grab a hold of the bowl
- Use the fork and whip the eggs
- Third step ? Dump eggs into frying pan
- Lift and hold the bowl
- Turn it upside down and dump onto the frying pan
22Introduction Levels of Abstraction (14)
- So, what youre doing when youre cooking
scrambled eggs is that youre following
instructions, but performing micro-instructions - Lets throw this all together
- High Level Language ? Open up a menu, tell the
waiter you want scrambled eggs - Assembly Language ? Chef makes scrambled eggs for
you following instructions, performing
micro-instructions - Machine Code ? 00101 001011, 11010 100111, 11011
100011, etc. etc.
23Outline of Lecture
- Objectives
- Introduction
- Levels of abstraction
- Basic Computer Architecture
- Overview of Customized Ryerson Microprocessor
(CRM) - Datapath Unit on CRM
- Architecture
- Control Signals
24Introduction Basic Computer Architecture
- The microprocessors in your computer, iPod, Cell
Phone, PlayStationetc. have 2 very important
elements that make it up - Datapath Unit
- Handles manipulation and the movement of data in
the microprocessor - Responsible for all mathematical and logical
operations performed on variables - Has memory storage elements such as cache,
registers, Static RAM
25Introduction Basic Computer Architecture (2)
- Control Unit
- How exactly do you tell the datapath unit that
you want to perform an add, store, load? - Control Unit provides the proper signals that are
fed to the datapath unit so it can perform the
required operation - Example Remote Control and TV
- Remote Control ? Control Unit
- TV performing the desired operation ? Done by
Datapath Unit - So! Control Unit tells the datapath on what it
should do and the Datapath Unit does the actual
grunt work itself
26Outline of Lecture
- Objectives
- Introduction
- Levels of abstraction
- Basic Computer Architecture
- Overview of Customized Ryerson Microprocessor
(CRM) - Datapath Unit on CRM
- Architecture
- Control Signals
27Overview of the CRM - Introduction
- Back in 1995 or so before
- I knew what the hell a computer was
- You all knew what the hell a computer was
- I was still sleeping at night with a night
light. Oops. - Ryerson profs developed a customized
Microprocessor for this course so you guys know - How a microprocessor works
- The basic architecture of a microprocessor
- How to program programs at the microprocessor
level - To make your lives miserable because they
probably werent married and want to take it out
on you guys
28Overview of the CRM Introduction (2)
- They created and implemented their circuit
designs for their customized microprocessor - CRM is physically implemented
- Circuit is printed on a PCB (Printed Circuit
Board) and is now ready for use - Lets look at the datapath unit (dont piss your
pants the circuit might look ugly)
29Overview of the CRM Datapath Unit Architecture
- Heres what it looks like!
- Remember, Datapath does the grunt work
- What do you see here?
- Register (ACCA)
- ALU
- SRAM
30Overview of the CRM Datapath Unit
Architecture (2)
- Big Vertical Solid Line ? Data Bus
- Mechanism used to transfer data between entities
- 4 bits wide
- Only 2 things can be connected to the data bus at
one time - Transmitter
- Receiver
- If you dont follow this youll get a data
clashing!
31Overview of the CRM Datapath Unit
Architecture (3)
- Register (Accumulator)?
- Call this accumulator because you have the
ability to change the contents based on
arithmetic or logical operations - Basically stores numbers after computation
- Very special kind of register, a shift register.
- Can use to load in a number, and you can also
shift bits around, either to the left or the right
32Overview of the CRM Datapath Unit
Architecture (4)
- Arithmetic / Logic Unit?
- Used to do all arithmetic and logical operations
on the microprocessor - Takes in 2 inputs, does logical or arithmetic
operations on them and stores them into the
accumulator - Output of the ALU is sent to the accumulator /
shift register
33Overview of the CRM Datapath Unit
Architecture (5)
- Tri-State Bus Driver?
- Acts basically like a switch
- Enables and Disables Output that its connected
to - 4 bits wide
34Overview of the CRM Datapath Unit
Architecture (6)
- Input Switches?
- Can load numbers provided by you as well instead
of just memory! - Switches take in an input number from the user
and goes to the ALU for computation purposes - Connected to tri-state buffer to ensure no data
clashing with other entities
35Overview of the CRM Datapath Unit
Architecture (7)
- Static RAM?
- Used to store numbers from the switches or the
accumulator - Used to retrieve stored numbers for use in
computing values - Output of RAM also serves as input to the ALU
(note the Chip Select used for no data clashing) - 16 memory locations available for this Static RAM
chip
36Overview of the CRM Datapath Unit Control
Signals
- Tri-State Bus Driver Control Signal Inputs?
- For the outputs of the accumulator and getting
data from the switches, there is a control switch
used to enable or disable the outputs - /AS Accumulator Select
- SM Switches or Memory
- /AS enables or disables the output of the
accumulator - SM disables or enables the switches
37Overview of the CRM Datapath Unit Control
Signals (2)
- Static RAM Control Signal Inputs ?
- SM is used to disable and enable the RAM chip
- This signal is shared between the RAM and the
Switches - Note the active low / active high inversion on
the switches and the RAM - /WE enables writing to a memory location or
reading from a memory location on the chip - N3-0 selects the particular address in memory you
want to access or write to.
38Overview of the CRM Datapath Unit Control
Signals (3)
- Accumulator Control Signal Inputs ?
- Note the Q3 and Q0, the MSB and LSB of the ACCA
output! - C is for a carry-in into the register.
- Since youre performing arithmetic operations,
you need a Carry-In, just like Lab 3 - CLK ? Very important signal. Youll see next
- S1 and S0 control the way the contents of the
accumulator are manipulated - S1 0, S0 0 ? Do not change the contents of
the accumulator - S1 0, S0 1 ? Shift bits to the right at each
clock cycle - S1 1, S0 0 ? Shift bits to the left at each
clock cycle - S1 1, S0 1 ? Do a direct loading from D3-0
39Overview of the CRM Datapath Unit Control
Signals (4)
- ALU Control Signal Inputs
- A and B are inputs into the ALU. You perform
Arithmetic and Logic Operations on these two
inputs - S3-0 are used to select the particular operation
you want to perform on A and B - /CALU Carry in into ALU (Same as Lab 3)
- M selects whether you want to perform Arithmetic
(M 0) or Logic (M 1) - /Co Carry out from ALU
- AEB - Flag goes high when B A 0
40Outline of Lecture
- Objectives
- Introduction
- Levels of abstraction
- Basic Computer Architecture
- Overview of Customized Ryerson Microprocessor
(CRM) - Datapath Unit on CRM
- Architecture
- Control Signals
41Outline of Lecture (2)
- Instruction set on CRM
- Details on each instruction available
- Control Unit on CRM
- Architecture
- Control Signals
- Procedure for Final Project
- Preparing EPROM Files
- Microinstructions ? EPROM Format
- Microinstruction Tables and Examples
- Format for code and addressing
- Conversion of EPROMs ? .asc to .hex
42Overview of the CRM Instruction Set
- Instruction Set The set of all instructions
that you can perform on a microprocessor - The list of available instructions on the CRM is
listed on page 5 of the lab7.pdf - Each instruction in the CRM needs
- Opcode Actual instruction to perform
- (Optional) Operand Parameter to the instruction
43Overview of the CRM Instruction Set (2)
- ADDA N Adds the accumulator with contents of
memory location N and stores into accumulator
(with the input carry to the accumulator) - OpCode 0000
- Operand N3N2N1N0 ? 4 bit address in memory you
want to access - SUBA N Subtracts the accumulator with contents
of memory location N and stores into accumulator
(with the borrow bit to the accumulator) - OpCode 0001
- Operand N3N2N1N0 ? 4 bit address in memory you
want to access
44Overview of the CRM Instruction Set (3)
- INPA N Takes a 4-bit binary number from the
switches and puts this to the accumulator - OpCode 0010
- Operand None (Dont Cares ? N3N2N1N0 xxxx)
- LDAA N Loads the accumulator with contents of
memory location N - OpCode 0011
- Operand N3N2N1N0 ? 4 bit address in memory you
want to access
45Overview of the CRM Instruction Set (4)
- STAA N Store the contents of the accumulator
and store it into memory location N. - OpCode 0100
- Operand N3N2N1N0 ? 4 bit address in memory you
want to access - JMP N Jump to instruction number (address) N in
your program - OpCode 0101
- Operand N3N2N1N0 ? 4 bit address in your program
that you want to jump to - Note, to implement a program using this
instruction, you can only have maximum 16 lines
of code!
46Overview of the CRM Instruction Set (5)
- Something you need to know ? We could have two
instructions with the same OpCode, but have the
Operand be used to distinguish instructions from
one another! (Dont cares are 1 (x 1)) - ADDA S Adds the accumulator with the input
number seen at the switches and stores into
accumulator (with the input carry to the
accumulator) - OpCode 0110
- Operand N3N2N1N0 ? xxx0 ? N0 0 to perform
addition - SUBA S Subtracts the accumulator with the input
number seen at the switches and stores into
accumulator (with the borrow bit to the
accumulator) - OpCode 0110
- Operand N3N2N1N0 ? xxx1 ? N0 1 to perform
subtraction
47Overview of the CRM Instruction Set (6)
- ANDA N Performs the logical AND operation with
the accumulator and whatever contents are in
memory location N and stores the result in the
accumulator - OpCode 0111
- Operand N3N2N1N0 ? 4 bit address in memory you
want to access - CLC Clears the input carry bit in the
accumulator - OpCode 1000
- Operand N3N2N1N0 ? xxx0 ? N0 0 to perform
clear
48Overview of the CRM Instruction Set (7)
- SEC Sets the input carry bit in the accumulator
- OpCode 1000
- Operand N3N2N1N0 ? xxx1 ? N0 1 to perform set
- DECA Decrement the accumulator (ACCA ACCA
1) - OpCode 1001
- Operand N3N2N1N0 ? xxx0 ? N0 0 to perform
decrement
49Overview of the CRM Instruction Set (8)
- INCA Increment the accumulator (ACCA ACCA
1) - OpCode 1001
- Operand N3N2N1N0 ? xxx1 ? N0 1 to perform
increment - RORA Rotate the Accumulator 1 bit to the right
(MSB of accumulator C and LSB of accumulator
C) - OpCode 1010
- Operand N3N2N1N0 ? xxx0 ? N0 0 to perform
right rotate
50Overview of the CRM Instruction Set (9)
- ROLA Rotate the Accumulator 1 bit to the left
(LSB of accumulator C and C MSB of
accumulator) - OpCode 1010
- Operand N3N2N1N0 ? xxx1 ? N0 1 to perform left
rotate - STSW N ? Take a number from the input switches
and store it into memory location N - This combines two operations INPA and STAA N
- OpCode 1011
- Operand
- 1st step ? Operand xxxx ? Number to place into
accumulator comes from switches - 2nd step ? N3N2N1N0 ? Memory location to store
input switch value to
51Overview of the CRM Instruction Set (10)
- Jump Instructions ? When you write an assembly
program, youre able to jump to any instruction
in your program - Doesnt have to follow the exact sequence line by
line - JCS N Jump to instruction number N when the
carry bit is set - OpCode 1100
- Operand N3N2N1N0 ? Address (instruction number)
to jump to if carry is set - JEQ N Jump to instruction number N when the
accumulator (A) equals the switches (B) - OpCode 1101
- Operand N3N2N1N0 ? Address (instruction number)
to jump to A B
52Overview of the CRM Instruction Set (11)
- JMI N Jump to instruction number N when the
number is negative (MSB of accumulator 1) - OpCode 1110
- Operand N3N2N1N0 ? Address (instruction number)
to jump to MSB of accumulator 1 - CLRA Clear the contents of the accumulator
- OpCode 1111
- Operand N3N2N1N0 ? xxx0 ? N0 0 to perform
clear - SETA Set all accumulator bits to 1
- OpCode 1111
- Operand N3N2N1N0 ? xxx1 ? N0 1 to perform set
53Outline of Lecture (2)
- Instruction set on CRM
- Details on each instruction available
- Control Unit on CRM
- Architecture
- Control Signals
- Procedure for Final Project
- Preparing EPROM Files
- Microinstructions ? EPROM Format
- Microinstruction Tables and Examples
- Format for code and addressing
- Conversion of EPROMs ? .asc to .hex
54Overview of the CRM Prequel - EPROM
- So, what the hells an EPROM?
- EPROM ? Electronically Programmable Read Only
Memory - Similar to RAM ? Write stuff to memory locations
- Can also access values that you wrote to this
chip by an address
55Overview of the CRM Prequel EPROM (2)
- However, once you write, you cannot overwrite
like you do for PALs! - When you write stuff to it and you make a
mistake, you must erase all of the contents all
at once! - Silver square in the middle is susceptible to UV
light. - You must place the EPROM under a UV light eraser
for about 10 15 minutes to clear the contents
56Overview of the CRM Control Unit Architecture
- Heres what it looks like! If you didnt piss
your pants, nows the time - Remember, Control Unit tells the Datapath on how
it should perform instructions - What do you see here?
- EPROMs
- PALs
- Program Counter
- Register
57Overview of the CRM Control Unit Architecture
(2)
- Program Counter ? Keeps track of the next
instruction number you will be running in your
code - The SW7 switch (CLR), resets your Program Counter
to 0 so that you start at the beginning of your
program
58Overview of the CRM Control Unit Architecture
(3)
- EPROMs 1 and 2 ? For a particular instruction you
want to perform, these store the microinstruction
signals required to perform the instruction you
want. - How this works
- Opcode serves as input to EPROM (there are more
inputs, but well look at those later) - Microinstruction sequence number also serves as
input (need to know which microinstruction you
want to execute) - These are used to find the memory location of the
proper control signals needed - Output is the actual control signals themselves
59Overview of the CRM Control Unit Architecture
(4)
- Microinstruction Next State Register
- This keeps track of the next microinstruction you
need to perform for a given instruction - Remember, an instruction requires
microinstructions in order to execute properly - Once you complete a microinstruction, this tells
you what microinstruction you need to perform
next - Fed back to EPROMs 1 and 2 to figure out next
microinstruction
60Overview of the CRM Control Unit Architecture
(5)
- EPROM 3 Stores programs in assembly format for
the microprocessor to execute - 2 ways to create programs
- C or Java way
- Assembly way (This is the way were going to make
programs) - EPROM 3 stores the instructions for up to 4
programs in this EPROM - Each program must be max 16 lines long
61Overview of the CRM Control Unit Architecture
(6)
- PAL
- Used to output additional control signals for a
microinstruction for a given instruction - EPROMs do not have the ability to give output
based on combinatorial logic. - These provide unconditional output You give a
memory location, you get an output - There are certain instructions that require
control signals to be generated based on certain
conditions that need to be met - PAL generates conditional control signals (Jump
Instructions!)
62Overview of the CRM Recap of Computer
Architecture
- Remember, Control Unit provides control signals
that are fed to the datapath. - Datapath uses these control signals to perform
what you want it to do! - Do you guys want a break?
- YES ? 10 minute break
- NO ? Well keep going
- Which one???
63Overview of the CRM Control Unit Control
Signals
- Program Counter Control Signal Generation
- Receives CLR from you when you want to reset the
program counter - CLK is also received from you. You tell the
microprocessor you want to go to the next
instruction by this signal (well get into this
later) - PA3-0 provide the next instruction to be executed
in the program (connected to LEDs!) - N3-0 provide the jump address if you want to jump
to a particular instruction number
64Overview of the CRM Control Unit Control
Signals (2)
- Program Counter Control Signal Generation (2)
- /PE and CNT are very special
- /PE 1 and CNT 0 Execute the next
microinstruction for the instruction - /PE 1 and CNT 1 Increment the program
counter and go to the next instruction - /PE 0 and CNT 0 or 1 You want to jump to an
address in your program given by N3-0 - Remember, N3-0 is also the operand part of the
instruction - When you want to jump, you specify the address of
where you want to jump here
65Overview of the CRM Control Unit Control
Signals (3)
- EPROM 1 and 2 Control Signal Generation
- Inputs
- OpCode (O3-O0) Used to figure out what
instruction you want to execute - A1-0 Used to figure out what microinstruction
you want to execute for the given OpCode - N0 Used to figure out what instruction you want
to execute if two instructions share the same
OpCode - A7 Used to tell these EPROMs if a jump condition
has been met (more on this later)
66Overview of the CRM Control Unit Control
Signals (4)
- EPROM 1 and 2 Control Signal Generation
- EPROM 1 is used to generate control signals for
the ALU per microinstruction - EPROM 1 Outputs
- S3-0 Outputs the function you want the ALU to
execute - M Arithmetic or Logic Operation select
- S1-0 Shift register control select
- NCC If you dont expect the output carry to
change, set this to 1, else 0.
67Overview of the CRM Control Unit Control
Signals (5)
- EPROM 1 and 2 Control Signal Generation
- EPROM 2 is used to generate control signals for
memory access, data bus control and Program
Counter control - Also provides the next microinstruction number to
execute - EPROM 2 Outputs
- D1-0 Provides the next microinstruction to
execute - CNT Used to increment Program Counter
- /PE Used to toggle when you want to jump to an
address or not - SM Used to switch between memory or switches
- WR Used to read from or write to memory
- /AS Used to disable and enable accumulator
output
68Overview of the CRM Control Unit Control
Signals (6)
- EPROM 3 Signal Generation
- Inputs
- You need PA3-0 to figure out the next instruction
in your program you want to execute - SW4 and SW5 These are input switches that tell
the microprocessor what program you want to run - SW5 0, SW4 0 ? 1st program
- SW5 0, SW4 1 ? 2nd program
- SW5 1, SW4 0 ? 3rd program
- SW5 1, SW4 1 ? 4th program
- Note Offsetting!
69Overview of the CRM Control Unit Control
Signals (7)
- EPROM 3 Signal Generation
- Outputs
- O3-0 output the OpCode of the particular
instruction to be executed, given the address
from the Program Counter - N3-0 output the Operand of the instruction
- Note This also is fed to the program counter
because Jump Instructions use the Operand to
specify a jump address - Also, the N0 bit is fed to EPROM1 and 2 for
instructions with the same OpCode - Theres a slight problem with this N0 bit
feeding. Youll see later
70Overview of the CRM Control Unit Control
Signals (8)
- Microinstruction Next State Register Control
Signal Generation - Inputs and Outputs
- CLR is used to reset the register so that the
next microinstruction to run will be the first. - CLK is provided by you so it will tell EPROMs 1
and 2 what the next microinstruction is at a
clock cycle - Every clock cycle is 1 microinstruction
- D1-0 is used to grab the next microinstruction
number from EPROM 2 and store it - AEB is the A equals B flag provided by the ALU
given the state of the previous version AEBD - C is the next carry provided to the accumulator
based on the previous carry C - A1-0 outputs whatever was given to D1-0 at the
next clock cycle
71Overview of the CRM Control Unit Control
Signals (9)
- PAL Control Signal Generation
- Inputs
- Q0 LSB of ACCA
- Q3 MSB of ACCA
- O3-0 OpCode given by EPROM 3
- CLK Provided by you as earlier
- N0 As described earlier
- WR Used to enable reading or writing for memory
- NCC Set to 0 if you want to change the input
carry to ACCA, else 1 - /Co Carry out from the ALU goes here to
determine conditional control signals - AEBD Comes from Next-State Register
- C Like above
72Overview of the CRM Control Unit Control
Signals (10)
- PAL Control Signal Generation
- Outputs
- /WE This asserts a write to memory only when WR
1, AND when the CLK is low to ensure that you
can write properly (dont worry about this too
much) - C - Determines the next state of the carry
- /CALU Determines the carry-in into the ALU
- A7 VERY special
- A7 is 1 ONLY when a jump condition has been
satisfied - When A B for JEQ N
- When carry is set for JCS N
- When MSB of ACCA is 1 for JMI N
- JMP N jump signal is not generated here because
it is not a conditional jump
73Procedure for Final Project More about the PAL
- Take a look at page 6 of Lab 7
- You can see that for the PAL, theyve already
generated the PAL equations for you! - You must
- Look at the pinouts for the PAL on the Control
Unit diagram and create a PALASM file based on
these inputs - Remember PIN 10 GND, PIN 20 VCC, and any
pin thats not described in the diagram NC (No
connect) - Write out the logic equations you see for each
output pin in PALASM format
74Outline of Lecture (2)
- Instruction set on CRM
- Details on each instruction available
- Control Unit on CRM
- Architecture
- Control Signals
- Procedure for Final Project
- Preparing EPROM Files
- Microinstructions ? EPROM Format
- Microinstruction Tables and Examples
- Format for code and addressing
- Conversion of EPROMs ? .asc to .hex
75Procedure for Final Project What the CRM looks
like
- 4 places where you plug in your 3 EPROMs and 1
PAL - Datapath and Control Unit are already physically
implemented - Switch Interface is used to control the
microprocessor behaviour - SW3-0 are the input switches
- PA5-4 are the program selection bits
- CLR is used to reset the program counter to 0
- Remember to toggle on and off!
76Procedure for Final Project So now what?
- So, whats already given to you
- Instruction Set with OpCode and Operand formats
- Datapath Unit physically implemented
- Control Unit physically implemented
- So, whatre you supposed to do now?
- What they DIDNT give you is the behaviour of the
microinstructions - They dont tell you what control signals should
be asserted or cleared for a given instruction - Its YOUR job to figure out which signals are
high or low for every microinstruction per
instruction!
77Procedure for Final Project Microinstructions
- Remember, each instruction can take up to 4
microinstructions to implement it - However, most of the instructions given in this
instruction set can be implemented in JUST 1
microinstruction - The only instructions that require 2
microinstructions are - JEQ N
- STSW N
78Procedure for Final Project Microinstructions
(2)
- For each microinstruction, there is a total of 15
control signals generated by EPROMs 1 and 2 to be
sent to the datapath unit for processing - Microinstructions will assert the proper control
signals needed for the datapath unit to properly
execute the given instruction at hand - These microinstructions will be stored in EPROMs
1 and 2
79Procedure for Final Project Microinstructions
(3)
- How does microinstruction signal generation work?
- We need to use
- OpCode
- Microinstruction in the sequence you want to run
- The jump indication bit A7
- Shared OpCode indication bit N0
- These need to be used to access EPROMs 1 and 2 in
order output the proper control signals for the
right microinstruction to execute properly
80Procedure for Final Project Microinstructions
(4)
- Lets create something new
- Lets combine all of these inputs into a single
8-bit input address to EPROMs 1 and 2 which will
be formatted as follows - A7A6A5A4A3A2A1A0
- A7 Jump Indication Bit
- A6 N0 ? Shared OpCode Indication Bit
- A5 A4 A3 A2 OpCode of the instruction you want
- A1A0 Microinstruction number of the instruction
you want executed - Example If A7A6A5A4A3A2A1A0 00000000, this
means that - A7 0 ? Conditional Jump Condition has not been
met - A6 0 ? Shared OpCode Indiciation Bit 0 ?
Choosing the first instruction of the two
instructions which share the same OpCode - A5A4A3A2 0000 ? We want to perform the ADDA N
operation - A1A0 00 ? From the ADDA N operation, we want to
perform the first microinstruction needed for
this instruction
81Procedure for Final Project Microinstructions
(5)
- Given this new method for access microinstruction
controls in the EPROMs, there are 4 possibilities
that you guys will encounter - A7 0, A6 (N0) 0 When the jump condition
hasnt been met and you want to possibly execute
the first instruction of the shared OpCode set
(CLC, SUBA S, RORA, DECA, CLRA) - A7 0, A6 (N0) 1 When the jump condition
hasnt been met and you want to possibly execute
the second instruction of the shared OpCode set
(SEC, ADDA S, ROLA, INCA, SETA) - A7 1, A6 (N0) 0 When the jump condition HAS
been met and you want to possibly execute the
first instruction of the shared OpCode set - A7 1, A6 (N0) 1 When the jump condition HAS
been met and you want to possibly execute the
second insruction of the shared OpCode set
82Procedure for Final Project Microinstructions
(6)
- Why possibly? Remember what I said when I was
looking at the control unit and said N0 would
create a problem? - Because of us making N0 part of the combined
8-bit addressing vector, lets say we want to
execute an instruction like ADDA N, or LDAA N and
so on - Remember, N0 is used for shared OpCode
instructions and this is the LSB of the Operand - But, if we want to use ADDA N or LDAA N, N0 could
be anything!
83Procedure for Final Project Microinstructions
(7)
- N0 when used by these kinds of instructions
states the memory location that you want to use,
so N0 can equal 0 or 1 - What does this mean? Lets do an example
- If we know that
- The jump condition isnt satisfied (A7 0)
- The instruction we want to perform is ADDA N
- The microinstruction we want to execute is the
first one (A1A0 00) - This means we could have
- A7A6A5A4A3A2A1A0 00000000 if we wanted to
access memory location 0 (N0 0) for example. - But what if we wanted to do the above, but
access memory location 1? - A7A6A5A4A3A2A1A0 01000000 if we wanted to
access memory location 1 (N0 1)
84Procedure for Final Project Microinstructions
(8)
- N0 should not affect the control signals to the
datapath required to perform - Access to memory
- Disabling and Enabling the switches or memory
- Accumulator Disabling and Enabling
-
- So, regardless of N0, we want to access THE SAME
microinstruction control signals - If N0 0 or 1, we should still generate the same
control signal values! - What do we do here? At A7A6A5A4A3A2A1A0
00000000 and at A7A6A5A4A3A2A1A0 01000000, we
should have duplicate entries in the EPROM - In both of these memory locations in the EPROM,
we should output the SAME microinstruction
control signals!
85Procedure for Final Project Microinstructions
(9)
- So, instructions that do not use the operand to
distinguish between instructions need to have
their microinstruction signals duplicated for 2
different addresses - Something to note ? Jump Condition Bit, A7, will
NEVER go high when calling instructions like ADDA
N, SUBA N etc. - Jump condition bit only goes high when you call
the conditional jump instructions and the
condition to jump is true - For the instructions that DO use the operand to
distinguish between instructions, their
microinstruction control signals will be
obviously different
86Procedure for Final Project Microinstructions
(10)
- Example Lets do the CLRA and SETA instructions
- CLRA ? Opcode 1111, Operand xxx0 1110SETA ?
Opcode 1111, Operand xxx1 1111 - Assume were at the first microinstruction for
both of these instructions - So, for CLRA ? A7A6A5A4A3A2A1A0 00111100 ? Use
this memory location to access control signals
for CLRA - For SETA ? A7A6A5A4A3A2A1A0 01111100 ? Use this
memory location to access control signals for
SETA - These different memory locations SHOULD have
different microinstruction control signals
because they are DIFFERENT instructions!
87Procedure for Final Project Microinstructions
(11)
- Next, suppose we want to execute a jump
instruction - Lots of different cases thatll happen
- Example 1 JMP N
- LSB of ACCA is used to specify part of jump
address, so N0 can be both 0 and 1. - A7 can never be 1 for this. Only 1 when
conditional jump condition is satisfied - Opcode 0101 Operand Any 4-bit number
- Assume first microinstruction
- So, A7A6A5A4A3A2A1A0 00010100 will be the
address to access the microinstruction signals
for both EPROMs 1 and 2 for N0 0 - Should be the same microinstruction signals for
when N0 1 as well
88Procedure for Final Project Microinstructions
(12)
- Example 2 JCS N
- LSB of ACCA is used to specify part of jump
address, so N0 can be both 0 and 1. - A7 will be either 0 when a condition to jump
hasnt been met, and 1 when a condition to jump
has been met - Opcode 1100 Operand Any 4-bit number
- Assume first microinstruction
- Case 1 A7 0
- In this case, A7 will equal 0, therefore
A7A6A5A4A3A2A1A0 000110000 for N0 0. The
microinstruction control signals should simply
move to the next instruction ? Jump Condition
hasnt been met. - Same for when N0 1
89Procedure for Final Project Microinstructions
(13)
- Case 2 A7 1
- In this case, A7 will equal 1, therefore
A7A6A5A4A3A2A1A0 000110000 for N0 0. The
microinstruction control signals should be
asserted so that the program counter should load
the instruction address to jump to - Same for when N0 1 the same logic as last time
90Procedure for Final Project Microinstructions
(14)
- Now that youre aware of the things we need to
know about microinstruction control signal
generation, its time to figure out when to
assert these signals for each microinstruction - Take a look on Pages 17 19
- They give you nicely laid out tables for you to
fill out the proper microinstruction signals to
assert for a given instruction - Remember, there are 15 different control signals
coming out from both EPROMs 1 and 2
91Procedure for Final Project Microinstruction
Tables
- Heres what part of the table looks like
- 3 different columns exist for each EPROM
- 1st column Shows your 8-bit combined input
addressing vector shows all combinations
possible with this combined addressing - Note the conversion of this combined address to
hexadecimal - 2nd column Shows you the microinstruction
control signals asserted for the 8-bit combined
input addressing for this row for EPROM 1 - 3rd column Shows you the microinstruction
control signals asserted for the 8-bit combined
input addressing for this row for EPROM 2
92Procedure for Final Project Microinstruction
Tables (2)
-
- EPROM 1 ? Control signals that are outputted from
here given the 8-bit combined input address are - NCC No change to next input carry of ACCA
- S1 and S0 Control the shift register
- M ALU Arithmetic and Logic Operation Control
- S3-0 Control what specific ALU operation you
want
93Procedure for Final Project Microinstruction
Tables (3)
-
- EPROM 2 ? Control signals that are outputted from
here given the 8-bit combined input address are - D7 Dont know what this is and I cant
remember. Always set this to dont care (1) - /AS Accumulator Disable / Enable
- WR Reads from memory or writes to memory
- /PE Program Counter uses or ignores jump
address fed in - CNT Used to determine whether to execute a
microinstruction or an instruction - A1, A0 - Used to specify the next
microinstruction to execute
94Procedure for Final Project Microinstruction
Tables (4)
- You will notice that there are 4 tables that you
need to fill out - There are 4 tables because of the 4 scenarios
involving A7 and N0 - Hints
- Control signals for the instructions that dont
use N0 for shared OpCode instructions will have
the same signals for when N0 0 and N0 1 - Those that do use N0 for shared OpCode
instructions WILL be different for when N0 0
and N0 1 - Control signals for instructions that attempt a
conditional jump and fail should only make the
microprocessor go to the next instruction (A7
0)
95Procedure for Final Project Microinstruction
Tables (5)
- When A7 1, this means that a conditional jump
condition is true - Less entries for this table since A7 can never be
1 for instructions like ANDA N, SUBA S, etc. - When A7 1, you should assert the proper control
signals for this microinstruction which will load
the program counter with whatever is in the
Operand N3-0 - When A7 1, the tables should be the same for
both N0 0 and 1. - N0 is used as part of the address to jump to.
Duplicate microinstruction signals are required
96Procedure for Final Project Examples
- Lets do ADDA N (Page 13)
- EPROM 1 Signals
- NCC 0 since carry to the accumulator can change
(arithmetic operation youll see!) - S1 S0 1 since you want to load the register
with some contents - M 0 for arithmetic operation
- S3-0 1001 ? Specifies adding 2 numbers (Page 4
of sn74ls181.pdf) - EPROM 2 Signals
- D7 Dont Care (1)
- /AS 1 since you want to disconnect the
accumulator with the data bus - WR 0 since you want to read from memory address
N - SM 0 since you want to choose memory and not
the switches - /PE 1 since you want to ignore jumping to an
address - CNT 1 since you want the program counter to
increment next instruction to execute - A1 0 and A0 0 to point to the next
microinstruction to execute (00 for the next
instruction)
97Procedure for Final Project Examples (2)
- Lets do JEQ N (Page 13)
- First, we must test to see if A B or B A 0
- EPROM 1 Signals
- NCC 1 The carry of the accumulator shouldnt
change. Not performing any arithmetic operations
to store into accumulator. Only testing - S1 0, S0 0 The accumulator should not
change its contents were just testing if B A
0 - M 0 for arithmetic instruction
- S3-0 0110 specifies subtracting ? A B
- EPROM 2 Signals
- D7 1 as before
- /AS 1 since we are testing for B A. Should
not be connected to data bus - WR 0 to be safe. Were not using memory, but
safer to read than write to avoid memory glitches - SM 1 to choose switches
- /PE 1 to ignore jump address
- CNT 0 to execute next microinstruction
specified by next-state register - A1 0, A0 1, to execute the second
microinstruction
98Procedure for Final Project Examples (3)
- The next microinstruction to execute will depend
on when the A equals B flag is 0 or 1 - Case 1 When A equals B flag 0
- Therefore A7 0, and we should just go to the
next instruction - EPROM 1 Signals
- NCC 1 so carry isnt changed again
- S1 S0 0 since we dont want to change ACCA
contents - M and S3-0 are dont cares (1) since we just want
to go to next instruction - EPROM 2 Signals
- D7 Dont Care (1)
- /AS 1 to disable attachment to data bus for
safety - WR 0 since its safer to read than write for
this case - SM Dont care (1) because it doesnt matter
whether you want to enable the switches or
memory you just want the next instruction - /PE 1 to ignore jump address
- CNT 1 since you want to execute next
instruction - A1 A0 0 so you can execute first
microinstruction of next instruction
99Procedure for Final Project Examples (4)
- Case 2 When A equals B flag 1
- Therefore A7 1, which means we need to load the
program counter with the address of N and jump
there - EPROM 1 Signals
- NCC 1 so carry isnt changed again
- S1 S0 0 since we dont want to change ACCA
contents - M and S3-0 are dont cares (1) since we just want
to go to next instruction specified by N - EPROM 2 Signals
- D7 Dont Care (1)
- /AS 1 to disable attachment to data bus for
safety - WR 0 since its safer to read than write for
this case - SM Dont care (1) because it doesnt matter
whether you want to enable the switches or
memory you just want the next instruction - /PE 0 to use jump address
- CNT Dont care because it doesnt matter
whether you want to go to next instruction or
microinstruction. Instruction number WILL change - A1 A0 0 so you can execute first
microinstruction of next instruction
100Procedure for Final Project Examples (5)
- Final example STSW N
- Does 2 instructions INPA and STAA N
- Step 1 INPA
- EPROM 1 Signals
- NCC 0 since carry to the accumulator can change
(arithmetic operation youll see!) - S1 S0 1 since you want to load the register
with some contents - M 1 for logical operation
- S3-0 1010 ? The output of the ALU will be
simply B, the switches (more below) - EPROM 2 Signals
- D7 Dont Care (1)
- /AS 1 since you want to disconnect the
accumulator with the data bus - WR 0 since you want to be safe and set it to
read. Writing might cause glitches - SM 0 since you want to choose the switches and
not memory - /PE 1 since you want to ignore jumping to an
address - CNT 1 since you want to execute the next
microinstruction specified by below - A1 0 and A0 1 to point to the second
microinstruction to execute
101Procedure for Final Project Examples (6)
- Step 2 STAA N
- EPROM 1 Signals
- NCC 1 since carry to the accumulator shouldnt
change. Only storing. - S1 S0 0 since contents of register shouldnt
change - M and S3-0 Dont Cares ? Not using ALU. Were
only storing - EPROM 2 Signals
- D7 Dont Care (1)
- /AS 0 since you want to connect the accumulator
with the data bus to transfer to memory - WR 1 since you want to write from memory
address N - SM 0 since you want to choose memory and not
the switches - /PE 1 since you want to ignore jumping to an
address - CNT 1 since you want the program counter to
increment next instruction to execute - A1 0 and A0 0 to point to the next
microinstruction to execute (00 for the next
instruction)