Lab 8 Report
Lab 8 Report
3.6 Part 6
The aim for Part 6 was to develop a program that displayed the value of a 16 bit input on
the four seven segment displays HEX 4-7, and then copied them onto displays 0-3, while being
able to reset. The value displayed was created through a 16-bit slide switch input, which was copied
onto the 16-bit input B and displayed on HEX 4-7. When push-button KEY[1] was triggered, the
value in B was transferred over to A and displayed on HEX 0-3. KEY[0] was used to reset value
A to zero, and was the asynchronous reset for this program. This was the most complex of all the
programs, as at first the instructions were not clear and resulted in the incorrect program being
created. However, after a considerable effort, this was corrected.
5 Conclusion
Library Parametrized Modules are able to be used to easily create components of a program
in a shorter amount of time that would’ve otherwise been consumed by the manual creation of
these components. Quartus has a large library of various LPMs to suit user needs, so productivity
is increased. These LPMs are separate programs that are called upon through instantiation in the
main program to do a large amount of the work. Latches are used in various applications, and for
this lab were used to create a storage element for the storage of values and their reset. Flip-Flops
are used for these purposes but also for the upwards incrementation of the values, especially for
multi-bit outputs. This can then be used as a counter with a clock input, which are useful for various
real-life situations, such as sorting and digital clocks. Using Verilog and Quartus Prime, these are
able to be created and to help the user further educate themselves in the field of Digital Logic.
always @(negedge KEY[1] or posedge SW[3]) //when push button 1 decreases or switch
3 increases
begin
if(SW[3]==1) //if switch 3 is activated
LEDR<=0; //all red LEDs off
else if(SW[1]) //else if switch 1 is toggled
LEDR<=LEDR+1; //increment binary value displayed by red LEDs up by 1
end
endmodule
Listing 6.5: Code for Part 5
always @(posedge KEY[0] or negedge KEY[1]) //when push button 1 increases or push
button 2 decreases
begin
A = SW; //values from switch inputs copied over to A
if (KEY[1]==0) //if push button 1 is not activated
begin
B = 0; //displays 5-8 are zero
end
else //if push button 1 is activated
begin
B = A; //values displayed on displays 1-4 are copied over to displays 5-8
end
end
count1 count1_inst (
.aset ( reset ),
.clk_en ( SW[0] ),
.clock ( SW[1] ),
.q ( Q )
);
endmodule
Listing 6.7: Code for Part 7