Submodules

NSL supports hiearachical logic design. In NSL, we call lower layer modules as submodules. The interface of a submodule is described in 'declare' sentense. It will be consist of external terminals and optional arguments for control terminals. To declare instances of a submodule, we can declare at facility_declaration part as:

submodule_name instance_name ;

Each submodule terminal can be refered or transfered a value. The terminal name is refered as:

instance_name.terminal_name

To invoke a control terminal of the submodule, we can use following syntax:

instance_name.control_input_terminal_name () ;

There is a special syntax that invoke a control terminal and refer a output terminal of the submodule.

instance_name.control_input_termainal_name(arguments).output_terminal_name

You can use this syntax as a reference to a terminal. Now we will see an example that uses NS11.nsl as a submodule. In this example, we use three submodule instances of NS11.



Example-NS12

#include "../NS11/NS11.nsl" declare NS12 { input a[8],b[8],c[8],d[8]; output f[8]; func_in do(a,b,c,d); } module NS12 { NS11 mod1,mod2,mod3; func do { f = mod1.exec_add( mod2.exec_add(a,b).f, mod3.exec_add(c,d).f).f; } }



We will make a simulation on this circuitry as following command:

# ./exe NS12



The result will be available on your console.



a: 99, b: 9, c:129, d: 36, f: 17 a: 18, b:101, c:141, d: 13, f: 17 a: 61, b:118, c: 13, d: 1, f:193 a:198, b:249, c:140, d:237, f: 56



We will make a wave form on this circuitry as following command:

# ./exe -wave NS12








PREV UP NEXT