byuccl / digital_design_colab

Digital Design Colab Examples
5 stars 2 forks source link

Arithmetic Lab Simulation for 8-bit Adder using default negative numbers fails partway #69

Open tylerricks377 opened 11 months ago

tylerricks377 commented 11 months ago

The second simulation for the Arithmetic lab simulates a simple 8-bit adder. Running this simulation with the default code and default simulation input as is generates this error:

Compiling
###########################################################################################
b'Input (18446744073709551495) on line 8 too large. Expected 8 bit value.\nEnabling waves into logs/vlt_dump.vcd...\n'
  zero:
    co      : "▔▔▔╲▁▁▁▁▁▁▁▁▁▁▁"
  two:
    cin     : "▁▁▁▁▁▁▁▁▁▁▁▁╱▔▔"
    co      : "▁▁▁▁▁▁▁▁▁╱▔▔╲▁▁"
  three:
    co      : "▁▁▁╱▔▔╲▁▁╱▔▔╲▁▁"
  four:
    co      : "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"
  six:
    cin     : "▁▁▁▁▁▁╱▔▔▔▔▔╲▁▁"
...

and the simulation of all the signals prints only half-way from left to right. The values on line 8 are cin = 0, a = 100, and b = -121.

Taking out all the negative values in the simulation code area gets rid of this problem, and the entire simulation prints out normally, ex:

Compiling
###########################################################################################
b'Enabling waves into logs/vlt_dump.vcd...\n'
  zero:
    co      : "▔▔▔╲▁▁▁▁▁▁▁▁▁▁▁▁▁▁╱▔▔▔▔▔▔▔▔╲▁▁▁▁▁╱▔▔╲▁▁╱▔▔▔▔▔▔▔▔"
  two:
    cin     : "▁▁▁▁▁▁▁▁▁▁▁▁╱▔▔╲▁▁▁▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔▔▔▔╲▁▁▁▁▁╱▔▔"
    co      : "▁▁▁▁▁▁▁▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔"
  three:
    co      : "▁▁▁╱▔▔╲▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔╲▁▁╱▔▔╲▁▁╱▔▔╲▁▁▁▁▁▁▁▁╱▔▔"
  four:
    co      : "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁╱▔▔╲▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁╱▔▔"
  six:
    cin     : "▁▁▁▁▁▁╱▔▔▔▔▔╲▁▁╱▔▔╲▁▁▁▁▁▁▁▁▁▁▁╱▔▔▔▔▔╲▁▁╱▔▔╲▁▁▁▁▁"
...

Currently, the code is assuming the numbers in the simulation are all unsigned and not two's complement. The question I have is this: do we want to change all the default values in the simulation to be positive, or do we want to change the code to additionally calculate the number of bits needed for two's complement numbers on top of unsigned numbers?