Verilog - Sequential Circuits
Verilog - Sequential Circuits
(ECE/EEE/INSTR F215 )
Verilog sequential
Prof. Anita Agrawal
16-11-23
Classes of signals
[ high#:low# ] or
[ low#:high# ]
reg [255:0] data1;
◉Starts at time 0.
initial
x= 1’b0; //single statement does not need to be grouped
initial
begin
#5 a=1’b1; // multiple statements need to be grouped
#20 b=2’b01;
end
initial
begin
#10 x=1’b1;
#20 y=1’b0;
end 16-Nov-23
Initial…..contd
initial
#50 $finish;
endmodule
16-Nov-23
always statement
◉ always @ (A or B or C)
will initiate execution if a change appears in A or
B or C.
◉In Procedural assignments, the value placed on a
variable will remain unchanged until another
procedural assignment updates the variable with a
different value.
◉Blocking (=)
◉Non-Blocking (<=)
◉B=A
◉ C = B+1
◉B<= A
◉C<=B+1
Blocking used in combinational (level sensitive) usually and non-blocking in edge triggering (concurrent)
Port declarations
module dff(q,d,clk,reset);
input d,clk,reset;
output q;
reg q;
always@(negedge clk)
if(reset)
q <=1'b0;
else
q <=d;
endmodule
module ringcounter(q,clk,clr);
input clk,clr;
output [3:0]q;
reg [3:0]q;
always @(negedge clk)
if(clr==1)
q<=4'b1000;
else
begin
q[3]<=q[0];
q[2]<=q[3];
q[1]<=q[2];
q[0]<=q[1];
end
endmodule