WOLFRAM SYSTEM MODELER
EightBitAdderExampleExample setup of an 8-bit Adder component with integer input varying over time. |
SystemModel["EducationExamples.ElectricalEngineering.EightBitAdder.EightBitAdderExample"]
Binary adders are digital circuits often used in computers for basic arithmetic operations. Using the digital package in the standard Modelica library, an 8-bit adder has been constructed that takes two 8-bit integers and calculates their sum.
The 8-bit adder model consists of eight 1-bit adders connected together in a series. The least significant bit of input a will be added together with the least significant bit of input b in the full adder located furthest to the right. Depending on the input, the adder will produce a 1-bit sum value that is the least significant bit of the result, as well as a 1-bit carry, which is sent to the next adder in the series. This is repeated in eight steps until 8 bits of output have been produced, as well as a possible carry-out signal.
The input to the calculator is varied using IntegerTable from the Modelica Standard Library. For each set of integers, the sum is calculated and simulated.
To simulate the model, click the Simulate button in the top toolbar:
When you run the simulation you will see the Sum and bit 0 Model plot:
The plot displays the input and output from the adder converted to a real number, as well as the input states of the first bit.
tableA |
Value: {21, 27, 31, 20, 17, 30, 22, 17, 29, 35} Type: Integer[:] Description: Table of integers to add together with table B |
---|---|
tableB |
Value: {50, 55, 49, 42, 56, 53, 59, 52, 47, 48} Type: Integer[:] Description: Table of integers to add together with table A |
eightBitAdder |
Type: Adder Description: Component that sums integers A and B together. |
|
---|---|---|
integer_table_a |
Type: IntegerTable Description: Value at position A to be summed. |
|
integer_table_b |
Type: IntegerTable Description: Value at position B to be summed. |