Tuesday, 24 July 2012

Buzzer added, Code base released

A close up of the final board for the NRI 832.

I have added a piezo buzzer on the left. It provides a beep on start up and a beep whenever a key is pressed which does help with using the board.

Also, the final code archive should now be in the links on the right.

This is an archive of the entire project. If anyone wants to rebuild this, note that the Arduino code is included rather than linked - I couldn't figure out how to link 'C' code not part of the Arduino project in (I'm not even sure if it is possible) so this will require some tweaking.

Monday, 23 July 2012

From Prototype to Final

The last one was of course a prototype. I have now built a final permanent version on an Arduino Prototyping Shield with a detachable keyboard which is much easier to use than the old one hanging off the Arduino :)

Other than that it is much the same except the order of the LEDs is reversed. That's because this one is upside down to the prototype (the Arduino programming socket is now on the right).

The design is the same - 8 LEDs, 8 1k Resistors, 3 x 4 7 pin keypad, Arduino Duemanona - that thing, Uno, Leonardo, just about any Arduino is up to this.

I might add a beeper to this, for the following reasons.
  • I've got one in my box of electronic bits.
  • I've got some unused Arduino pins
  • I can use it to give audio feedback on key presses
  • I can (maybe) add some Audio instructions to the NRI832.

With the policy of plausible-in-1972-hardware (like the RAM* and Subroutine system)) though this means that hardware improvements have to be reasonably plausible.

I can't just plug an AY-3-8912 (award yourself 1 retropoint if you know what that is without looking). It would have to be something like a latch feeding a programmable down counter with bit 0 driving a speaker.

One thing that could be plausibly uprated is the speed. As far as I can see the clock speed is completely arbitrary. It could be driven a lot faster - it's stock 74 series TTL which has a propagation speed in nano seconds. It could probably run 50 times faster without breaking sweat. I suppose there wouldn't be much point though.

Thursday, 19 July 2012

Dracula has risen from the Grave.

video

It lives :)

The video above shows the new improved NRI832. It's running a simple program (see below) at what I think is the speed, about 16Hz (there's a 250Hz clock and 8 fetch and 8 execute cycles).

What happens in the video ... okay, it's not that exciting but it's still better than Gigli.

  1. I press the reset button
  2. The LEDs all blink to show it's alive
  3. The LEDs show the first program byte 00000011 (e.g. LDA 03)
  4. I press 9 (the run button)
  5. It displays the accumulator as it is running, hence the counting effect.
  • 00 LDA 03
  • 01 ADD 04
  • 02 JMP 01
  • 03 0
  • 04 1
I will upload some more demonstration stuff when I can stabilise my camera. This was shot with the hand you can't see holding my Android phone :)

Prototype Hardware

The rats nest to the right is the prototype for the NRI832 hardware. Nor running actual code yet, just a testing program that takes a key from the keypad and displays its ASCII value on the LEDs (00110010 == $32, or character '2').

Despite the mess it is relatively simple. It is an Arduino Duemanolive (sic ?) - i.e. a Mega328 based Arduino. Ontop of that is a prototyping shield with a breadboard.

The LEDs are connected to ground via 8 1k Resistors and are connected to pins 10,9,A5,A4,A3,A2,A1,A0 respectively (left to right).

The keypad is a standard 3x4 keypad (almost everywhere sells them) and it is connected to 8,7,6,5,4,3,2 (left to right).

Pins 1 and 0 are NC because I used Serial Debugging at one point.

Unfortunately it is upside down. On all these trainer-type constructs the display is always above the keyboard. I used a pin strip (6 pins) and a wire to fit the keyboard (the wire because of the gap between pins 7 and 8 on an Arduino).

Most of the code is written now - the 'C' code simulates the Arduinos operation, providing functions to isolate the actual physical I/O, so I just need to glue it to this code and hopefully it should work. The C code link on the right has been updated with this new code. Not that it's very interesting :)

Tuesday, 17 July 2012

C version of CPU Core

To get the system into an Arduino, I need a C version. This also can be used for simulating, running programs in a command line and for testing.

The first version of this is now available. It has three modes of use controlled by a single parameter.

nri832 run - runs the simulator for the Arduino system which isn't implemented yet.

nri832 test - runs the unit test of the CPU core, running 1,000,000 simulated instructions which takes about 7 seconds on my PC.

nri832 ???? - runs the binary file and dumps the processor status to the console as it goes along.

The code is for Code::Blocks and the provided binary is for 64 bit Linux, though it should compile on any version of gcc or more or less any other 'C' compiler.

The picture shows the result of a run of the 'divide' code.  It is dividing $86 (134) by $0C (12) giving a result of $0D (13) remainder $02 (2).

These values are store in the data memory except for the result which is in the Accumulator.

This version also supports the subroutine extensions and 512 bytes of memory.

Monday, 16 July 2012

NRI832 Assembler now available.

Now you can write NRI832 code using an assembler. The assembler takes source files and creates a binary output file, and a source/object listing.

The assembler is written in Python and requires version 2.7. The archive includes the multiplication and division routines, and a version of the divide code using the paging system.

To use it, you need to run it as a Python script from the command line (okay, Visual Studio 2012 it is not .....) and pass source file name(s) as a parameter.

As well as producing hexadecimal listing, it also produces a 737 octal listing (i.e. an octal number representing bits 5,6,7, bits 3,4, and bits 0,1,2. The reason for this is that the hardware version won't use toggle switches but a 3x4 keypad (see piccy), and the operation codes are better suited to 737 format than 377 format.

I am using a 3x4 keypad because .... that's what I've got in my box of electronic bits and bobs. Actually a 4x4 keypad allowing Hexadecimal opcodes wouldn't be as clear and the octal keypad gives four keys for controlling the machine. Using a 737 format gives you the opcode as the first digit and the operand as the last two. However it is a bit of a daft thing for constants. So it'll be one of these, 8 LEDs, 8 resistors and an Arduino Uno.

I wasn't ever actually going to reproduce the physical controls of the NRI832. I do not have 128 toggle switches for one thing. If I did I wouldn't want to spend hours wiring the things up along with the multiplexer circuits. It would be a nightmare to program anyway. The toggle switches aren't too bad, but memory locations 16-31 (the TTL Ram) you have to write a little program to load the code into there and you can't really check it.

It also outputs a URL which for Linux (yo !) and iMac (rich or what ?) users means you can write click on it and open the object code in the javascript version, in the same way the multiply example works. Windows users will have to cut and paste it into the browser bar.

However, the assembler does support the subroutine calls mechanism described earlier and the javascript emulator does not.

Friday, 13 July 2012

Javascript NRI832 now running

I now have a working 'classic' NRI832 emulator (see picture right). It looks the same as the earlier one, but this one actually works.

This is the display after running the multiplication example in the reference manuals.

You can try it out by visiting NRI832 Emulator - Multiplication - the code is loaded in via the query string.  It is calculating 5 x 7 which is 00100011 (35) as can be seen on the accumulator display.

To run it, press the 'Start' button. To change the run speed use the High / Low switch. To single step run it, set the Clock to 'Manual' and press the Step button.

To perform a different calculation put the two numbers you want to multiply into memory locations 11 and 12 using the toggle switches (blue), reset the computer, and press 'start' again


It is a peculiarity of the system that the Start / Step buttons only work when the Clock switch is on Auto / Manual respectively.

It works very similarly to the original (as far as I can tell from the manual). The main differences are that there are 32 'switches' to set program memory rather than 16 as on the original - and there is no disassembly column, obviously :)

The source code can also be downloaded (see the links on the right)

Note that this application now uses cookies - the current state of the memory / switches is stored in a cookie so that if  you refresh the page the current program is not lost.  Please see usual blather about cookies and privacy - the cookie in this application just stores a 64 character string representing the 'program memory'. 

Oh, and it also keeps all your bank account details and the location of all the valuables in your house, and the cookie will sneak out of the computer in the night and strangle you.