Sol+Marking scheme Comp Arch Labtest 2025
Sol+Marking scheme Comp Arch Labtest 2025
case (current_state)
IDLE: begin
if (X)
next_state = S1;
else
next_state = IDLE;
end
S1: begin
if (X)
next_state = S1;
else
next_state = S10;
end
S10: begin
if (X)
next_state = S1;
else
next_state = S100;
end
S100: begin
if (X)
begin
next_state = S1001;
end
else
next_state = IDLE;
end
S1001: begin
if (X)
next_state = S1;
else
next_state = S10;
end
///////////////////////////////////////--BIN_Counter--
/////////////////////////////////////
module BIN_Counter (
output reg [2:0] Q_out,
input wire CLR1, Binary Counter module:
input wire CLR2,
4 Marks. If saturation logic not done
input wire Clock
); then only 2 marks. If behavioral not
always @(posedge Clock) begin used then 0 marks.
if (CLR1 || CLR2)
Q_out <= 3'b000;
else
Q_out <= (Q_out == 3'b111) ? 3'b111 : Q_out + 1;
end
initial
Q_out = 3'b000;
endmodule
////////////////////////////////////////////////////--DEC_8--
/////////////////////////////////////
module DEC_8 (
output reg [7:0] O,
input wire [2:0] S
);
endmodule
////////////////////////////////////////////////////--INTG--
/////////////////////////////////////
module INTG (
output wire [7:0] Z2,
input wire X,
input wire CLK,
input wire RST,
output wire z1,
output wire [2:0] Q_out
Integrator module:
);
2 marks each for instantiating 3
wire Z;
// Instantiate SEQ_DET modules with correct connections =
SEQ_DET seq_det_inst ( 6 Marks. If behavioral not used then
.Z1(Z), 0 marks.
.X(X),
.CLK(CLK),
.RST(RST)
);
// Instantiate BIN_Counter
BIN_Counter bin_counter_inst (
.Q_out(Q_out),
.CLR1(RST),
.CLR2(Z2[3]),
.Clock(Z)
);
// Instantiate DEC_8
DEC_8 dec_8_inst (
.S(Q_out),
.O(Z2)
);
assign z1=Z;
endmodule
/////////////////////////////////////////TESTBENCH///////////////////////
//////////
module TESTBENCH;
INTG dut (
.z1(Z1),
.Z2(Z2),
.X(X),
.CLK(CLK),
.RST(RST),
.Q_out(Q_out)
);
// Input sequence
X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
#10 X = 0;
#10 X = 0;
#10 X = 1;
// Finish simulation
#10 $finish;
end
endmodule
Z1 correct: 7 Marks.
No partial marking
Z2 correct: 8 Marks
No partial marking