How to simplify repetitive pin assignments?

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

How to simplify repetitive pin assignments?

kj0
In my RAMxxx.hdl code, I would *like* to write specs like

    RAMxxx(..., address=address[3..n], ...);

...but this syntax is illegal, so I must settle for

    RAMxxx(..., address[0]=address[3], address[1]=addess[4], address[2]=address[5], ... );

These chains of 1-bit pin assignments get longer and longer as the size of the chip increases, and they make the code unnecessarily bloated, IMO.

Is there a way to simplify this code?  For example, is there some way to assign input pins address[3..n] to some variable v, so that I can write

    RAMxxx(..., address=v, ...);

?

Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: How to simplify repetitive pin assignments?

cadet1620
Administrator
There isn't any way to do "assignments" like you want with "v".

Your long chain of address[]=... can be written shorter, however.  Instead of
    address[0]=address[3], address[1]=addess[4], address[2]=address[5]
you can write
    address[0..2]=address[3..5]

What RAM part are you working on what RAM part are you using to make it?

In general, if the sub-part is 1/8 the size of the part you are making, you should be able to use assignments like this
CHIP RAM64 {

    IN in[16], load, address[6];
    OUT out[16];

    PARTS:
        ...
        RAM8(address=address[3..5], ...);

--Mark
   
kj0
Reply | Threaded
Open this post in threaded view
|

Re: How to simplify repetitive pin assignments?

kj0
@Mark: thanks!

At some point I got an error when I tried the syntax

    foo=bar[x..y]


...but now I realize that the reason for the error was that bar was an *internal* pin.  The address pin (to the right of the `=`) in my original question is not an internal pin, so no error.