Hierarchy- Nested Modules
A module can be declared within another module. The outer name space is visible to the inner module, so that any name declared there can be used, unless hidden by a local name, provided the module is declared and instantiated in the same scope.
module first_counter (clock ,reset ,enable ,counter_out );
module ports()
input clock ;
input reset ;
input enable ;
output [3:0] counter_out ;
wire clock ;
wire reset ;
wire enable ;
reg [3:0] counter_out ;
endmodule
always @ (posedge clock)
begin : COUNTER // Block Name
if (reset == 1'b1) begin
counter_out <= #1 4'b0000;
end
else if (enable == 1'b1) begin
counter_out <= #1 counter_out + 1;
end
end
endmodule
module first_counter_tb();
reg clock, reset, enable;
wire [3:0] counter_out;
module functionality ()
initial begin
$display ("time\t clk reset enable counter");
$monitor ("%g\t %b %b %b %b", $time, clock, reset, enable, counter_out);
clock = 1; // initial value of clock
reset = 1; // initial value of reset
enable = 1; // initial value of enable
#5 reset = 1; // Assert the reset
#10 reset = 0; // De-assert the reset
#10 enable = 1; // Assert enable
#100 enable = 0; // De-assert enable
endmodule
#5 $finish; // Terminate simulation
end
always begin
#5 clock = ~clock; // Toggle clock every 5 ticks
end
first_counter U_counter (
clock,
reset,
enable,
counter_out
);
endmodule
This blog contains all the information, latest technologies in VLSI and interview questions for freshers
Subscribe to:
Post Comments (Atom)
Popular Posts
-
http://www.mediafire.com/?n77dan3ovdwyoy3 http://www.mediafire.com/?8ncruxr37o1dbqb http://www.mediafire.com/?jqhvobf6j4gbp6e ...
-
Verilog code for an 8-bit shift-left register with a positive-edge clock, serial in and serial out. module shift (clk, si, so);...
-
Verilog code for a 4-bit unsigned up counter with asynchronous clear. module counter (clk, clr, q); input ...
-
seminar topics with ppts if u need any topics below mail me: bsnspkumar_484@yahoo.co.in Analysis of the Performance of DOA Algorithms in sma...
-
ECE Seminar topics These are the seminar topics based on Electronics and Communications. If u need abstracts of the below seminar topics u c...
-
// memory module `timescale 1ns/1ns module ram(wr_ad,rd_ad,wr_en,rd_en,clk,wr_dat,rd_dat); //parameter addr_width=4; //parameter depth=16; /...
-
Verilog code for single-port RAM in read-first mode. module raminfr (clk, en, we, addr, di, do); input clk; input ...
-
If inverted output of D flip-flop is connected to its input how the flip-flop behaves? Design a circuit to divide input frequency by 2...
-
Synthesizeable constructs and VHDL templates VHDL is frequently used for two different goals: simulation of electronic designs and synthesis...
-
http://www.mediafire.com/?h1bj9w1bx8kja69 http://www.mediafire.com/?yot1d4b0u344lmc http://www.mediafire.com/?hzqj1m6j91mg9td http://ww...
No comments:
Post a Comment