specific lines SR question

2007-03-24 Thread Eric Leenman

Hi,

In vhdl I create many times entity is like below:

entity HALFADDER is
port(
A, B  : in  bit;
SUM, CARRY: out bit);
end entity HALFADDER;

When I want to use this port into another bigger file
(for example a full-adder ) I need in VHDL to
create a component from it.

This then looks like

component HALFADDER
port(
A, B  : in  bit;
SUM, CARRY: out bit);
end component;

Notice that only the first line and the last line changes:

entity HALFADDER is
becomes
component HALFADDER

and

end HALFADDER;
becomes
end entity HALFADDER;

This entity to component changing happens rahter often.
Say that you copy the 5 lines of the entity and then
paste them where you want to use it as component.
Is it then easy to replace the first and last line of these 5 lines of 
entity code to 5 lines of component code by pressing i.e. F5?

If so how to do this?

Rgds,
Eric

_
It’s tax season, make sure to follow these few simple tips 
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=HMMartagline




Re: specific lines SR question

2007-03-24 Thread Tobia
Eric Leenman wrote:
 entity HALFADDER is
 port(
 A, B  : in  bit;
 SUM, CARRY: out bit);
 end entity HALFADDER;
 
 component HALFADDER
 port(
 A, B  : in  bit;
 SUM, CARRY: out bit);
 end component;
 
 Is it then easy to replace the first and last line of these 5 lines of
 entity code to 5 lines of component code by pressing i.e. F5?

Sure!
Here it is, based on your examples:

:map F5 j{/^entityCRcecomponentESC/ isCRD/^end 
entityCRwCcomponent;ESC0

It works when invoked inside the entity block or just before it.

Explanation (spaces added for clarity, literal spaces marked with ␣):

j { go down one line and up a paragraph (so that it
works inside the block or one line before it)
/^entity CR   go to the next 'entity' at the start of a line
ce component ESC  change that word to 'component'
/␣is CR   go to the ' is'
D   delete it (delete to the end of line)
/^end␣entity CR   go to the next 'end entity'
w   skip a word ('end')
C component; ESC  change the rest of the line to 'component;'
0   go back to the start of the line

Tune it as needed :-)


Tobia