verilog HDL problem

Jun 07, 2007 1 Replies

what is the error in the following code. in it the main module is "test". in that module's "always" block another module "counter" is called. but it shows error. how can i solve the problem? how can i call another module in always block?


module counter(clock, reset, count); input clock, reset; output [3:0] count;



reg [3:0] next_count,count;



always@* begin if(count


Hi there, First of all, there is a newsgroup for Verilog discussions: comp.lang.verilog (and I noticed that you just post your question there as well).

You cannot put a module in a process that only execute at clock edge. Try think that the counter module is a hardware, and you can't make it appear only at clock edge, it exist in the design all the time. So instead of putting it in a process, you should instantiate it.

module test(clock,reset,count); input clock, reset; output [3:0] count; // reg [3:0] count; // This line is removed because // it is not controlled by a process.

// Instantiate counter counter counter1(clock, reset, count);

endmodule

If you want to do a number of processing inside a process, you could use "function". Google "Verilog" and "function" should come up with lots of examples.

Hope this help.

regards, Joseph

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required