16 bit gates - is there a better way than copy-paste

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

16 bit gates - is there a better way than copy-paste

kesten
It seems that the limitation of not subscripting internal inputs/outputs causes me to do a lot of copy/paste of the same logic many times.

With sublime-text auto-increment indexing, it's not too painful
http://rricketts.com/add-auto-incrementing-number-selection-sublime-text-3/

But i'm wondering, is there a better way?  Is there a trick to reducing the amount of copy paste?  For example, my And16 is 16 lines of nearly identical work.  My register is 16 blocks of 3 lines each, all nearly identical.  Is this a limitation of HDL implementation or is this a limitation for real hardware description languages as well?
Reply | Threaded
Open this post in threaded view
|

Re: 16 bit gates - is there a better way than copy-paste

ybakos
It's a great question. The short answer is "no," because Hack HDL is pretty simple and explicit. So just roll with the repetitive HDL code.

I like to imagine the HDL as an explicit representation of the physical chip and its connections, which would involve those 16 physical wires.

Reply | Threaded
Open this post in threaded view
|

Re: 16 bit gates - is there a better way than copy-paste

cadet1620
Administrator
In reply to this post by kesten
kesten wrote
It seems that the limitation of not subscripting internal inputs/outputs causes me to do a lot of copy/paste of the same logic many times.

With sublime-text auto-increment indexing, it's not too painful
http://rricketts.com/add-auto-incrementing-number-selection-sublime-text-3/

But i'm wondering, is there a better way?  Is there a trick to reducing the amount of copy paste?  For example, my And16 is 16 lines of nearly identical work.  My register is 16 blocks of 3 lines each, all nearly identical.  Is this a limitation of HDL implementation or is this a limitation for real hardware description languages as well?
I wrote a quick and dirty preprocessor that replicates any line that contains a '*' not in a comment 16 times replacing all the '*'s with 0 through 15. This makes Not16 a one-liner:
    Not(in=in[*], out=out[*]);

There's also some syntax to allow limiting the replication and simple arithmetic so that it can handle things like the carry chain in the Add16 chip. See this post.

--Mark