# And16

7 messages
Open this post in threaded view
|

## And16

 To simplify test I start with And4 like this: CHIP And16 {     IN a[4], b[4];     OUT out[4];     PARTS:     And(a=a[0], b=b[0], out=out[0]);     And(a=a[1], b=b[1], out=out[1]);     And(a=a[2], b=b[2], out=out[2]);     And(a=a[3], b=b[3], out=out[3]);     } 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?
Open this post in threaded view
|

## Re: And16

 Ok, found out about the input - had to turn to binary. Stupid me. Is a more comprehensive specification possible? Like:     And(a=a[i], b=b[i], out[i]=out, for i=1..15)
Open this post in threaded view
|

## Re: And16

 Administrator Nope. 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.
Open this post in threaded view
|

## Re: And16

 Thank you WBahn. As I have lately studied programming (just for fun - I'm educated otherwise) I have learned to avoid repetitive code. So, just carried this habit into this study. Thank you, again, for your support - I appreciate very much
Open this post in threaded view
|

## Re: And16

 Administrator "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.