Skip to content

Commit

Permalink
Added 7408, 7432, and and 7486 chips
Browse files Browse the repository at this point in the history
  • Loading branch information
gaz20004 committed Oct 15, 2024
1 parent 85968c3 commit 72f12e6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion SDPPython/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def pin_configuration_json(self):

def send_pin_configuration(self, uart_port, baudrate=250000):
"""
Sends the pin configuration as a JSON string over UART.{"chip_number": "00", "logic_type": "NAND", "pin_count": 14, "description": "Quad 2-input NAND gate", "pins": {"1": "input", "2": "input", "3": "output", "4": "input", "5": "input", "6": "output", "7": "ground", "8": "output", "9": "input", "10": "input", "11": "output", "12": "input", "13": "input", "14": "VCC"}}
Sends the pin configuration as a JSON string over UART.
:param uart_port: The UART port (e.g., 'COM3' on Windows or '/dev/ttyUSB0' on Linux).
:param baudrate: The baudrate for UART communication.
Expand All @@ -96,9 +96,36 @@ def send_pin_configuration(self, uart_port, baudrate=250000):
print(f"Sent JSON data over UART: {json_data}")
def set_truth_table(self,outputs):
self.TruthTable=binary_number_list(self.inputn,outputs)

def print_truth_tale(self):
print(f"Chip: {self.chip_number}")
print(f"Logic type: {self.logic_type}")
print("INPUT BITS|OUTPUT BITS")
for entry in self.TruthTable:
print(f" {entry[0]} {entry[1]}")

def binary_number_list(bits,outputs):
list = []
for number in range(0,(2**bits)):
bitslist = separate_bits(number,bits)
list.append([bitslist,outputs[number]])
return list

def separate_bits(num, n):
bits = [(num >> i) & 1 for i in range(n)] # Extract each bit
return bits[::-1] # Return in correct order

def find_input_pins(ic):
n = ic.inputn

inputpins = []
temp = []
for pin in range(1,ic.pin_count+1):
print("PIN NUMBER IS: ", pin, ic.get_pin(pin))
if(ic.get_pin(pin) == "input"):
temp.append(pin)
if len(temp) == n:
inputpins.append(temp)
temp=[]
return inputpins
print("")

0 comments on commit 72f12e6

Please sign in to comment.