Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Simple 4bit CPU

Go down  Message [Page 1 of 1]

1Simple 4bit CPU Empty Simple 4bit CPU Fri Apr 09, 2021 1:11 am

Mistral



This project consists of two parts, they are called Sample1 and Sample2.
It is based on a design made by Jon Qualey.
http://www.galacticelectronics.com/Simple4BitCPU.HTML
Sample 1&2 are here:
http://www.galacticelectronics.com/4BitCPU_SamplePrograms.HTML
I used my own data for S1. The Rom files are here:
https://github.com/Alectus/Gep-Cpu
S1a is making the leds count.
Data S1a Ram0 = don't care
Data S1a Ram1 = 
4,   3,   14,  4,   3,   14,   4,   3,   14,   4,   3,   14,   4,   3,   14,   15
S1b is making a pattern:
Data S1b Ram0 = 
15,   0,   0,   10,   0,   0,   9,   0,   0,   6,   0,   0,   3,   0,   0,   12
Data S1b Ram1 = 
1,   3,  14,   1,  3,   14,  1,  3,  14,   1,   3,   14,   1,   3,   14,   15
More info and a page with the instruction set:
https://simulide.forumotion.com/t162-simple-4bit-cpu-spike-in-pc-clk-pin

Simple 4bit CPU Gep_cp12

Full view:

Simple 4bit CPU Gep_cp13

Simu-file
https://github.com/Alectus/Gep-Cpu/blob/main/Gep%20Cpu%20Sample1%20completed.simu

2Simple 4bit CPU Empty Re: Simple 4bit CPU Fri Apr 09, 2021 12:27 pm

Mistral



Some additional information.
The reason why I used my own data for Sample1 is because the Jon Qualey example did not give the result as expected. It turns out there seems to be a typo at this Gep-website.
http://www.galacticelectronics.com/4BitCPU_SamplePrograms.HTML
The first Data and Instruction lines are switched around, marked by the arrows

Simple 4bit CPU Ram0_j10
So, in decimals you can put into
Ram0 =
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
Ram1 =
   1,   6,   2,   14,   4,   3,   9,   0,   0,   0,   0,   0,   0,   0,   0,   0
Running at 60Hz this gives a very nice pinball machine effect. In a ordered manner, the leds are counting. By the way, Register A is the same as Register 0. That is IC 74HC670 in the Accu-section.
Overview of the instruction set:


Simple 4bit CPU Gep_mi12

a is the address shown in the two 7-segments under Rom0.
b is the instruction name
c is the operation it does
d is the decimal to put into Ram1

So for example, to make the leds count you put into Ram 1: 
4,   3,   14,  4,   3,   14,   4,   3,   14,   4,   3,   14,   4,   3,   14,   0
That means INC followed by STORE and followed by OUT repeatively.
Maybe the last zero I should make it a 15, a NOP.


*********************


This project is given the title Simple because the author used that term here:
http://www.galacticelectronics.com/Simple4BitCPU.HTML
Compared to modern machines it might be simple but I am not able to design this myself.

There are some more details about this Gep Cpu here:
https://simulide.forumotion.com/t148-show-id-text-lines-break-up
It is about a Start/Stop issue, it is not that critical and is not resolved yet, it is very busy at the moment for the Simulide Team preparing version 0.4.15 for launch.



Last edited by Mistral on Sat Apr 10, 2021 8:41 pm; edited 1 time in total (Reason for editing : Typo in picture table, replaced it.)

arcachofo likes this post

3Simple 4bit CPU Empty Re: Simple 4bit CPU Sat Apr 10, 2021 12:56 pm

Mistral



I have added a stepper motor, still using sample1.

Simple 4bit CPU Gep_cp14

Ram0=    7,   0,   0,   11,   0,   0,   13,   0,   0,   14,   0,   0,   0,   0,   0,   0
Ram1 =    1,   3,   14,   1,   3,   14,   1,   3,   14,   1,   3,   14,   9,   0,   0,   0
So the instructions are : Literal, Store, Out, LSO, LSO, LSO and the 9 for Restart.
The data are used to give the signals to the stepper to make it turn clockwise. They are fetched only during Literal, that's why there are zero's in between.
It can go up to 4 kHz and that has a Speed of about 56%.
At 5kHz the stepper stops turning.

https://github.com/Alectus/Gep-Cpu/blob/main/Gep%20Cpu%20Sample1%20stepper%20motor.simu

4Simple 4bit CPU Empty Re: Simple 4bit CPU Sat Apr 10, 2021 9:19 pm

Mistral



Sample 2 is finished.
There were some typos in the samples and a wiring mistake in the comparator section. 
The typos are marked in red

Numonic Address Data Instruction Comments
------------------------------------------------------------------------------
Sample 1 Make leds count Runs in segment zero.

LIT 1 0000 0000 0000 0001 Put 0 in the accumulator.
REG 0000 0001 0000 0110 Select register A.
LOAD 0000 0010 0000 0010 Load value into accumulator from reg A.
OUT 0000 0011 0000 1110 Send accumulator value to output.
INC 0000 0100 0000 0100 Increment accumulator.
STORE 0000 0101 0000 0011 Store accumulator back to register A.
RST 0000 0110 0000 1001 Restart program counter.


Numonic Address Data Instruction Comments 
------------------------------------------------------------------------------
Sample 2 Make leds go 1-2-4-8 Runs in 4 memory segments.

Segment 0. Loads registers A and B.

LIT 0 0000 0000 0000 0001 Put 0 in the accumulator.
REG 0000 0001 0000 0110 Select register A for write.
LIT 1 0000 0010 0001 0001 Put 1 in the accumulator.
STORE 0000 0011 0000 0011 Put 1 in register A.
LIT 1 0000 0100 0001 0001 Put 1 again in the accumulator.
REG 0000 0101 0000 0110 Select register B for write.
LIT 2 0000 0110 0010 0001 Put 2 in the accumulator.
STORE 0000 0111 0000 0011 Put 2 in register B.
CMPL 0000 1000 0010 0111 Compare to last accu value.Set equal flg
LIT 1 0000 1001 0001 0001 Put 1 in the accumulator.
JUMPE 0000 1010 0000 1011 Jump to segment 1.

Segment 1. Loads registers C and D.
LIT 2 0001 0000 0010 0001 Put 2 in the accumulator. 
REG 0001 0001 0000 0110 Select register C for write. 
LIT 4 0001 0010 0100 0001 Put 4 in the accumulator. 
STORE 0001 0011 0000 0011 Put 4 in register C. 
LIT 3 0001 0100 0011 0001 Put 3 in the accumulator. 
REG 0001 0101 0000 0110 Select register D for write. 
LIT 8 0001 0110 1000 0001 Put 8 in the accumulator. 
STORE 0001 0111 0000 0011 Put 8 in register D. 
CMPL 0001 1000 1000 0111 Compare to last accu value.Set equal flg 
LIT 2 0001 1001 0010 0001 Put 2 in the accumulator. 
JUMPE 0001 1010 0000 1011 Jump to segment 2.

Segment 2. Sends regs A and B to output.

LIT 0 0010 0000 0000 0001 Put 0 in the accumulator.
REG 0010 0001 0000 0110 Select register A for read.
LOAD 0010 0010 0000 0010 Load register A to accumulator.
OUT 0010 0011 0000 1110 Output accumulator (register A).
LIT 4 0010 0100 0100 0001 Put 4 in the accumulator.
REG 0010 0101 0000 0110 Select register B for read.
LOAD 0010 0110 0000 0010 Load register B to accumulator.
OUT 0010 0111 0000 1110 Output accumulator (register B).
CMPR 0010 1000 0000 1000 Compare accu to register.Set equal flag.
LIT 3 0010 1001 0011 0001 Put 3 in the accumulator.
JUMPE 0010 1010 0000 1011 Jump to segment 3.


Segment 3. Sends registers C and D to output.

LIT 8 0011 0000 1000 0001 Put 8 in the accumulator.
REG 0011 0001 0000 0110 Select register C for read.
LOAD 0011 0010 0000 0010 Load register C to accumulator.
OUT 0011 0011 0000 1110 Output accumulator (register C).
LIT 12 0011 0100 1100 0001 Put 12 in the accumulator.
REG 0011 0101 0000 0110 Select register D for read.
LOAD 0011 0110 0000 0010 Load register D to accumulator.
OUT 0011 0111 0000 1110 Output accumulator (register D).
CMPR 0011 1000 0000 1000 Compare accu to register.Set equal flag.
LIT 2 0011 1001 0010 0001 Put 2 in the accumulator.
JUMPE 0011 1010 0000 1011 Jump back to segment 2 - loop.

Numbers in red are (corrected) typos at the Gep-website
http://www.galacticelectronics.com/4BitCPU_SamplePrograms.HTML


****************************************

The wiring mistake is this one:
Simple 4bit CPU Alu_co10

Comparator 74HC85 inputs A0-3 should be connected with D0-3.
After these bugs were solved it's running very nice. And by coïncidence Sample2 can be used to drive a stepper motor.

Simple 4bit CPU Gep_cp15

Data decimals for Ram0:
   0,   0,   1,   0,   1,   0,   2,   0,   2,   1,   0,   0,   0,   0,   0,   0
   2,   0,   4,   0,   3,   0,   8,   0,   8,   2,   0,   0,   0,   0,   0,   0
   0,   0,   0,   0,   4,   0,   0,   0,   0,   3,   0,   0,   0,   0,   0,   0
   8,   0,   0,   0,   12,   0,   0,   0,   0,   2,   0,   0,   0,   0,   0,   0
Data decimals for Ram1:
   1,   6,   1,   3,   1,   6,   1,   3,   7,   1,   11,   0,   0,   0,   0,   0
   1,   6,   1,   3,   1,   6,   1,   3,   7,   1,   11,   0,   0,   0,   0,   0
   1,   6,   2,   14,   1,   6,   2,   14,   8,   1,   11,   0,   0,   0,   0,   0
   1,   6,   2,   14,   1,   6,   2,   14,   8,   1,   11,   0,   0,   0,   0,   0

Simu-file:
https://github.com/Alectus/Gep-Cpu/blob/main/Gep%20Cpu%20Part3%20JQ%20Sample2%20completed.simu

Clock is set at 1 kHz.

Simple 4bit CPU Gep_cp16

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum