Digital_Lab_41
"(Very) Small Computer System Design"
by
Choon B. Kim, Ph.D., a retired ASIC engineer
Prerequite: This Lab assumes that you have basic knowledge of computer architecture, its low-level operations, and machine/assembly language programming. If you do not, it is recommended for you to spend some time for learning them before trying this lab.
1. Design Specifications:
In this lab, you will design a very small, introductory-level computer system on FPGA board with following features.
1.1) Architecture:
1.1.1) CPU : 8-bit PC, 16-bit IR & AC, ALU, Control Unit
1.1.2) External memory : 16-bit word x 265 words
1.1.3) Bus : 8-bit Address Bus, 16-bit Data Bus,
1.1.4) Bus Interface Register : 8-bit MAR, 16-bit MDR
1.2) Instruction set: Here, you can specify your own instruction set which defines the operation of your computer.
A few common instructions are listed here for your reference and testing purpose.
Instruction Mnemonic Operation Preformed Opcode Value
ADD Address AC <= AC + memory(Address) 00
STORE Address memory(Address) <= AC 01
LOAD Address AC <= memory(Address) 02
JUMP Address PC <= Address 03
XNOR Address AC <= AC XOR memory(Address) 04
SUB Address AC <= AC - memory(Address) 05
XOR Address AC <= AC XOR memory(Address) 06
OR Address AC <= AC OR memory(Address) 07
AND Address AC <= AC AND memory(Address) 08
ADDI Data AC <= AC + Data 09
SHL Data AC <= AC shifted left by data bits 0A
SHR Data AC <= AC shifted right by data bits 0B
OUT xxxx 7-Seg LED displays hex value of AC 0C
etc.....
1.3) Clock: Use 5 Hz clock for testing purpose(for easy reading the output on 7-sement Didplay )
1.4) Power-on initial state: Turn on the power ==> HEX3-1 = "0000":
1.5) Initial state of Computer: Press KEY(3) ==> HEX3-1 = "0000"
1.6) Input : User provides the computer a link to a .mif file of input program written in machine language.
1.4) Output: The output is displayed on HEX3-1(7-segment Display) following the SW settings below.
1.4.1) SW[3:0] = 0000 ==> HEX3-1 = "0000"
1.4.2) SW[3:0] = 0001 ==> HEX3-1 = PC
1.4.3) SW[3:0] = 0010 ==> HEX3-1 = OUT instruction (=hex value of AC)
1.4.4) SW[3:0] = 0100 ==> HEX3-1 = IR
1.4.5) SW[3:0] = 1000 ==> HEX3-1 = MDR
1.4.6) SW[7:4] not used...
1.4.7) SW[8] = 1 for doubling the clock frequency to 10 Hz for testing purpose only
1.4.8) SW[9] = 1 for Pause operation
2. Testing(video on YouTube):
Test case:
The test program adds two numbers ("AAAA", "1111") in memory and stores the result("bbbb") in memory, and repeats the same process.
Various outputs based on SW[3:0] will be displayed in HEX3-1. For example, when SW[3:0] = 0010, the pattern, "AAAA......bbbb" should repeat continously.
The mif file for the test case:
-- Digital_Lab_41
DEPTH = 256; % Memory depth and width
are required %
WIDTH = 16; % Enter a decimal number %
ADDRESS_RADIX = HEX; % Address and value
radixes are optional %
DATA_RADIX = HEX;
% Enter BIN, DEC, HEX, or OCT; unless %
% otherwise specified, radixes = HEX %
-- Specify values for addresses, which can be single
address or range
-- program: add A + B = C
CONTENT
BEGIN
[00..FF] :
0000; %
Range--Every address from 00 to FF = 0000 (Default) %
00
: 0211;
% LOAD A with MEM(11) %
01
: 0C00;
% OUT Acc
%
02
: 0012;
% A = A + MEM(12)
%
03
: 0113;
% STORE A to MEM(13) %
04
: 0213;
% LOAD A with MEM(13) %
05
: 0C00;
% OUT Acc
%
06
: 0300;
% JUMP to 00 (loop forever) %
10
: 0000;
% Reset Value
%
11
: AAAA;
% A
%
12
: 1111;
% B
%
13
: 0000;
% C, output value
%
END ;
https://youtube.com/shorts/Ita4U0mSH0c
3. Recommended additional work:
Add following instruction(s) to your computer system design.
3.1) Random number generation
Instruction Mnemonic Operation Preformed Opcode Value
RANDOM Data AC <= 4-bit Random Number 0x55
Test case mif file:
.....
[00..FF] : 0000; % Range--Every
address from 00 to FF = 0000 (Default) %
00 : 0210;
% Reset AC - LOAD A with 0000 at MEM(10) %
01 : 5500;
% A random number generated at AC %
02 : 0C00;
% OUT AC %
03 : 0300;
% JUMP to 00 (loop forever) %
10 : 0000;
% Reset Value %
....
Test video: https://youtube.com/shorts/JtIvdmWs7bk
3.2) Indirect addressing
Instruction Mnemonic Operation Preformed Opcode Value
ADDIND Address AC <= AC + memory(Indirect Address) 0x56
Test case mif file:
.....
[00..FF] : 0000;
% Range--Every address from 00 to FF = 0000 (Default) %
00 : 0210;
% LOAD AC with MEM(10) -- initialize AC %
01 : 0C00;
% OUT AC %
02 : 5611;
% ADD INDIRECT memory contents to AC %
03 : 0C00;
% OUT AC %
04 : 5613;
% ADD INDIRECT memory contents to AC %
05 : 0C00;
% OUT AC %
06 : 0300;
% JUMP to 00 (loop forever) %
10 : 0004;
11 : 0012;
12 : 0009;
13 : 0010;
END ;
....
Test video: https://youtube.com/shorts/Pbf_GpdzaTo
3.3) PCR(Program Counter-Relative) addressing
Instruction Mnemonic Operation Preformed Opcode Value
ADDPCR Data AC <= AC + memory(PCR Address) 0x57
Test case mif file:
.....
[00..FF] : 0000;
% Range--Every address from 00 to FF = 0000 (Default) %
00 : 0210;
% LOAD AC with MEM(10) -- initialize AC %
01 : 0C00;
% OUT AC %
02 : 570E;
% ADD PCR memory content to AC %
03 : 0C00;
% OUT AC %
04 : 570D;
% ADD PCR memory content to AC %
05 : 0C00;
% OUT AC %
06 : 570C;
% ADD PCR memory content to AC %
07 : 0C00;
% OUT AC %
08 : 0300;
% JUMP to 00 (loop forever) %
10 : 000A;
11 : 0009;
12 : 000C;
13 : 001B;
END ;
....
Test video: https://youtube.com/shorts/B8aCoVPOXnM
4. Key lesson(s) learned from this Lab:
How to handle the basic computer system design in digital system design.
5. Timing(optional):
Assuming your design is used as a part of a bigger clock-based system, find the maximum clock frequency of your design.
Explain how you get it.
------------------------------------------- The End of Digital_Lab_41 ---------------------------------------------------