2 modules

P

pat

Guest
i have 2 modules.
one i call 'main'
one is called 'counter' which is instantiated in main.

main has...
clk input
counter_input
[7:0] output

counter has...
clk input
counter output

(i am using xilinx web pack verilog design (not schematic design)

i instantiate counter in main sending it clk only. inside counter i
have always @(posedge clk) counter <= counter + 1;

in main, i...
also have the same clk.
what i am looking to do is have the output of counter go into the input
of main.

i tried wire, assign and a bunch of other stuff.

this is what i am thinking
1. counter and main are in sink cause they use the same clk.
2. is my counter value lost when i go out of instantiated counter?
3. if need be i can cut/paste my two modules

thanks
 
pat,

What do you want to accomplish? Is your confusion on how to interface two
modules? If so, you need to either instantiate one module in the other (
like calling a subroutine from within a root C program called "main") or you
need to instantiate both module in another top module. The counter module
can have an "output [7:0] counter;" and a "reg [7:0] counter;" which will
make the clocked counter value available to the Verilog module that
instantiated the counter module.

Typically there is much more to a module than just a counter but many
engineers use small, proven modules for their own reasons.


"pat" <me@here.com> wrote in message
news:pan.2004.09.08.01.16.41.305429@here.com...
i have 2 modules.
one i call 'main'
one is called 'counter' which is instantiated in main.

main has...
clk input
counter_input
[7:0] output

counter has...
clk input
counter output

(i am using xilinx web pack verilog design (not schematic design)

i instantiate counter in main sending it clk only. inside counter i
have always @(posedge clk) counter <= counter + 1;

in main, i...
also have the same clk.
what i am looking to do is have the output of counter go into the input
of main.

i tried wire, assign and a bunch of other stuff.

this is what i am thinking
1. counter and main are in sink cause they use the same clk.
2. is my counter value lost when i go out of instantiated counter?
3. if need be i can cut/paste my two modules

thanks
 

Welcome to EDABoard.com

Sponsor

Back
Top