Professional Documents
Culture Documents
Course: M.Tech
SID: 23215005
Submitted to:
Dr. Neelam Rup Prakash
1. Combinational Circuits
1. AND Gate
2. 4x1 Multiplexer
3. Full Adder
4. Full Subtractor
5. Priority Encoder(4:2)
assign y = a&b;
endmodule
begin
Y = 1'b1;
end
else
Y = 1'b0; end
endmodule
output y);
if((sa0==0)&(sa1==0))
y = a;
if((sa0==0)&(sa1==1))
y = b;
if((sa0==1)&(sa1==0))
y = c;
if((sa0==1)&(sa1==1))
y = d;
end
endmodule
a, b, c, d, s0, s1);
endmodule
4x1 Multiplexer(Dataflow Style) module m41
( input a,
input b,
input c,
input d,
output out);
a, b, c, d, s0, s1);
endmodule
4x1 Multiplexer(Dataflow Style) module m41
( input a,
input b,
input c,
input d,
output out);
endmodule
((a&b)|(b&c)|(c&a));
endmodule
full_adder_s (
sum,carry
);
and(w2,a,b); and(w3,b,cin);
and(w4,cin,a);
endmodule
module full_subtractor(
input a,
input b,
input c,
output diff
output borr); wire
x,n2,z,n1; xor
s1(x,a,b); not
s3(n2,x); not
s4(n1,c); and
s5(y,n1,b); xor
s2(diff,a,x); and
s6(z,n2,a); or
(borr,y,z);
endmodule
A1;
output A0,A1;
= Y3 + ((~Y2)&Y1); endmodule
2. Sequential Circuits
1. T Flip Flop
2. J-K Flip Flop
3. S-R Flip Flop
4. D- Flip Flop
5. SR Latch
Ans 1: T-FF(Behavioral)
module TFF (
logic Q, Qn
);
begin
Q <= 0;
Qn <= 1;
Q <= ~Q;
endmodule T-FF(Structural)
module tff_gate_level (
input clk,
input t, output
reg q
);
endmodule
Not Possible as T flip flop doesn’t work on level triggered clock Ans 2: JK-FF(Behavioral) module jkff
begin
Q <= 0;
begin
Q <= ~Q;
(J) begin
Q <= 1;
Q <= 0;
Qn <= 1;
end
end
endmodule
JK-FF(Dataflow)
Not Possible as JK flip flop doesn’t work on level triggered clock JK-
q,qbar; wire
nand1_out; // output
nand2_out; // output
from nand2
nand(nand1_out, j,clk,qbar); nand(nand2_out,
k,clk,q); nand(q,qbar,nand1_out);
nand(qbar,q,nand2_out);
endmodule
Ans 3: SR-FF(Behavioral)
module SRFF (
logic Q, Qn
);
begin
Q <= 0;
(S) begin
Q <= 1;
Qn <= 0;
Q <= 0;
Qn <= 1;
end end
endmodule
SR-FF(Dataflow)
Not Possible as SR flip flop doesn’t work on level triggered clock
qbar;
(nand2_out,clk,r); nand
(q,nand1_out,qbar); nand
(qbar,nand2_out,q);
endmodule
Ans 4: D-FF(Structural)
module nand_gate(c,a,b);
assign c = ~(a&b);
endmodule
module not_gate(f,e);
input e; output f;
assign f= ~e;
endmodule
module d_ff_struct(q,qbar,d,clk);
not1(dbar,d); nand_gate
nand1(x,clk,d); nand_gate
nand2(y,clk,dbar); nand_gate
nand3(q,qbar,y); nand_gate
nand4(qbar,q,x); endmodule
D-FF(Behavioral) module
dff_behavioral(d,clk,clear,q,qbar); input d, clk,
D-FF(Dataflow)
module sr_latch (
output Q, input R,
input S
);
(rn, R, ~Q);
endmodule
SR- Latch(Behavioral)
module sr_latch ( output Q,
input R, input S
);
always @(R or S) begin case
({R, S})
endcase end
endmodule
SR- Latch(Dataflow)
Cannot be implemented as dataflow considers combinational circuits
1. Design a logic circuit using XOR gates to generate the even parity of a 4-bit input
(D0, D1, D2, D3). The output should be 0 if the number of 1s in the input is even,
and 1 if it's odd.
Ans: Assume 4bit number given to us. If we implement it in the form of F=(D0^D1)^(D2^D3).
It will produce 1 if number of zeroes is odd else 0.
1. Implement a 3-bit shift register using D flip-flops and combinational logic. The
register should shift its contents to the right on each rising edge of the clock signal.
Consider how to handle data input and the most significant bit (MSB) shifting out.
Ans:
Here the logic Synthesis has been performed using the following code in Verilog
and schematic simulated on Vivado module shift_register(input clk, input shift_in,
input load, output [2:0] q);
endmodule
begin
q_reg <= d;
end assign q =
q_reg;
endmodule