Circuit Simulator Java

Circuit Simulator Java is an assignment which is designed to give you some experience in C programming. And also increasing your understanding of circuits.

You will be writing a C program to simulate the output of combinational circuits.

Electronic circuit simulation: uses mathematical models to replicate the behaviour of an actual electronic device or circuit. Simulation software allows for the modelling of circuit operation and is an invaluable analysis tool. Wikipedia

Circuit Simulator Java Description Directives


One of the inputs to your program will be a circuit description file that will describe a circuit using
various directives. We will now describe the various directives. The input variables used in the circuit are provided using the INPUTVAR directive. The INPUTVAR directive is followed by the number of input variables and the names of the input variables. All the input variables will be named with capitalized identifiers. An identifier consists of at least one character (A-Z) followed by a series of zero or many characters (A-Z) or digits (0-9).


For example, some identifiers are IN1, IN2, and IN3. An example specification of the inputs for a
circuit with three input variables: IN1, IN2, IN3 is as follows:
INPUTVAR 3 IN1 IN2 IN3


The outputs produced by the circuit are specified using the OUTPUTVAR directive. Moreover, the OUTPUTVAR directive is followed by the number of outputs and the names of the outputs. For example specification of the circuit with output OUT1 is as follows:
OUTPUTVAR 1 OUT1


The circuits used in this assignment will be built using the following building blocks: NOT, AND,
OR, NAND, NOR, XOR, XNOR, DECODER, and MULTIPLEXER. Further, these building blocks can use either the input variables, temporary variables, a boolean ’1’ or a ’0’ as input.

Circuit Simulator Java
Circuit Simulator Java

Describing Circuit Simulator Java using the Directives


It is possible to describe any combinational circuit using the above directives. For example, the circuit OUT1 = IN1.IN2 + IN1.IN3 can be described as follows:
INPUTVAR 3 IN1 IN2 IN3
OUTPUTVAR 1 OUT1
AND IN1 IN2 temp1
AND IN1 IN3 temp2
OR temp1 temp2 OUT1

Note that OUT1 is the output variable. IN1, IN2, and IN3 are input variables. temp1 and temp2
are temporary variables.


Here is another example:
INPUTVAR 4 IN1 IN2 IN3 IN4
OUTPUTVAR 1 OUT1
OR IN3 IN4 temp1
AND IN1 IN2 temp2
MULTIPLEXER 4 0 1 0 1 temp2 temp1 OUT1
As seen above, a circuit description is a sequence of directives. If every temporary variable occurs as an output variable in the sequence before occurring as an input variable, we say that the circuit description is sorted. You can assume that the circuit description files will be sorted.

Format of the Input Files

Example Execution 1
Suppose a circuit description file named circuit.txt has the description for the circuit

OUT1 = IN1.IN2 + IN1.IN3
Then the description file is as follows:

5
INPUTVAR 3 IN1 IN2 IN3
OUTPUTVAR 1 OUT1
AND IN1 IN2 temp1
AND IN1 IN3 temp2
OR temp1 temp2 OUT1
2
6
Then, on executing the program with the above circuit description file, your program should produce
the following output (one line for each input).
./first circuit.txt
0
1

Code For Circuit Simulator Java



READ MORE

Python-related posts Visit HERE

Data Structures related posts visit HERE

C/C++ related posts Visit HERE

Databases related posts Visit HERE

Algorithms related posts visit HERE

Data Science related posts visit HERE

Share the Knowledge