Introduction to Digital Logic and VHDL

by Zach Pezzementi and Joshua Hudner

Computer Architecture

Engin 25

Lab 1

Abstract

In this lab, VHDL and Altera's graphical editing tools were used to design a circuit similar to a greatly simplified CPU consisting of memory, an instruction register roughly corresponding to a CPU control unit, an accumulator capable of simple data manipulation like an ALU, a light register and reset button functioning as I/O devices, and a program counter similar to a memory address register. The circuit that was implemented loaded a set of instructions from a ROM and processed these instructions to manipulate a set of eight two-state lights.

Procedure

The implemented circuit is intended to take a word from the program memory, pass it to the instruction register, which then parses that word by distributing the appropriate bits to the program counter, accumulator, and light register. The bits received by the program counter determine which instruction in memory will next be executed. A set of bits is received by both the accumulator and the light register. In the accumulator, these bits are stored, and, depending on the selector bits also received from the instruction register, can be modified in a variety of ways before passing these bits on to the light register. The light register can accept input from either the instruction register or the accumulator, or load or invert its previous value, depending on the selector bits received from the instruction register. The output of the light register directly controls the lights.

Each major element of the circuit was designed and tested individually. Each element was designed in VHDL except for the light register, which was implemented graphically in Altera. A symbol was then created for each element, and they were connected to form the complete circuit in the graphic editor.

The initial design for the circuit contained four-bit registers to manipulate four lights. After this design was successfully tested, it was modified to use eight-bit registers and control eight lights. This modification required a four bit increase in the size of the instruction register and in each word of memory.

Our final design's instructions for the eight-bit model did 3 tasks. First, each light was lit sequentially until all eight were on. Next, the lights were reset to all off, and began counting in binary from 0 up to 128, at which point the conditional jump was activated. The circuit then began to count down indefinitely, looping back to 255 whenever it reached zero.

Problem-Solving

The biggest problem encountered was arranging the overall design in the graphical editor. The large number of wires and an unintuitive labeling scheme used by the symbol generator made it difficult to connect the proper outputs. Maintaining proper bit orders between separate VHDL entities was also difficult. Both problems, however, were manageable. The graphical design arrangement probably would have been greatly simplified by the extended use of vectors and buses instead of single-bit wires, but the syntax necessary was not known in the initial stages of work.

Testing

Each major circuit element was tested individually in the simulator, using each possible set of inputs. Any problems found in the elements at this point were corrected. No major problems were found, and all elements worked individually before being combined into the full circuit. The full circuit was then tested with different ROMs in the waveform editor, verifying that the elements worked together as expected. The final circuit design was loaded onto the board and tested in actual operation. After the four-bit model was in working order, the modification to an eight-bit model was made and tested on the board. Some minor difficulties connecting the proper inputs to the corresponding outputs were encountered, but these were sorted out. Both circuits are now fully functional.

Learning

We learned a lot of VHDL syntax and concepts, particularly the non-sequential nature of programs. The member of the group not initially familiar with digital logic concepts acquired a familiarity with basic logical systems. We also learned that it is not possible to watch a program execute at 25 MHz with the intention of gaining any information. As regards how the lab could be better, it would have been nice for the resulting behavior of the circuit had been more spectacular. Expanding the circuit to control eight lights helped a little, but was still anticlimactic. Having the boards in better condition would also improve the lab (obviously). Ours had a wire broken off in a light bank and a missing button.