You are on page 1of 9

Lab Title

Counter and Real-Time-Clock

Name & Matric No.

Syafina binti Mohammad Hasbullah BK15110261

Results & Discussion


There are two tasks done in this lab - counter and real-time-clock(RTC). By using seven segment
as display(output), two different coding were coded to show the differences in uses and
application. Note that the output display of this lab is the same. It is as the following:

Table 1: Rotating the word HELLO in eight displays


Counter Character Pattern
000 H E L L O
001 H E L L O
010 H E L L O
011 H E L L O
100 E L L O H
101 L L O H E
110 L O H E L
111 O H E L L

Pin assignment for both tasks are the same as the following:
Variable Signal Name FPGA Pin No.
HEX0[0] PIN_G18
HEX0[1] PIN_F22
HEX0[2] PIN_E17
hex7 HEX0[3] PIN_L26
HEX0[4] PIN_L25
HEX0[5] PIN_J22
HEX0[6] PIN_H22
HEX1[0] PIN_M24
HEX1[1] PIN_Y22
HEX1[2] PIN_W21
hex6 HEX1[3] PIN_W22
HEX1[4] PIN_W25
HEX1[5] PIN_U23
HEX1[6] PIN_U24
hex5 HEX2[0] PIN_AA25
HEX2[1] PIN_AA26
HEX2[2] PIN_Y25
HEX2[3] PIN_W26
HEX2[4] PIN_Y26
HEX2[5] PIN_W27
HEX2[6] PIN_W28
HEX3[0] PIN_V21
HEX3[1] PIN_U21
HEX3[2] PIN_AB20
hex4 HEX3[3] PIN_AA21
HEX3[4] PIN_AD24
HEX3[5] PIN_AF23
HEX3[6] PIN_Y19
HEX4[0] PIN_AB19
HEX4[1] PIN_AA19
HEX4[2] PIN_AG21
hex3 HEX4[3] PIN_AH21
HEX4[4] PIN_AE19
HEX4[5] PIN_AF19
HEX4[6] PIN_AE18
HEX5[0] PIN_AD18
HEX5[1] PIN_AC18
HEX5[2] PIN_AB18
hex2 HEX5[3] PIN_AH19
HEX5[4] PIN_AG19
HEX5[5] PIN_AF18
HEX5[6] PIN_AH18
HEX6[0] PIN_AA17
HEX6[1] PIN_AB16
HEX6[2] PIN_AA16
hex1 HEX6[3] PIN_AB17
HEX6[4] PIN_AB15
HEX6[5] PIN_AA15
HEX6[6] PIN_AC17
HEX7[0] PIN_AD17
HEX7[1] PIN_AE17
HEX7[2] PIN_AG17
hex0 HEX7[3] PIN_AH17
HEX7[4] PIN_AF17
HEX7[5] PIN_AG18
HEX7[6] PIN_AA14
push KEY[0] Push-button[0]

The display coding also the same for both. It is as the following:
The difference between both coding lies in the main block which will be signified better in later
part.

Task 1: Counter

Unlike previous labs where switches were used as the input, this time, push button was used.
Every press on push buttons adds 1 bit from previous. Below is the coding for the counter:

Figure 1

posedge is used in sequential design. Usage of counter calls for sequential design instead of
using behavioral nor dataflow like previous labs. push is the push button used. The counter
works at the if-else condition. As seen in Figure 1 above, if (State == 3b111), StateNext =
3b000. This allows the message displays in cycle instead of ended after the eighth turn. If the
State is not 3b111, the display will just switch places. The counter (State = State + 1b1) is the
increment of the content.

Demonstration will get the following results:


The images above changes as the push button is pressed. Last image show that the display runs
in cycle.
Task 2: Real-Time-Clock(RTC)

In RTC, sequential also used like the previous task. the coding to allow time is as the following:

Figure 2

The ctime is the clock assigned. reg [31:0] signifies the number of bits that could cover the
required time as in labsheet: 50Mhz. The counter is again used to increment the contents of the
counter circuit at one second intervals. The results are alike to that in Task 1 but what happens
actually is the display moves itself instead of the need to press the push button one at a time.

Conclusion
In conclusion, I get to understand the concept of counter and RTC using Verilog HDL
description. Counter allows the increment or decrement of the previous state of a system. RTC
allows the display to work itself depends on the time assigned.
Feedback/Comments
In this lab, I get to learn to apply sequential design as taught in class. I get better understanding
and get to apply the knowledge. This lab is quite simple and straightforward.

You might also like