free circuit simlator for logic gates ? - Page 1
Forum section: electronics / general

author: Jaunedeau
author_rank: Regular Contributor
timestamp: February 16, 2022, 07:15:38 am
content: Hi,I am trying to (re)learn things about how computers works. I've read a lot about adders, counters, logic gates, ... and I want to replicate some of the circuits in a simulator. I'm specialy interested in the "analog" part of digital circuit, i.e. how long signal takes to propagate and stabilise.Is there a free (if possible open source) tool you would recommand to visualise those ?I'm not interested in high precision, but rather in being able to understand e.g. what are the pro and cons a ripple counter vs a polynomial counter in a given application.Thank you,John.

author: Ian.M
author_rank: Super Contributor
timestamp: February 16, 2022, 08:33:12 am
content: Its *fugly* usingLTspicefor logic, but it has efficient digital primitives for simple gates up to five inputs, ordinary and Schmidt trigger buffers and inverters and D and SR flipflops. You can build more complex logic and use the result as a single component, either using hierarchical schematics, or if you've fully debugged it you can convert it to a subcircuit model. There's a lot of digital stuff for LTspice here:http://ltwiki.org/but its badly organized so Google is your friend. To give you an idea what's possible, nearly five years ago I posted a LTspice sim of a QEI (quadrature encoder interface) hardware state machine using 74HCT series logic:https://www.eevblog.com/forum/projects/quadrature-rotary-encoder/msg1291949/#msg1291949Hopefully you'll get some better, more user friendly suggestions for free mixed mode simulators. If not, there are a few traps and pitfalls when using LTspice for complex digital logic, so don't hesitate to ask for help.

author: RoGeorge
author_rank: Super Contributor
timestamp: February 16, 2022, 10:42:31 am
content: Quote from: Jaunedeau on February 16, 2022, 07:15:38 amThe thumb rule is a logic gate is seen as an ideal gate + a constant/specific delay. The delay depends with the technology used to implement that gate, then with other factors like the supply voltage, temperature, load and so on, depending of how much one needs to dive into the rabbit hole.For example, a discrete TTL gate from the 7400N (N means normal speed) can be assumed to have about 10ns propagation time, 6ns for fast one (74S00), etc. The exact numbers are to be found in the datasheets. Same for the FF (Flip-Flops), the propagation times between various input and output pins are specified in the datasheets (random search result):https://www.quora.com/What-is-the-propagation-delay-of-the-standard-TTL-chipYour question made me think you are in fact interested in synchronous vs. asynchronous digital design right now (regarding the timing issues), and how this leads to glitches and meta-stability in digital circuits.These are well studied in "digital design" classes, currently dealt with by always using synchronous logic instead of asynchronous. Even so, problems can still occur so more measures are used, for example Gray code instead of binary, clock domain crossing synchronizers, FIFO buffers, etc.You may want to search about "digital design" to learn more, thought all these details are not needed to understand how a computer works, unless you start designing your own CPU from scratch. I wouldn't spend too much time simulating glitches or metastability (those issues are usually sorted out by the chip designers - your CPU or RAM wouldn't work at all without fixing all the timing issues first). Instead, I'll recommend to focus mostly on the stable states of the logic circuits, their architecture, their function, and how a program is run and how the dataflow happens, in order to get a good understanding of how a computer works.Not sure if that material is still considered relevant today (I think it still is), but the first time when I really understood how a microprocessor (and implicitly a full computer) works was after I've read the original documentation for the AM2900 bitslice. That was the aha moment for me, when all the essential parts of a microprocessor were introduced one by one, and they clicked together, then the other components of a computer (like memory or peripherals) simply came naturally to complete the program counter and the ALU (Arithmetic Logic Unit).Quote from: Jaunedeau on February 16, 2022, 07:15:38 amThis is the kind of material I was talking about, see if it fits your needs:http://www.bitsavers.org/pdf/amd/ED2900A_vol1_Jan85.pdfhttp://www.bitsavers.org/pdf/amd/ED2900A_vol2_Jan85.pdf

author: Jaunedeau
author_rank: Regular Contributor
timestamp: February 16, 2022, 12:06:45 pm
content: thanksQuote from: RoGeorge on February 16, 2022, 10:42:31 amI fact, I'm writing a presentation aimed at (experienced but probably high level oriented) developers about "numbers representation" in memory. At some time I want to speak about the counters in the TIA (video chip of the Atari 2600, ...) and felt I need to understand why there was both a polynomial and a ripple counter for sprite positionning, so I'm now trying to simulate themQuoteI just took a quick look, but that seem wonderfull ^^ Out of what I should focus on for this presentation, but I will probably spent some time on it anyway, thx !

author: RoGeorge
author_rank: Super Contributor
timestamp: February 16, 2022, 01:36:13 pm
content: OK, totally misunderstood your needs.This video explains why the need for a polynomial counter (starting at 22m15s), but keep in mind that this one had to be areversiblepolynomial counter. A "normal" polynomial counter is usually used as a pseudo-random numbers generator, but it only counts one direction. His random numbers generator had to be reversible:https://youtu.be/MBT1OK6VAIU?t=1335I never studied the hardware of Atari 2600, so I don't know the details. The only computer I've designed was compatible with Sinclair ZXSpectrum and CP/M, which was already having a memory mapped video RAM, so no need to form on-the-fly graphic sprites from a ROM.I still don't see why the analog aspect would be important, and not sure why you put "analog" in quotes in the OP, probably it's something else that what I understand by analog simulation of a digital circuit, but I won't insist about it.To get on topic, QUCS is an open source simulator that can simulate digital circuits. Don't have it right now, I prefer QucsStudio, which is based on QUCS, but distributed as a Windows installer, thought it can run in Linux, too, through WineHQ. If you plan to install any of these, beware there are a few named almost the same, but different products:https://www.eevblog.com/forum/eda/qucs-qucs-s-and-qucsstudio-simulators-are-not-the-same-thing/QucsStudio can build diagrams like these, if of any help for your presentation:The attached .sch file is for QucsStudio (after unzipping it).Apart from the LTspice that is free but not open source, I thinkngspiceis a FOSS simulator (based on SPICE), don't have it installed right now either, but it should work for digital circuits, too. I prefer LTspice for its wider support and easier GUI (LTspice can be installed on *nix with WineHQ).By the title of your presentation, your audience should be comfortable with programming, maybe a few lines of code and a truth table would be good enough to simulate the counters:https://en.wikipedia.org/wiki/Linear-feedback_shift_register

author: Jaunedeau
author_rank: Regular Contributor
timestamp: February 16, 2022, 06:46:35 pm
content: Quote from: RoGeorge on February 16, 2022, 01:36:13 pmnot *completely*, I have both a target (the talk i'm writting), and a will (have fun and learn). You were on track for the latestQuotebecause simulating with cold 0 and 1 probably hide part of the real problems people who made the choices encountered. Things such as how long the signal needed to stabilise or propagate, oscillations, power consumption / heat dissipation... All those things I know nothing about, being a high level programmer.QuoteBecause I don't know a thing about analog electronic and probably missuse the word. (is leakage current or EMI part of it ? I don't even know)QuoteWill try themQuoteProbablyI want to see how interested I can get them to be in things they are not comfortable with though ^^Thank you again,John.

author: ledtester
author_rank: Super Contributor
timestamp: February 16, 2022, 06:51:17 pm
content: You might take a look at Microcap:Brochure:https://www.spectrum-soft.com/download/mc12_brochure.pdfWebsite:http://www.spectrum-soft.com/index.shtmNot open source, but it became free as in beer a couple of years ago.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 18, 2022, 03:42:22 am
content: I've done simulation with ngspice of transistor-level logic. Attached is a small library with a typical NMOS and PMOS from a 180nm process, to get you started, and my rendition of two logic gates (inverter and buffer) in the 74AUP series (with schmitt trigger inputs) using them. For anyone that could find it useful.