iPad 2
I recently got an iPad 2, and the first thing I did after connecting it to iTunes was to upgrade it to iOS5. After I did, iTunes gave me the error "This device is not registered as part of the iPhone Developer Program".
This is easily fixed, all I needed to do was log into the developer portal and add the device UDID, however the screen telling me this was preventing me from getting the UDID.
Eventually I managed to retrieve it from the Organiser in XCode. Glad I didn't brick it in less than 8 hours, I can now play around with airplay once I've flashed my AppleTV.
If-Else If
I never really thought about if statements until sometime last year, when I noticed that an if statement only has an else, there is no such thing as an else if.
I was writing an if statement at the weekend and I was writing an else for that got me thinking about it again.
Another revelation is that Alex from Clockwork Orange is also Caligula from Caligula, and Linderman from Heroes.
if( value == true )
doSomething();
else if( anotherValue == true )
doSomethingElseIf();
else
doSomethingElse();Take this for example, break up the else if, shifting the if onto a new line and indent, the nature of the if statement is revealed.
if( value == true )
doSomething();
else
if( anotherValue == true )
doSomethingElseIf();
else
doSomethingElse();An if statement only uses the single statement after the if and then the single statement after the else, so the else if is only an else with another if as its single statement.
The way we are allowed to perform multiple statements is to either wrap it in a function, or to use brackets to give scope.
if( value == true )
{
doSomething();
doSomething2();
}
else
if( anotherValue == true )
doSomethingElseIf();
else
{
doSomethingElse();
doSomethingElse2();
}Of course rather than just indenting, its easier to read with the else and if treated as else if.
if( value == true )
{
doSomething();
doSomething2();
}
else if( anotherValue == true )
doSomethingElseIf();
else
{
doSomethingElse();
doSomethingElse2();
}This can be applied to other statements too, such as for loops, do while loops, and while loops.
// Else-For
if( value == true )
{
doSomething();
}
else for( int i = 0; i < 2; ++i )
{
doSomethingFor( i );
}
// Else-Do
if( value == true )
{
doSomething();
}
else do
{
anotherValue = doSomethingDo();
} while( anotherValue );
// Else-While
if( value == true )
{
doSomething();
}
else while( anotherValue )
{
anotherValue = doSomethingWhile();
}
Processor Memory
Storing variables on registers is fine, but eventually another operation will need to happen and the contents needs to be moved somewhere else more permanent.
For this, the processor will also need memory.
Building on using flip flops for storing data for registers, I decided that if I could create an enable flag that could be AND'd with the value in the flip flop, I could create a logic gate sequence for each address as to whether the input address is valid for that block.
All other addresses won't accept the address and so won't output anything.
RAM
In the image is a basic design for reading two bits from memory. There are a total of four bits worth of memory, two bits on address 0x00, and two bits on address 0x01.
I've hardcoded the values contained within that memory into the flip flops. Using a series of logic gates, each address of memory enables the transistor to return the value from the flip flops.
Using a unique logic gate sequence for each memory address means only one return set can be active at a time.
As you can see in the image to the right, changing the memory address to be 0x01 returns the data from the other flip flops.
I still need to add another input so I can write to memory as well, I could probably use the same data lines as the output and AND it with the write input flag.
How much RAM I haven't decided yet, I think maybe 4 addresses worth might be enough for such a basic system. The nice thing about this system is that more can be added at any time.
Removable Storage Media
I was thinking about making a version of removable storage as well, the idea is based on reading data from CDs, a piece of memory with black and white markers that can be read by LDRs.
I could also add some kind of paper feed system, then it could random access previous pages.. heh pages.
Processor Register
With my full adder complete and working in emulation, I just need to build it on a breadboard to make sure it works in practice.
The next step would be to etch and build a prototype before outsourcing for eight of them to be made (my processor will be 8bit), I might use surface mount components to keep down costs and size.
Okay, so I can add two numbers together, but where do I get those numbers from, and where can I store the result. Now I need memory, specifically for registers.
So how do I write and read bit states. The answer is a Flip Flop.
To read from it is easy, neither input should be set as high, and the output will be the value stored.
To write a state, first the Reset input must be set high, this sets the value stored to low, now before a new value is set, Reset must be set to low.
With reset set to low, the Set input should be set high to store a high value. One problem with however is that giving an input of low, will not store a low signal.
One way around this is to use a third input, Enable. We can AND this input with each input.
Now whenever we want to set a value, we must set the reset to high, then toggle the Enable input between high and low.
For setting a value, we set the Input to the value we want stored, and toggle the Enable input between high and low.
This will prevent accidentally setting the value stored until we are ready.
Now I just need to breakdown the logic gates in the flip flop into discrete components. The AND Gate I already have a circuit for, so all I need a NOR Gate.
A NOR Gate works in the reverse of an OR Gate, so I just switched the PNP for an NPN, however the voltage dropped again so I added another signal booster.
I only quickly put this circuit together and will look at reducing the amount of transistors being used for it later. For three registers, two for input and one for output, an 8-bit processor will need a total of 24 flip flops.
More Discrete Logic
I have wondered why I haven't found any other 2 transistor XOR Gates, and only now do I think I know the reason why.
There was a slight flaw in my Full Adder where one of the output bits was being set when it shouldn't.
The cause, a slightly lower voltage caused by the diode in my OR Gate. Without the same voltage at the base of the PNP as in the emitter, one of the PNP will always remain active.
Because of this, I'm going to have to rework my OR gate as well, or the signal 'booster' circuit I added to my XOR gate to guarantee that it remains the same for both inputs.
Slightly modifying the AND gate, removing a resistor and replacing the right NPN with a PNP, I get a high signal whenever both inputs have enough voltage to trigger the NPN transistors.
The OR gate is similar to the AND gate, only either transistor should short circuit the base of the PNP to ground.
Discrete Logic continued
See previous post Discrete Logic.
EDIT: There is a flaw with this XOR circuit, see More Discrete Logic.
In my previous post I used two PNP transistors to perform of the job of XOR gate, however after building and test, the drop in voltage was too much over just a single full-adder.
Using a circuit I got from the EEV Forums, I got help when I needed to supply 14V to my OLED but the open drain on my chip supply a maximum of 2.5V, the XOR will now supply 5V from its output when it is high.
The 1k resistor represents the load. I've also added diodes onto the inputs since I had a problem with my AND circuit getting power from the base of the PNPs.
It requires an additional NPN and PNP transistor and a couple more resistors.







