Sed command to create a verilog blackbox

I recently had to create black boxes for 28 verilog modules. I could have done it manually, but thought of using some sed scripting, and it sure got done in a flash.

This is the sed command I used.

sed -i".bak" -n -e '/module/p' -e '/output/p' -e '/input/p' bb.v

where bb.v is the blackbox file.

In my case, I had already created copies of my verilog.v file as bb.v, and I then went about editing the bb.v files. One can also perform the copying and editing in a single step as follows

sed -n -e '/module/p' -e '/output/p' -e '/input/p' verilog.v > bb.v



switch is a way of telling sed that the substitution. printing, deletion have to be done in-place

Sed command to create a verilog blackbox

For loop in csh, tcsh

CSH has a for loop. The syntax of the loop is as follows

> foreach i (1,2,3,4,5)

Another flavor of the foreach loop is when one wants to perform the same action on a set of files in a directory, or a set of sub-directories in a directory

Below is an example of copying a file verilog.v to bb.v in each of the sub-directories in the present directory

foreach fn ( `ls` )
  if (-d $fn) then
    cp $fn/Verilog/verilog.v $fn/Verilog/bb.v
For loop in csh, tcsh