DCD Task - 4
DCD Task - 4
DCD Task - 4
TASK – 5
CODE:
module Mealy_zero_detector_XYZ(y_out,x_in,clk,rst);
input x_in, clk, rst;
output y_out;
reg [1:0] state,next_state;
reg y_out;
parameter S0=2'b00, S1=2'b01, S2=2'b10, S3=2'b11;
always @ (posedge clk, negedge rst)
if(rst==0)state<=S0;
else state <= next_state;
always@(state,x_in)
case(state)
S0: if (x_in) next_state=S1; else next_state=S0;
S1: if (x_in) next_state=S3; else next_state=S0;
S2: if (~x_in) next_state=S0; else next_state=S2;
S3: if (x_in) next_state=S2; else next_state=S0;
endcase
always @(state,x_in)
case(state)
S0: y_out =0;
S1,S2,S3: y_out = ~x_in;
endcase
endmodule
OUTPUT:
2.
A) Using MODELSIM, carry out the simulation of a MOD 8 counter using T
flipflops.
B) Accomplish 2A) using case statements
CODE:
module mod8_counter
# (parameter N = 8,
parameter WIDTH = 4)
( input clk,
input rstn,
if (!rstn) begin
out <= 0;
if (out == N-1)
out <= 0;
else
out<=out+1;
end
end
endmodule
input clock, j, k;
output q, qbar;
reg d = 1'b0;
assign q = d;
assign qbar = ~d;
endmodule
input clock;
output q2, q1, q0;
assign q2 = d[2];
assign q1 = d[1];
assign q0 = d[0];
endmodule
input clock, j, k;
output q, qbar;
reg d = 1'b0;
assign q = d;
assign qbar = ~d;
endmodule
input clock;
output q2, q1, q0;
assign q2 = d[2];
assign q1 = d[1];
assign q0 = d[0];
endmodule
TASK-4
1. Write a test bench for verifying the functionality of any one
combinational circuit in task III. Write few lines about the
need for a test bench.
2. Write a Verilog HDL code for a ‘D’ latch and ‘D’ flipflop.
Verify its working using its function table. Mention its
characteristics equation and excitation table. Mention few of
its applications.
‘D’ LATCH:
‘D’ FLIPFLOP:
3. Write a Verilog HDL code for a ‘JK’ and ‘T’ flipflop.
Verify its working using its function table. Mention its
characteristics equation and excitation table. Mention few of
its applications.
‘JK’ FLIPFLOP:
‘T’ FLIPFLOP;
4. Write a note on Behavioural modelling, the role
of assignment operator and its proper usage.
Illustrate with examples.
CONTINUATI
ON OF TASK – 3