.net ADT "net list" help me!



  • I started writing a program that could do gate array logic style calculations and got completely stumped on how to represent the gate array components themselves. My original ADT was a "grid" that had pins that could be connected to inputs or outputs, and would keep track of what pins were outputs (as those could go to multiple inputs, but each input can only have 1 connection), and what the voltage value on each pin in the grid was. This doesn't seem abstract enough, or robust enough for what i need.

    On the grid i had "sections" that were partitioned into 8 bit areas that the algorithm could take the input pins, compare against a truth table, and then output to the appropriate bits in the last 4 bit positions.

    the problem with a linked list, or a hashtable for doing this is the multiple output routing - i suppose i could create a splitter 8 bit pattern that takes 1 bit input and outputs that on all four output pins, but this seems like a hassle for any implementer in the future.
    For reference i have included my kind of working framework here:

    Thanks, i'll be adding stuff as i think of it!



  • What does ADT stand for in this context?



  • abstract data type.



  • In actuality, this isn't even the part that stopped the production of this software, i have a utility class to convert chars to bit arrays and ints, and that class has too many bugs, so i want to scrap the design i am using and just pass only bitarrays around. I was being way too forward thinking in my programming, the char/int designators were there for "recipes", and to make the output files human readable. a single character is 8 bits, so that represents 4 inputs and 2 outputs (q and qBar) - with two extraneous bits.

    So anyhow, i was thinking a graph... Don't those have multiple inputs/outputs per node? like a directional graph.

    Oh and for my thought process on the algorithm, i figured every single truth table row is represented in an array, where the index is a row on the truth table - i needed a way to get the bit patterns for 0-7 (4 bits Look Up Table) - but evidently windows stores the bit patterns backwards (big endian) and the way i was processing everything was little endian (i think) - so i had to write a way to reverse endianness, and that just opened a huge can of worms. I very nearly scrapped the entire project to write it in C on linux.



  • Can you give a bit more info about the program?

     

    It sounds like it is for simulating a set of logic gates (AND, OR, NOT etc, maybe more complex things like MUX). I'm not sure exactly how your "grid" fits into it, but ill give a brief overview of how I would implement a logic gate "solver":

    Define classes for each type of gate, eg AndGate, OrGate, NotGate, etc, all extending abstract class LogicGate. The LogicGate class stores an "input" and "output" list of "pin" structures, as well as an evaluation status (i.e. have the inputs been analysed and the outputs set). The input list of pins are references to the output pins of another logic gate the gate is dependant on. You can thus represent the circuit as a dependancy diagram. The pins themselves record the LogicGate they are an output of, and a state. Each class extending LogicGate has an Evaluate method which creates the correct ouputs based on the inputs - you can implement this as IF statements, truth table lookups etc (or probably even "embed" a whole circuit of simple gates to represent something more complex like a mux).

    To "solve" the circuit (find the outputs given the inputs), simply recurse over all the logic gates, and evaluate them (provided any dependancies are already evaluated). See a quick naive implementation I made here: http://pastebin.com/2SMzuwZw (did it in C# but should be easily translatable to VB.net). Obviously this will break/go on forever if you make some kind of loop with the gate inputs/outputs, but you can add code to check for or prevent that.


     



  • @dr spock said:

    Can you give a bit more info about the program?

     

    It sounds like it is for simulating a set of logic gates (AND, OR, NOT etc, maybe more complex things like MUX). I'm not sure exactly how your "grid" fits into it, but ill give a brief overview of how I would implement a logic gate "solver":

    Yeah, it's a gate array simulator. I had a "pin" object, that i scrapped to use the grid which was an array of booleans. I like your thinking on this and it has helped.

    By the way, a Mux can still be represented as a truth table. I worked out many truth tables for testing when i was working on this program, and i'm going to look up dependency diagrams on google and possibly get started again. Thanks again.


Log in to reply