


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















4-bit Full Adder, Using Dataflow Operators^ // Define a 4-bit full adder by using dataflowstatements.^ module fulladd4(sum, c_out, a, b, c_in);^ // I/O port declarations^ output [3:0] sum;^ output c_out;^ input[3:0] a, b;^ input c_in;^ // Specify the function of a full adder^ assign {c_out, sum} = a + b + c_in;^ endmodule
Procedural^ Blocks ย^ There are two structured procedurestatements in Verilog: always andinitial
initial Block^
always^ Block
Behavioral Block /P=wire/reg
O/P=reg
I
module stimulus; reg x,y, a, b, c; initial begin^ c=1โb0;^ #5^ a=1โb1;^ #25 b=1โb0; end initial begin^ #10 x=1โb0;^ #25 y=1โb1; end initial^ #50 $finish; endmodule
initial Block starts at time 0,executes only once during asimulation Multiple statements must be groupedusing the keywords begin and end.Incase^ of^ a^
single^ behavioral statement, grouping is not necessary.
module stimulus; reg x,y, a, b, c; initial Begin^ c = 1โb0;^ #5^ a=1โb1;^ #25 b=1โb0; end initial begin^ #10 x=1โb0;^ #25 y=1โb1; end initial^ #50 $finish; endmodule
Here we have three initial blockswhere each block starts to execute inparallel at time 0.Each^ Block^ finishes
its^ execution independent of each other.