The following laboratory explains the concepts behind standard serial
communications used between computer systems and presents the design for
an implementation of a serial-to-parallel convertor based upon those
standards. The homework assignment is to complete the design and implement
a parallel-to-serial convertor. The combined serial-to-parallel
and parallel-to-serial convertor components will provide full serial communications
between the UP1 and a standard computer system that will be used in this
and later laboratories.
Data Bit 0 1 2 3 4 5 6 7 12 ___ _______ ___ ___ Volts -12 ________________| |_______| |___| |___| |__________________ 0 0 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 | Idle bits | B | Data 'S' ASCII code | E |Idle bits| |______________| |_______________________________| |_________| time-->B = Start bit (opposite of idle bit). E = Stop bit (same as idle bit).
time,
asynchronous
to
the serial-to-parallel convertor state clock. Another is that as the bits
arrive, one should read the bit very near its middle to improve the chance
of correctly reading the value. If it were read near the edge of two bits,
one might easily be somewhat early or late, misreading one bit for another.
As the diagram illustrates, at time A the read may give either 0 or 1 while
at time B, in the middle of the bit, one is nearly certain to read the
bit correctly. That is the notion of wait long enough for middle of
data bit in the algorithm above, to improve the odds of reading the
data bit correctly, the read wait long enough for the middle of the
data bit.
The start bit serves to synchronize the receiver with the sender bits. If the bit rate is 1, then 1 bit arrives every second. The middle of the first data bit then arrives 1.5 seconds after the beginning of the start bit. The middle of the next bit arrives 1 second after that, etc. as the diagram below illustrates. The start bit, B, should be detected near the rising edge in order to synchronize the remaining bits. This requires that the FSM clock must be somewhat faster than the baud rate, a clock of 16 times the baud rate usually provides sufficient detection accuracy of the start bit. The remaining bits are then read after waiting some fixed amount of time, long enough to pass from the middle of one bit to the middle of the next.

Putting these ideas together produces a more detailed list of tasks for the SP:
| Input: SerialIn(t) element of {0,1}
Output: ParallelOut(t) element of {00000000..11111111}, dataReady(t) element of {0,1} State: s(t) element of {S0,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11} Initial: s(0)=S0 Present | Next | Output s(t) | Input SerialIn(t) | Parallel(t) dataReady(t) | 0 1 | S0 | S0 S1 | xxxxxxxx 0 S1 | S2 S2 | xxxxxxxx 0 S2 | S3 S3 | xxxxxxx0 0 S3 | S4 S4 | xxxxxx10 0 S4 | S5 S5 | xxxxx210 0 S5 | S6 S6 | xxxx3210 0 S6 | S7 S7 | xxx43210 0 S7 | S8 S8 | xx543210 0 S8 | S9 S9 | x6543210 0 S9 | S10 S10 | 76543210 0 S10 | S11 S11 | 76543210 1 S11 | S0 S11 | 76543210 1 |
The SerialIn is the serial input from the receiver, the Parallel is the 8 bits of parallel data for output. dataReady output signals when a full 8 bits of serial data has been received and the parallel data is ready.
| -- Serial input component. 8 data bits, 1 stop bit, NO parity
ENTITY serI IS
ARCHITECTURE behavioral OF serI IS TYPE STATE_TYPE IS (S0, S1, S2,
S3, S4, S5, S6, S7, S8, S9, S10, S11);
BEGIN TRUE <= '1'; FALSE <= '0'; PROCESS (clk)
-- Change nextS on rising clock edge
Count := Count
+ 1; -- Count
number of clock cycles
SIn <= SerialIn; -- Synchronize serial input CASE presentS
IS
PROCESS (nextS, StartBit)
|
| -- Test serial input component by outputting to LED of UP1
ENTITY serITest IS
ARCHITECTURE structural OF serITest IS COMPONENT segment7
COMPONENT slowCLK
COMPONENT serI
SIGNAL data : BIT_VECTOR(7 DOWNTO 0);
BEGIN
|
![]() |
|||
Necessary Pin Definitions for serITest component
|


program from
the Program/Accessories/HyperTerminal folder. Give it a name to
call the new connection.Turn In
Design
The serial-to-parallel (SP) and parallel-to-serial (PS) components are the reverse of the other. The SP receives serial data and converts to parallel (serI component), the PS converts parallel to serial data (serO component). The inputs to PS are 8 bits of Parallel data and a signal that new data is available to convert. The outputs are the serial output and a signal to indicate that data sent. The design of the parallel-to-serial component can be listed as the series of steps required:
Implementation
Points of note:
Testing
There are two testing components. The first sends a character 'A' or
ASCII code 01000001 binary until the pushbutton is pressed. The second
echos whatever character is typed on the terminal program.
| -- Serial output via mouse connector of Altera UP1 when PB pressed
ENTITY serOTest IS
ARCHITECTURE structural OF serOTest IS COMPONENT debounce
COMPONENT slowCLK
COMPONENT serO
SIGNAL data : BIT_VECTOR(7 DOWNTO 0);
BEGIN
|
Test Component serIO - The testing procedure for the second
test component generally follows that
of
the laboratory with the few exceptions given below. The primary difference
is that instead of displaying the character ASCII code on the LEDs, the
character is echoed back using your parallel-to-serial component. The serial-to-parallel
serI
component inputs the character which is then output immediately by your
parallel-to-serial serO component, creating an echo of the character
typed. The main points of note are:
| -- Echo serial input/output via mouse/keyboard connection on Altera
UP1
ENTITY serIO IS
ARCHITECTURE structural OF serIO IS COMPONENT slowCLK
COMPONENT serI
COMPONENT serO
SIGNAL data : BIT_VECTOR(7 DOWNTO 0);
BEGIN
|
Debugging
Document last modified: