What is the best way to teach practical logic design? - Page 1
Forum section: electronics / beginners

author: AmmarKurd
author_rank: Contributor
timestamp: October 16, 2022, 10:07:20 am
content: I am about to teach a course on logic design for second-year mechatronics and third-year biomedical engineering, this course will have a practical side as well. I want to know what you think is the best way to learn experimental logic design.When I studied logic design we used a learning kit with 74 series ICs, do you think this is still a good way to learn, or is it outdated? I appreciate any advice on this topic.Thanks in advance.

author: bostonman
author_rank: Super Contributor
timestamp: October 16, 2022, 01:33:14 pm
content: I'd start with the basics what a 0 and 1 represent and why a computer uses them.After I'd go over basic gates (AND, OR, etc...) along with their associated truth table. Eventually do some basic binary math so you're teaching them the fundamentals of how a computer does math functions.A simulator would be a good visual too, but after a few lessons first.

author: tooki
author_rank: Super Contributor
timestamp: October 16, 2022, 02:19:35 pm
content: I’m in my last year of an electronics technician apprenticeship, and when we did logic, we did that all first with truth tables and such, and then in simulation software.

author: strawberry
author_rank: Super Contributor
timestamp: October 16, 2022, 02:49:51 pm
content: I think it should end with some interesting project otherwise it is just 0/1ttl cmos gates are outdated for consumer products indeed, because production cost is main and only goalMCU/CPU is not possible without logic gates

author: rstofer
author_rank: Super Contributor
timestamp: October 16, 2022, 03:11:57 pm
content: All the usual stuff including gates and the various flops plus the 74181-74182 ALU - the introductory stuff. Here's a video re: the 74181, there are others.https://youtu.be/xODcIY1Hg5wKarnaugh maps are vitally important.Some brief amount of time on Quine-McCluskey minimization.https://youtu.be/sKu2Yprsp4YState machines and reductionhttps://courses.cs.washington.edu/courses/cse370/09wi/LectureSlides/22-Minimization.pdfMost important: microcoding of FSMs and CPUsThere's a book for this level which ends up building a small 16 bit CPU. The book starts with gates and flops and winds up with microcoding.https://www.alibris.com/Introduction-to-Computing-Systems-From-Bits-and-Gates-to-C-C-Beyond-Yale-N-Patt/book/42539098The problem is, the book is now too expensive! I have both the 2d and 3d edition and I built the LC3 CPU from the 2d edition. I believe the 3d edition modifies the CPU to allow byte addressing - LC3b. It's important to pick either LC3 or LC3b when searchingThe appendices are online and they describe the entire machine and much of the implementation. Google for 'LC3 appendix'https://people.cs.georgetown.edu/~squier/Teaching/HardwareFundamentals/LC3-trunk/docs/LC3-uArch-PPappendC.pdfhttps://www.jmeiners.com/lc3-vm/supplies/lc3-isa.pdfI don't know how far you can get in one semester. It would be nice to touch on FPGAs because all of the techniques above are done by the software. Minimization is a lot less of an issue for the designer because a simple change doesn't require another dozen 74 series chips. It's almost certain that one-hot state encoding won't be done in TTL for machines with more than a few states. The state word gets too wide. Not a problem for an FPGA but difficult in discrete logic.Don't overlook the possibility of hanging some switches and LEDs on an Arduino and coding up some logic. Even state machines are easy to implement in C/C++

author: AmmarKurd
author_rank: Contributor
timestamp: October 16, 2022, 04:01:16 pm
content: Thank you all for your valuable feedback, I am more interested in what could be the best practical side of this course, the options I have are:1 - Simulation-based.2 - Use 74 series components to build circuits.3 - Go straight to microcontrollers or maybe Arduino.I know that practically speaking 74 series is outdated and mostly Microcontrollers, MCUs, and FPGAs are the way to go for a practical design, but what will be the best way to teach an introductory course on logic design?FPGA might be too advanced for someone learning what a truth table is, what do you think?

author: RoGeorge
author_rank: Super Contributor
timestamp: October 16, 2022, 04:20:17 pm
content: 1. meh, too abstract, do that only if hands-on learning is not possible, or as an alternative to practice (there are many online webpages that can simulate logic circuits, some with nice interactive/live GUI, e.g.https://logic.ly/demo/)2. yes, breadboards with switches and LEDs at first, then TTL or CMOS digital chips later, LEDs to visualize the outputs, hands-on is the second best way to consolidate any learning, bridges theory with practice (first best way of learning would be to teach to others the very same thing one is trying to learn, not applicable here)3. too much unrelated MCU details/bloatware, worst option IMHO

author: Fredderic
author_rank: Regular Contributor
timestamp: October 16, 2022, 06:01:47 pm
content: When I learnt this back in Uni, we spent a semester building most of a 6800-series processor in a simulator. (I think it was based on the 6802 specifically, but encouraging us to choose our own op-codes was a good way to spot cheating students.) Something roughly along the lines of:Starting with assembling an SR-Latch from gates in the simulator, and building it through the various kinds up to a D-Latch, then adding another 3, enough to latch data in, and through to some simulated LED's. (After that, we were allowed to upgrade our register to 8-bit, using D-Latch components. Partly to remove unnecessary complexity if we wanted, and partly to catch up struggling students who hadn't gotten theirs to work.)Then address decoding (again out of logic gates), a small ROM (address decoding into a grid of wires, where we placed diodes to make a 1), followed by a few bytes of RAM (this time address decoding into 8-bit D-Latch components), and manually clocking data between ROM, register, RAM, and through to the LED's. (We were then allowed to upgrade it all to 8-bit D-Latch components.)Add a simple ALU and another register, so now we can move bytes of ROM into the registers, through the ALU, store them in RAM, repeat with another operator, then again taking the values we'd just computed and stored in RAM back through the ALU, and presenting the final result on the LED's. (Basically just add, sub, the logic functions, stuff like that.)Followed by decode logic that takes a manually entered op-code and drives the control lines for you, for the couple simple instructions to exercise the hardware built so far, then adding instruction and instruction pointer registers, allowing an actual simple linear program to be loaded into the ROM (which was also upgraded to a simulated ROM chip with more room, and so we didn't have to manually place all those diodes to set each bit of ROM individually).Finally replacing our register RAM with a RAM component, and attaching a simulated terminal output and a keypad input interface with memory-mapped IO, fleshing out the ALU (including the flags register), and the instruction set a bit more (like conditional jumps using those flags), finally culminating in writing a small program that actually does something, on our own 6800 compatible processor design, running our own microcode and decode logic.In the process, we hit all the things rstofer mentioned, had a working (if simulated) thing out of all that "logic stuff", and gained a very good idea of what was going on within those computer things. (Arduino wasn't yet a thing, though…) But I credit that grounding for never having struggled with bit twiddling and several other topics that I find myself having to help a lot of aspiring coders with.For my particular course, I also did some other parallel subjects that tied in rather well; exploring caching, RISC architectures, and other modern processor ideas, writing a 6800 assembler and emulator pair, and around the middle of our analog electronics subject we were building logic gates out of transistors. So those of us doing that particular course, ended up being able to write a simple program in assembler, assemble and emulate it on our own hand-written assembler, load the binary output into the ROM of our own simulated processor (had to adjust one or the other, since though we were making real 68xx instructions, we weren't actually told that, and were encouraged to choose our own opcodes), and see the output on the simulated terminal device (and that it matches what our simulator produced for the same program), knowing it's all built from gates, and that we know how to build those gates in transistors. And with the ASIC subject later on I'd have been able to translated it all the way into silicon, too.

author: Benta
author_rank: Super Contributor
timestamp: October 16, 2022, 07:02:08 pm
content: I think most posters missed the point "second-year mechatronics" and went straight to their hobby horse.We're talking mechanics, hydraulics, electrics, electronics and diagnostics here. In the second year.The only poster I can agree with is @bostonman.The knee-jerk reaction "throw an Arduino at it" I don't understand at all. There are plenty of designs being done with 74HC, 74AHC, 74AC etc.

author: tooki
author_rank: Super Contributor
timestamp: October 16, 2022, 07:33:41 pm
content: Quote from: AmmarKurd on October 16, 2022, 04:01:16 pm74 series is far from dead. TI even introduced a new 74 logic family (HCS) in 2019!What we certainly no longer see are large circuits made of discrete logic. But they’re still widely used as “glue” and as level shifters, etc. What have become quite popular are single-gate devices in small packages like SOT-23 and smaller. Perfect when you need a quick inverter or to AND or OR a few lines.

author: exmadscientist
author_rank: Frequent Contributor
timestamp: October 16, 2022, 08:24:23 pm
content: I have taught this exact type of student before and it is not so easy. These are not EE or CS people who need to know this stuff to understand their own jobs. These are people who will be either using it as an end to achieve entirely separate goals or who will be doing archaeology on an ancient device to fix it/repurpose it/get one more publication out of it.74 series MSI etc is dead and you can and should forget about it, at least at this level.In my opinion the best flow is:Transistors as switches. Don't assume they know or remember this stuff. Spend a lesson explaining what transistors are and what they do. Do not spend much time on this.Mentionthat they also work as linear amplifiers (and that it's exactly the same parts and same math, you're just overdriving them to get clean switching), but say that's for another class, and only talk about them as switches.Logic gates. Get them comfortable with NOT, AND, NAND, OR, NOR, XOR. They should know why NAND and NOR are special. Show a few gates built from transistors. A few words on memory cells would be great if you have time, but don't test them on this. Just show that they exist and they're not hard if you have the other basics down.Gate circuits. Build a few full adders and such. Maybe even go up to a decade counter. This is a great stopping point because it hints at useful things but is itself not too complex. If you have time (and energy), the next step of building a clock or clock-like thing is also neat, but I think it doesn't usually pay off as well for the time invested.Jump to... CPUs. Now they see how to build math-y circuits. Describe, briefly (in a half lecture or so), how to make a CPU core. Instruction stream, instruction bus, data bus, load-execute-store. The idea is less that they understand and remember, and more that they see it as a perfectly natural and easy thing to build using the basic gate stuff they have hopefully learned by now. Do not spend much time on this, and do not test it heavily. Instead, jump to...Microcontrollers. This should be the bulk of the course, probably half or even more. Because they're going to use microcontrollers for everything they do in their actual existence as mechatronics/bioengineering students. They should know by now what a MCU is, where it came from, and what it can do. Toss a few words at them to get them from assembly/C to something higher level like Arudino or MicroPython or whatever you favor, and then spend the rest of your time there. This is the right level for these people and they will get a lot of benefit out of it.ADCs. Most of them will be doing some signal conversion. A lecture or two about ADCs will go a long way, especially if you are practically oriented and spend less time about theoretical ADCs and more about what to do and not do to get good results out of one.IMO your job is done if they can, after the course, identify a microcontroller on a schematic (in detail!), identify and be comfortable with the various glue logic that keeps it happy, and can write some useful code for it.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: October 16, 2022, 09:22:50 pm
content: The computer game Robot Odyssey. There's a Java prot that runs best on modern hardware.

author: Benta
author_rank: Super Contributor
timestamp: October 16, 2022, 10:52:32 pm
content: Quote from: JustMeHere on October 16, 2022, 09:22:50 pmDid you by mistake post on the wrong forum? You can still "Remove".

author: MathWizard
author_rank: Super Contributor
timestamp: October 17, 2022, 01:43:47 am
content: Lately I made a astable multi-vibrator clock, an SR-latch, iirc a JK-latch, and a few other things from pullup-resistor/open collector logic, all 10k's and 100k's except a few 1k's. Combined with a binary counter / period doubler, I did a few things like trigger of a number, so you can time or count up to stuff. That was pretty cool.Then in LTSpice w/ transistors, I made a calculator that could add/subtract +/- numbers. And multiply 3d*3d before I gave up.And wow does the transistor count start going up.I bought a 50x10LED blocks for future breadboard computer type projects. And a pile of BC547/557's. Now if only common logic chips were a lot cheaper.

author: MrAl
author_rank: Super Contributor
timestamp: October 17, 2022, 09:58:28 am
content: In a camel back word, BooleanAlgebra.

author: rstofer
author_rank: Super Contributor
timestamp: October 17, 2022, 01:10:15 pm
content: In terms of mechatronics, the topics would include microcontrollers and IO peripherals (UART, I2C, SPI, GPIO, PWM) both in terms of the hardware and software. This would include time with the datasheets and other documentation.Then the external devices such as ultrasonic distance sensors, H-bridges, stepper drivers and any other sensors that seem relevant.Writing code for all of this in C/C++, microPython (where applicable) and this could apply to the Arduino, Raspberry Pi and now the Raspberry Pi Pico. The Pi Pico has the advantage of being programmable with C/C++ and microPython and is quite inexpensive. The Pi Pico W adds WiFi and it particularly easy to use.I would be all over the computer vision projects with the Pi Pico W - Google search 'pi pico computer vision'https://mjrobot.org/2021/03/12/tinyml-motion-recognition-using-raspberry-pi-pico/Mechatronics is a vast field with plenty of real-world industrial applications.

author: rstofer
author_rank: Super Contributor
timestamp: October 17, 2022, 02:55:04 pm
content: Quote from: AmmarKurd on October 16, 2022, 04:01:16 pmOther than the constraints file, the rest of FPGA programming flows nicely from logic expressions and FSM state tables. There are just a few constructs to understand (selector, multiplexor, logic expressions and FSMs) and everything builds from there. Either of these boards would be excellent for a logic design course with an FPGAhttps://digilent.com/shop/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users/https://digilent.com/shop/nexys-a7-fpga-trainer-board-recommended-for-ece-curriculum/<-- my favoriteThere are many other boards available at a MUCH lower cost. The thing I look for is buttons, LEDs, Displays and switches. It is quite simple to demonstrate logic expressions on an FPGA. In fact, given 16 switches and 16 LEDs, several expressions could be generated at the same time.I suppose the student could write code for a less than optimal expression, reduce it with a Karnaugh map and add code for the optimized expression and compare the outputs on LEDs. That's still faster than wiring up a bunch of 74xx gates. And once they get to flops, the FPGA shines. By definition, FPGAs use D-flops and the student is left to figure out how to create a J-K flop. There is also a library with J-K flops. Unclocked latches are highly discouraged.The cool thing about FPGAs is the small effort required to add a 32 bit register compared to the amount of wire-wrapping required for 7474 devices. One line of code and it exists, another few lines of code to clock it and set values. I love FPGAs!The key topic is combinatorial logic versus sequential logic. Once the student truly understands FSMs, they are on their way to building just about anything with an FPGA. That's why I like the LC3 project, the state transition diagram is given, just code up the state actions and the CPU is just about done. Yes, there are several other components to code up but they are pretty easy.I would hand out the constraints file and tell the students to name their HDL signals to match. Or, they can try to figure it out for themselves.The problem with FPGAs is cost and availability. It is possible to write state machines in any computer language so there is no reason not to use the Pi Pico W with some switches and LEDs and the logic in microPython. Obviously, the C 'switch' statement is key.Here are the first few states for LC3 and if you look in Appendix C you will see how it matchesCode:case State iswhen 0 => -- Branch Instructionif BEN = '1' thenNextState <= 22; -- branch is takenelseNextState <= 18; -- branch not takenend if;when 1 => -- ADD Instructionif Immediate = '1' thenSR2select <= Sext5sel;elseSR2select <= SR2outSel;end if;ALUop <= ALUadd;GateBusSelect <= GateALU;LD_Reg <= '1';LD_CC <= '1';NextState <= 18;when 2 => -- LD InstructionAddr1Select <= Addr1PC;Addr2Select <= Addr2Sext9;MARselect <= MARadder;GateBusSelect <= GateMARmux;LD_MAR <= '1';NextState <= 25;when 3 => -- ST InstructionAddr1Select <= Addr1PC;Addr2Select <= Addr2Sext9;MARselect <= MARadder;GateBusSelect <= GateMARmux;LD_MAR <= '1';NextState <= 23;when 4 => -- JSR Instructionif IR(11) = '1' thenNextState <= 21;elseNextState <= 20;end if;How easy is that? Just follow along from the state transition diagram. Figure C-2https://people.cs.georgetown.edu/~squier/Teaching/HardwareFundamentals/LC3-trunk/docs/LC3-uArch-PPappendC.pdfOne key point: Every signal needs to be defined in every state or latches will be generated. As a result, there are a LOT of default assignment statements in the process:Code:process(State, BEN, IR,MemReady, Immediate, PSR, Interrupt)begin-- set default values for all signalsGateBusSelect <= GatePC;MIOenable <= '0';LD_MAR <= '0';...

author: strawberry
author_rank: Super Contributor
timestamp: October 17, 2022, 03:47:17 pm
content: Arduino GPIO shematic . easier to understand what this peripheral really doArduino language is for kids to begin some hardware programming

author: fourfathom
author_rank: Super Contributor
timestamp: October 17, 2022, 04:45:31 pm
content: What happened to designing a simple traffic-light controller with logic gates (probably use the HC74xx or 74LVC series or similar)? This gets you Boolean logic, Karnaugh maps, and state machines, as well as hands-on experience. You know, the basics.Trying to design an ALU isn't perhaps the best task for an introductory course...After this, you might introduce Verilog/VHDL. and perhaps map that traffic-light design and show how to simulate.

author: strawberry
author_rank: Super Contributor
timestamp: October 17, 2022, 04:50:35 pm
content: ALU can be a calculator