UART

4.0 The Parity Generator

A transmitter subcircuit not included in the transmitter subcircuit is the parity bit generator. The paritybit subcircuit takes a 16-bit data from the transmitter and generates the parity bit which will be attached to the transmitter data, the receiver can check for errors in transmission using this bit. The circuit will be integrated into the transmitter using HDL (VHDL and Verilog) function, later in this chapter. The truth table can be drawn from the circuit below . The VHDL and Verilog code is also given below. The circuit is basically a 16-bit xor gate.


module parity_generator(
      input wire[15:0] tx_data,
      output reg parity_bit
  );

  always @(tx_data)
  begin
     parity_bit <= tx_data[0] ^ tx_data[1] ^ tx_data[2]
  	^ tx_data[3]^ tx_data[4] ^ tx_data[5] ^ tx_data[6] ^ tx_data[7]
  	^ tx_data[8] ^ tx_data[9] ^ tx_data[10] ^ tx_data[11]
  	^ tx_data[12] ^ tx_data[13] ^ tx_data[14] ^ tx_data[15] ;
  end
  endmodule
  
PARITY GENERATOR VERILOG CODE

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity parity_generator is
port(
  tx_data            : in  std_logic_vector(15 downto 0);
  parity_bit         : out std_logic);
end parity_generator;

architecture rtl of parity_generator is

begin

parity_bit <= tx_data(0) xor tx_data(1)  xor tx_data(2)
xor tx_data(3)  xor tx_data(4)  xor tx_data(5)  xor tx_data(6)
 xor tx_data(7)  xor tx_data(8)  xor tx_data(9)  xor tx_data(10)
 xor tx_data(11)  xor tx_data(12)  xor tx_data(13)  xor tx_data(14)
 xor tx_data(15) ;

end rtl;
PARITY GENERATOR VERILOG CODE

4.1 The Transmitter sub circuit

The diagram shown below is the the transmitter simulation in logism, the FSM (finite state machine) is the left side while the state action is the right side, as can be seen two flip flops are used to store the current state of the transmitter, the output labelled A and B will be fed into the state action subcircuit.You will notice that the clock driving the flip flops are not the system clock, it is the generated BAUD_CLOCK, this new clock will be fed into the transmitter through this pin as will be shown inthe last chapter.The entire circuit still share a common reset pin. The RTS pin was discussed in the architecture chapter of this tutorial, it will send the transmitter signal that the receiver is ready to receive data while the txbusy bit is set when the transmitter is currently sending data, this two bits are used to start the data transmission. The txbitcnt bit stores the number of received data, once the data is completed sent, it moves the state to the finished state. All these will be explained with the VHDL code.

4.1 The Transmitter subcricuit

4.2 The Transmitter State action subcircuit

This is the right side of the diagram, here we can see the paritybit subcircuit we generated earlier connected to the dataout input which is data transmitter wants to send. Also, the FSM subcircuit outputs A and B which serves as input to this subcircuit. Two Rams, ram19 which stores our 16bit data to be sent with one start, one stop bit and one parity bit making it 19 total. The next ram is ram8 which keeps counts of how many bits that has been sent out, once it counts upto 19. It stops and goes to the last state which ends the transmission. Both rams are been driven by the newly generated baud clock and not the system clock, but a common reset for the entire circuit. The txbusy bit tells the device that the transmitter is busy and it should try to transmit a new data, it turns on during transmission and off after transmission. The Area marked in Red is two wire splitters facing eachother, the upper one contains the 19bit data to be sent , then the txbit sends just one bit from it, the second lower splitter takes the remaining 18 bits and adds a '1' to it and then sends it back to the Ram. The VHDL explains it further.

--------------------------------------------------------------------------------
-- PROJECTFPGA.COM
--------------------------------------------------------------------------------
-- NAME:    UART TRANSMITTER
--------------------------------------------------------------------------------
-- AUTHORS: Ezeuko Emmanuel <ezeuko.arinze@projectfpga.com>
--------------------------------------------------------------------------------
-- WEBSITE: https://projectfpga.com/uart
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- UART TRANSMITTER FOR FPGA
--------------------------------------------------------------------------------
-- Copyright (C) 2020 projectfpga.com
--
-- This source file is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This source file is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity transmitter is
port(
  dout : in  std_logic_vector(15 downto 0); --data to be transmitted
  rts : in  std_logic;--set by receiver to tell transmitter to start sending data
  baud_clock : in  std_logic;--The baud clock, will be used instead of main clock
  reset , error: in  std_logic;
  txbit: out std_logic;
  sent_ok: out std_logic);

end entity;

architecture structure of transmitter is

signal txbusy: std_logic;
signal s_txbusy: std_logic;
signal nobits: std_logic;
signal parity_in: std_logic;
signal TXFSM : std_logic_vector(1 downto 0);
signal TXFSM_in : std_logic_vector(1 downto 0);
signal txbitcnt : std_logic_vector(7 downto 0);
signal txbitcnt_in : std_logic_vector(7 downto 0);
signal data_reg : std_logic_vector(18 downto 0);
signal data_reg_in : std_logic_vector(18 downto 0);
signal data_reg1 : std_logic_vector(18 downto 0);

--adding the parity generator circuit to the transmitter
component parity_generator is
port(
  tx_data            : in  std_logic_vector(15 downto 0);
  parity_bit         : out std_logic);--the name was changed to avoid 
  --conflict with the parity_bit here.
end component;
begin
  join_parity: parity_generator
    port map (tx_data=>dout, parity_bit=>parity_in );
 -- ends here

 --adds the stopbit, paritybit, 16-bit data, and the start bit together 
 --making total of 19bits to be sent out
 data_reg_in <= '1' & parity_in & dout & '0';
 data_reg1 <='1' & data_reg(data_reg'high downto 1);
 txbit      <= data_reg(18) or not s_txbusy;
nobits <= '1' when (txbitcnt = "1101") else '0';

process (reset, baud_clock)
begin
if reset='1' then
 TXFSM <=  (others => '0');
  txbitcnt <=  (others => '0');
   data_reg <=  (others => '0');
	 sent_ok <= '0';
	 txbusy <= '0';
  elsif rising_edge(baud_clock) then
 TXFSM <=  TXFSM_in;
  txbitcnt <=  txbitcnt_in;
	 sent_ok <= nobits;
	txbusy <= s_txbusy ;

	case TXFSM is

  when "00" =>
  if rts='1' then
  data_reg <= data_reg_in;
  txbitcnt <=  (others => '0');
  TXFSM <="01";
  end if;

  when "01" =>
  txbusy <='1';
  data_reg <= data_reg1;
  txbitcnt <= txbitcnt + 1;
  if(nobits = '1') then
  TXFSM <="11";
  else
  TXFSM <="10";
  end if;

  when "10" =>
  txbusy <='1';
  data_reg <= data_reg1;
  txbitcnt <= txbitcnt + 1;
  if(nobits = '1') then
  TXFSM <="11";
  else
  TXFSM <="01";
  end if;

when "11" =>
	txbusy <= '0';
	if (error = '1') then

	TXFSM <= "11";
else
   TXFSM <= "00";
end if;
	end case;

end if;
end process;
end structure;






John Doe
3:47:45am On 2018.10.8
woowwww apollo.
John Doe
9:43:12am On 2018.12.9
This Verilog code doesn t require a test bench to simulate?.
John Doe
4:9:27pm On 2018.12.19
Bro what is the verilog programe of a even bit parity generator.
John Doe
3:16:40pm On 2018.10.22
can i share this post :).
John Doe
09:07:17pm On 2022.09.14
video chat older gay chat gay granada <a href="https://free-gay-sex-chat.com/">chat random gay </a>.
John Doe
04:58:37am On 2022.09.16
in gay chat what is an poz? <a href=https://chatcongays.com>gay chat chartestone</a> popular gay chat avenue.
John Doe
01:41:40am On 2022.09.20
best custom essay writers <a href=https://au-bestessays.org>need help writing an essay</a> academic essay writing services.
John Doe
08:59:16pm On 2022.09.20
buy essays cheap <a href=https://bestcampusessays.com>reflective essay help</a> help with essay introduction.
John Doe
07:15:49pm On 2022.09.21
buy essays cheap <a href=https://besteasyessays.org>essay help online</a> custom essay writing service org.
John Doe
03:06:34pm On 2022.09.22
essay writing websites <a href=https://bestessayreviews.net>essay conclusion help</a> professional college application essay writers.
John Doe
12:37:58am On 2022.09.25
review of essay writing services <a href=https://bestsessays.org>cheap essay writer service</a> writing essays custom.
John Doe
07:37:05pm On 2022.09.25
best custom essay writing service <a href=https://buyacademicessay.com>custom essays review</a> help writing scholarship essays.
John Doe
03:13:18pm On 2022.09.26
pay for someone to write my essay <a href=https://buy-eessay-online.com>help writing a comparison and contrast essay</a> essay writing services.
John Doe
10:24:09am On 2022.09.27
custom essay UK <a href=https://buytopessays.com>best essay cheap</a> custom essays essay help.
John Doe
06:19:22am On 2022.09.28
essay writers net <a href=https://cheapessaywritingservice1.com>college essay community service</a> service to others essay.
John Doe
02:16:38am On 2022.09.29
buy essay online cheap <a href=https://customcollegeessays.net>psychology essay writing services</a> best essay writing website.
John Doe
09:55:14pm On 2022.09.29
easy essay help <a href=https://customessays-writing.org>help 123 essay</a> buy an essay cheap.
John Doe
04:51:02pm On 2022.09.30
online essay writing service review <a href=https://customessaywwriting.com>helping writing essay</a> college application essay writing service.
John Doe
11:16:04am On 2022.10.01
write my social work essay <a href=https://customs-essays-writing.org>who can i pay to write my essay</a> us essay writers.
John Doe
06:52:13am On 2022.10.02
fast custom essays <a href=https://firstessayservice.net>essay write service</a> best article writing service.
John Doe
03:36:00am On 2022.10.03
help with writing an essay <a href=https://geniusessaywriters.net>how can i pay someone to write my essay</a> macbeth essay help.
John Doe
01:31:41am On 2022.10.04
essays writing services <a href=https://howtobuyanessay.com>essay writing services recommendations</a> service essay writing.
John Doe
01:25:32pm On 2022.10.09
buy essays for college <a href=https://lawessayhelpinlondon.com>essay help chat room</a> what can i write my essay on.
John Doe
07:47:24pm On 2022.10.11
essays to buy <a href=https://ukessayservice.net>i need help writing an argumentative essay</a> expository essay help.
John Doe
10:42:39am On 2022.10.13
top essay writing service <a href=https://writemyessaycheap24h.com>order custom essay online</a> where can i buy an essay online.
John Doe
05:07:20am On 2022.11.16
essay writing service forum <a href=https://au-bestessays.org>best essay writer</a> best college essay service.
John Doe
06:46:40am On 2022.11.19
professional essay help <a href=https://bestcampusessays.com>professional college essay writers</a> professional essay writers for hire.
John Doe
01:51:23pm On 2022.11.20
custom essay writing service toronto <a href=https://besteasyessays.org>writing essays help</a> looking for someone to write my essay.
John Doe
10:00:19pm On 2022.11.21
cheap essays for sale <a href=https://bestessayreviews.net>essay writing service online</a> college admission essay writing service.
John Doe
06:44:26am On 2022.11.23
helping others essays <a href=https://bestessaysden.com>buy essays for college</a> write my essay for money.
John Doe
08:52:12am On 2022.11.27
best essay services <a href=https://buy-eessay-online.com>law school essay writing service</a> essay writing services toronto.
John Doe
06:03:58pm On 2022.11.28
essay help college <a href=https://buytopessays.com>professional essay writers review</a> us essay writing service.
John Doe
05:48:35pm On 2023.01.21
coursework masters <a href=https://brainycoursework.com>courseworks help</a> coursework science.