It works - in the sense it compiles and run without errors.
But I'm still perplexed:
I expect the two input to be list like "1101" and "0101" - but not matter my input the simulator turns it to "1". Output also becomes a single bit.
Can someone explain?
Next question: Is this really the simplest way to specify And16? 16 lines of highly repetitive code. Can I use some kind of loop here?
Keep in mind that this is a very simple simulator with no bells and whistles. It was written by a grad student of one of the authors. Since it's only needed for five chapters worth of work, it's not too bad to deal with its limitations.
"Real" HDL languages, such as VHDL and Verilog, have lots of syntactic sugar that allow you to avoid repetition. But those languages and the simulators that support them were professionally developed over many years by significant teams of people. This simulator was developed by one or two people over the course of a semester or so. Also, there's a noticeable learning curve with other HDLs in order to get the equivalent of "Hello World" up and running, whereas with this one you know almost everything you need to know to use it within about ten minutes (there's some tricks regarding sub-busing that take a bit longer to wrap your head around).
I'm very curious to see what changes have been made to the HDL for the Second Edition of the text.
As a useful exercise you might consider devising your own HDL and then writing a program/script to take that code and generate code for this HDL. If you were actually using this HDL for some amount of time, that would pay for itself very handsomely. In this case, there's no efficiency payoff, but you'll improve your programming skills quite a bit. Plus, there's a good chance that you will gain an appreciation for why this HDL has some of the limitations that it does.
Actually, I just started such a project - not yet finished.
Using Python and Pygame my plan is to make a small library of basic gates that I can move to the screen. Then add connections between the gates and make input(s) on/of.
All with relevant graphics.
The idea is to simulate the function/output by animating current flow - i.e. adding a very slow clock that advance in steps even along a conductor.
I may introduce resistors and capacitors as well as they are important for timing/wait sequences.
It will be able to handle only quite simple circuits, but I like the graphical element.
I'm also currently building small computer parts on breadboards - eventually ending up in a working 8-bit computer. So far I have made an adder, a register, a clock module and some minor demo parts. Now summer is approaching so I'll probably postpone until autumn - soon it is time for sailing and gardening.