Professional Documents
Culture Documents
2 KJKFD
2 KJKFD
Objective
In this lab, we design and implement BCD to 7-segment decoder. Moreover, we learn how to use
the 7-segment display of Nexys2 FPGA board.
IN-LAB TASK 1:
On Proteus:
Post-lab Tasks
we had two tasks that we had to perform. In task 1 we used common cathode to test the
functionality of BCD to 7- Segment decoder by simulating the circuit on Proteus. We also
observed the behavior of BCD to 7-Segment decoder on 7-Segment by choosing different
BCD values. In second task we write the BCD to 7 segment code on online compiler and
verify its values and we also wrote test bench. Then we gave different input combinations to
get the desired output.
Lab # 10
Equation from Y:
AB~C
In-lab+Post-lab
Moore FSM for Sequence Detection:
module mooredec(sequence_in,clock,reset,detector_out);
input clock;
input reset;
input sequence_in;
parameter Zero=3'b000,
One=3'b001,
OneZero=3'b011,
OneZeroOne=3'b010,
OneZeroOneOne=3'b110;
begin
if(reset==1)
else
end
always @(current_state,sequence_in)
begin
case(current_state)
Zero:begin
if(sequence_in==1)
next_state = One;
else
next_state = Zero;
end
One:begin
if(sequence_in==0)
next_state = OneZero;
else
next_state = One;
end
OneZero:begin
if(sequence_in==0)
next_state = Zero;
else
next_state = OneZeroOne;
end
OneZeroOne:begin
if(sequence_in==0)
next_state = OneZero;
else
next_state = OneZeroOneOne;
end
OneZeroOneOne:begin
if(sequence_in==0)
next_state = OneZero;
else
next_state = One;
end
default:next_state = Zero;
endcase
end
always @(current_state)
begin
case(current_state)
Zero: detector_out = 0;
One: detector_out = 0;
OneZero: detector_out = 0;
OneZeroOne: detector_out = 0;
OneZeroOneOne: detector_out = 1;
default: detector_out = 0;
endcase
end
endmodule
clock = 0;
end
initial begin
sequence_in = 0;
reset = 1;
#30;
reset = 0;
#40;
sequence_in = 1;
#10;
sequence_in = 0;
#10;
sequence_in = 1;
#20;
sequence_in = 0;
#20;
sequence_in = 1;
#20;
sequence_in = 0;
end
endmodule
Conclusion:
In this lab, we knew about Mealy and Moore model. But we used Moore machine model in
this report. In lab task we converted decimal number (22) into binary number. We also
construct a code in Moore machine Model to detect a sequence. We also attached the output
and test bench file of the code.