Goals

  • Learn about circuits.

  • Learn about event-driven simulation.

  • See a typical use for a queue.

  • Learn about organizing and coding a medium size program.

  • Checking your work and hints

  • Significant hints are available here. Novices will definitely want to use these to get started.

  • The directory /u/cs126/files/circuit/ contains a number of circuit data files (.txt extension) that you can use to test out your program. Note that buzzer.txt describes a sequential circuit that never "settles down" - set the input to 1, then to 0 and watch what happens!

  • You can use the program circuit126 to check your work.

  • You program may assume that the maximum number of gates is 128, and that the maximum number of outputs for any one gate is 16.

  • Submission and readme
  • Use the following submit command:
    submit126 6 readme simulator.c .....
    
    We require that the main() function be located in simulator.c, but you can also submit auxiliary files as needed. Submit all source and header files needed to compile your program (including any that we supply in the hints page). We will compile your program with the following command:
    gcc126 *.c
    

  • The input of your program should be exactly as described in the assignment. Your program will be tested automatically, so deviating from these instructions will result in a significant penalty.

  • The circuit description will be read from a file corresponding to the command line input.

  • The values of the circuit inputs will be read in from standard input, and the values will either be 0 or 1.

  • After each simulation, the user enters 'q' to quit the program, and any other letter to continue.
  • The readme file should contain the following information. Here is a template readme file:

  • Name, precept number, high level description of code, any problems encountered, and whatever help (if any) your received.

  • Extra credit

  • Create a data file (in the given format) for an interesting circuit, perhaps one from the course packet. Give it an appropriate name, e.g., 8bitadder.txt or master-slave.txt.

  • Write a program that reads in a circuit and determines whether or not it is a combinational circuit. If it is, then it should print a truth table of the combinational circuit.
    % a.out majority3way.txt
    x y z  f
    --------
    0 0 0  0
    0 0 1  0
    0 1 0  0
    0 1 1  1
    1 0 0  0
    1 0 1  1
    1 1 0  1
    1 1 1  1
    
    % a.out srflipflop.txt
    Not a combinational circuit.
    
    % a.out buzzer.txt
    Not a combinational circuit.
    
    Important: The main() function must be located in the file extra.c. We will compile your program with the command gcc126 *.c, after removing the file simulator.c.



  • Kevin Wayne