state=2'b00; outp=0; end 2'b01:if(inp) begin state=2'b01; outp=0; end else begin state=2'b10; outp=0; end 2'b10:if(inp) begin state=2'b11; outp=0; end else begin state=2'b00; outp=0; end 2'b11:if(inp) begin state=2'b01; outp=1;
end else begin state=2'b10; outp=0; end default: begin state=2'b00; outp=0; end endcase end endmodule
Test bench:
module fsmsd_tb; reg clk,rst,inp; wire outp; reg [15:0] sequences; integer i; fsmmealy1011 test(clk,rst,inp,outp); initial begin clk=0; rst=1; i=0; sequences=16'b1010101110111001;
Result: A 1011 sequence detector using mealy type state machine has been designed and verified
using verilog.
Signal flow:
3'b001:if(inp) begin state=3'b001; outp=0; end else begin state=3'b010; outp=0; end 3'b010:if(inp) begin state=3'b011; outp=0; end else begin state=3'b000; outp=0; end 3'b011:if(inp) begin state=3'b100; outp=0; end else begin
state=3'b010; outp=0; end 3'b100:if(inp) begin state=3'b001; outp=1; end else begin state=3'b011; outp=1; end default: begin state=3'b000; outp=0; end endcase end endmodule
Test bench:
module fsmmoore_tb; reg clk,rst,inp; wire outp; reg [15:0] sequences; integer i;
fsmmoore1011 test(clk,rst,inp,outp); initial begin clk=0; rst=1; i=0; sequences=16'b1010101110111001; #5 rst=0; while(i<=15) begin inp=sequences[i]; #2 clk=1;#2 clk=0;i=i+1; end end endmodule
Result: A 1011 sequence detector using moore type state machine has been designed and verified
using verilog.
Signal flow:
Test bench:
module tb; reg clk,reset; wire [3:0]Y; upcounter pav(clk,reset,Y); initial begin {clk,reset}=0; end
Result:A 4-bit synchronous up counter has been designed and verified using verilog. Signal Flow:
endmodule
Result:A 4-bit synchronous down counter has been designed and verified using verilog. Signal Flow:
Test bench:
module realizationSOP_tb; reg [3:0]X; wire Y; realizationSOP tb(X,Y); initial X=4'b0000; always begin X=X+1;
Result: The given 4 variable SOP boolean function has been realized using verilog. Signal Flow:
Test bench:
realizationPOS tb(X,Y); initial X=4'b0000; always begin X=X+1; #100; end endmodule
Result: The given 4 variable POS boolean function has been realized using verilog. Signal Flow:
Aim:To design an 8X1 MUX using two 4X1 multiplexers using verilog. Code:
module MUX4X1(I,Y,E,S); input [3:0]I; input E; input [1:0]S; output reg Y; always@(I or E or S) begin if(E) if(S[1]) if(S[0]) Y=I[3]; else Y=I[2]; else if(S[0]) Y=I[1]; else Y=I[0]; else Y=0; end endmodule
input [2:0]S; output Y; wire Y1,Y2; MUX4X1 a1(I[3:0],Y1,~S[2],S[1:0]); MUX4X1 a2(I[7:4],Y2,S[2],S[1:0]); or (Y,Y1,Y2); endmodule
Test bench:
module MUX8X1_tb; reg [7:0]I; reg [2:0]S; wire Y; MUX8X1 tb(I,S,Y); initial {I,S}=0; always begin {I,S}={I,S}+1; #20; end endmodule
Result:An 8X1 multiplexer has been designed using two 4X1 multiplexers and verified using
verilog.
Signal Flow:
Test bench:
module pen8X3_tb; reg [7:0]X; wire [2:0]Y; wire Z; priorityencoder8X3 tb(X,Y,Z); initial X=0; always begin X=X+1; #10; end endmodule
Result:An 8X3 priority encoder has been designed and verified using verilog. Signal Flow:
Technology schematic:
Critical path:
Netlist: (edif gates (edifVersion 2 0 0) (edifLevel 0) (keywordMap (keywordLevel 0)) (status (written (timestamp 2010 10 30 07 49 56) (program "LeonardoSpectrum Level 3" (version "2010a.7")) (author "Mentor Graphics"))) (external PRIMITIVES (edifLevel 0) (technology (numberDefinition ))) (external ami05_typ (edifLevel 0) (technology (numberDefinition )) (cell nor02ii (cellType GENERIC) (view NETLIST (viewType NETLIST) (interface
(port A0 (direction INPUT)) (port A1 (direction INPUT)) (port Y (direction OUTPUT))))) (cell and02 (cellType GENERIC) (view NETLIST (viewType NETLIST) (interface (port A0 (direction INPUT)) (port A1 (direction INPUT)) (port Y (direction OUTPUT))))) (cell or02 (cellType GENERIC) (view NETLIST (viewType NETLIST) (interface (port A0 (direction INPUT)) (port A1 (direction INPUT)) (port Y (direction OUTPUT))))) (cell inv02 (cellType GENERIC) (view NETLIST (viewType NETLIST) (interface (port A (direction INPUT)) (port Y (direction OUTPUT)))))) (library ravichandra_lib (edifLevel 0) (technology (numberDefinition )) (cell gates (cellType GENERIC) (view INTERFACE (viewType NETLIST) (interface (port a (direction INPUT))
(port b (direction INPUT)) (port y1 (direction OUTPUT)) (port y2 (direction OUTPUT)) (port y3 (direction OUTPUT)) (port y4 (direction OUTPUT))) (contents (instance ix9 (viewRef NETLIST (cellRef nor02ii (libraryRef ami05_typ )))) (instance ix5 (viewRef NETLIST (cellRef and02 (libraryRef ami05_typ )))) (instance ix3 (viewRef NETLIST (cellRef or02 (libraryRef ami05_typ )))) (instance ix117 (viewRef NETLIST (cellRef inv02 (libraryRef ami05_typ )))) (net a (joined (portRef a ) (portRef A1 (instanceRef ix5 )) (portRef A0 (instanceRef ix3 )) (portRef A (instanceRef ix117 )))) (net b (joined (portRef b ) (portRef A0 (instanceRef ix5 )) (portRef A1 (instanceRef ix3 )))) (net y1 (joined (portRef y1 ) (portRef Y (instanceRef ix5 )) (portRef A0 (instanceRef ix9 )))) (net y2
(joined (portRef y2 ) (portRef Y (instanceRef ix3 )) (portRef A1 (instanceRef ix9 )))) (net y3 (joined (portRef y3 ) (portRef Y (instanceRef ix9 )))) (net y4 (joined (portRef y4 ) (portRef Y (instanceRef ix117 )))))))) (design gates (cellRef gates (libraryRef ravichandra_lib )))
******************************************************* Cell PadInC PadOut buf02 inv02 Library References ami05_typ ami05_typ ami05_typ ami05_typ 2x 4x 3x 1x 1x 2x 1 1 1 1 3 gates 1 gates 1 gates 2 gates Total Area
6 15 13 0
WAVEFORM
WAVEFORM:
RESULT:
Square waveform is generated using verilog hdl.