Flexible 'alignment' function
Posted: Fri May 09, 2003 12:44 pm
When writing code/VHDL (I'm a hardware designer) it's imortant to make things neat and readable. Part of this can involve vertically aligning lists, or series of assignments.
An example....
port map(
wraddress => ram_wr_address,
data=> ram_din,
wren=> ram_1_wren,
wrclock=> clk,
wrclken=> enabled,
rdaddress => ram_rd_address,
rdclock=> clk,
rden=> enabled,
rdclken=> enabled,
q=> ram_1_dout
);
isn't nearly as easy to scan as
port map(
wraddress.....=> ram_wr_address,
data..............=> ram_din,
wren.............=> ram_1_wren,
wrclock.........=> clk,
wrclken.........=> enabled,
rdaddress.....=> ram_rd_address,
rdclock..........=> clk,
rden.............=> enabled,
rdclken.........=> enabled,
q..................=> ram_1_dout
);
(I've had to put in '.'s so the spaces aren't cut out, and this is badly aligned but I hope you get the jist)
...and these are two very short examples, with much longer lists it can take ages getting things tidy.
Prism (that I mentioned below) has an 'alignment' feature where you can select a block of text and what's being aligned ( => in the example above) and it simply right justify aligns all the examples to the one farthest to the right. The ability to select what's used for the alignment allows this function to be used in all sorts of situations.
This shouldn't be hard to implement, but can save a _lot_ of time.
Go on, you know you want it....
An example....
port map(
wraddress => ram_wr_address,
data=> ram_din,
wren=> ram_1_wren,
wrclock=> clk,
wrclken=> enabled,
rdaddress => ram_rd_address,
rdclock=> clk,
rden=> enabled,
rdclken=> enabled,
q=> ram_1_dout
);
isn't nearly as easy to scan as
port map(
wraddress.....=> ram_wr_address,
data..............=> ram_din,
wren.............=> ram_1_wren,
wrclock.........=> clk,
wrclken.........=> enabled,
rdaddress.....=> ram_rd_address,
rdclock..........=> clk,
rden.............=> enabled,
rdclken.........=> enabled,
q..................=> ram_1_dout
);
(I've had to put in '.'s so the spaces aren't cut out, and this is badly aligned but I hope you get the jist)
...and these are two very short examples, with much longer lists it can take ages getting things tidy.
Prism (that I mentioned below) has an 'alignment' feature where you can select a block of text and what's being aligned ( => in the example above) and it simply right justify aligns all the examples to the one farthest to the right. The ability to select what's used for the alignment allows this function to be used in all sorts of situations.
This shouldn't be hard to implement, but can save a _lot_ of time.
Go on, you know you want it....