Professional Documents
Culture Documents
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart is
Port ( sci_sel,r_w,clk,rxd : in std_logic;
add2 : in std_logic_vector(1 downto 0);
sci_irq,txd : out std_logic);
end uart;
component uart_receiver
port(rxd,bclkx8,sysclk,rst_b,rdrf:in std_logic;
rdr:out std_logic_vector(7 downto 0);
setrdrf,setoe,setfe:out std_logic );
end component;
component uart_transmitter
port(bclk,sysclk,rst_b,tdre,loadtdr:in std_logic;
dbus:in std_logic_vector(7 downto 0);
settdre,txd : out std_logic);
end component;
component clk_divider
port(sysclk,rst_b:in std_logic;
sel:in std_logic_vector(2 downto 0);
bclkx8,bclk:out std_logic);
end component;
process(clk,rst_b)
begin
if(rst_b = '0') then
tdre<='1';
rdrf<='0';
oe<='0';
fe<='0';
tie<='0';
rie<='0';
elsif(rising_edge(clk)) then
sci_irq <='1' when (rie ='1' and (rdrf = '1' or oe='1')) or (tie='1' and tdre='1'))
else '0';
----bus interface
scsr <= tdre & rdrf & "0000" & oe & fe;
sccr <= tie & rie & "000" & baudsel;
sci_read <= '1' when (sci_sel ='1' and r_w ='0') else '0';
sci_write<= '1' when (sci_sel ='1' and r_w ='1') else '0';
clrrdrf <= '1' when (sci_read ='1' and addr ="00") else '0';
loadtdr<='1' when (sci_write ='1' and addr ="00") else '0';
loadsccr<='1' when (sci_read ='0' and addr ="10") else '0';
dbus<="zzzzzzzz" when (sci_read ='0') else rdr when (addr ="00");
else scsr when (addr="01")
else sccr;
end uart1;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity clk_divider is
Port ( sysclk,rst_b : in std_logic;
sel : in std_logic_vector(2 downto 0);
bclkx8 : buffer std_logic;
bclk : out std_logic);
end clk_divider;
begin
process(sysclk)
begin
if(sysclk'event and sysclk='1') then
if(ctr1="1100" ) then ctr1<="0000";
else ctr1<=ctr1+1;
end if;
end if;
end process;
clkdiv<=ctr1(3);
process(clkdiv)
begin
if(rising_edge(clkdiv)) then
ctr2<=ctr2+1;
end if;
end process;
process(bclkx8)
begin
if(rising_edge(bclkx8)) then
ctr3<=ctr3+1;
end if;
end process;
bclk<=ctr3(2);
end baud;
===============================================================
==========
* Final Report *
===============================================================
==========
Final Results
RTL Top Level Output File Name : clk_divider.ngr
Top Level Output File Name : clk_divider
Output Format : NGC
Optimization Goal : Speed
Keep Hierarchy : NO
Design Statistics
# IOs :7
Macro Statistics :
# Registers :1
# 3-bit register :1
Cell Usage :
# BELS :1
# GND :1
# IO Buffers :2
# OBUF :2
===============================================================
==========
Device utilization summary:
---------------------------
===============================================================
==========
TIMING REPORT
Clock Information:
------------------
No clock signals found in this design
Timing Summary:
---------------
Speed Grade: -4
Timing Detail:
--------------
All values displayed in nanoseconds (ns)
===============================================================
==========
CPU : 2.31 / 3.23 s | Elapsed : 2.00 / 3.00 s
-->
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart_receiver is
Port ( rxd,bclkx8,sysclk,rst_b,rdrf : in std_logic;
rdr : out std_logic_vector(7 downto 0);
setrdrf,setoe,setfe : out std_logic);
end uart_receiver;
begin
bclkx8_rising <= bclkx8 and (not bclkx8_delayed);
rcvr_control: process(state,rxd,rdrf,ct1,ct2,bclkx8_rising)
begin
inc1<='0';inc2<='0';clr1<='0';clr2<='0';
shftrsr<='0';loadrdr<='0' ;setrdrf<='0' ;setoe<='0';setfe<='0';
case state is
when idle=> if(rxd='0') then nextstate<=start_detected;
else nextstate<= idle;
end if;
end case;
end process;
rcvr_update:process(sysclk,rst_b)
begin
if(rst_b='0') then state<=idle;
bclkx8_delayed<='0';
ct1<=0;ct2<=0;
elsif(sysclk'event and sysclk='1') then
state<=nextstate;
if (clr1='1')then ct1<=0 ;
elsif(inc1='1') then ct1<=ct1+1;
end if;
if (clr2='1')then ct2<=0 ;
elsif(inc2='1') then ct2<=ct2+1;
end if;
if(shftrsr='1') then rsr<=rxd & rsr(7 downto 1);
end if;
if(loadrdr='1')then rdr<=rsr;
end if;
bclkx8_delayed<=bclkx8;
end if;
end process;
end rcvr;
===============================================================
==========
* Final Report *
===============================================================
==========
Final Results
RTL Top Level Output File Name : uart_receiver.ngr
Top Level Output File Name : uart_receiver
Output Format : NGC
Optimization Goal : Speed
Keep Hierarchy : NO
Design Statistics
# IOs : 16
Macro Statistics :
# Registers : 11
# 1-bit register :9
# 3-bit register :1
# 8-bit register :1
# Counters :1
# 4-bit up counter :1
# Multiplexers :1
# 2-to-1 multiplexer :1
Cell Usage :
# BELS : 38
# GND :1
# LUT1 :1
# LUT2 :2
# LUT2_D :1
# LUT2_L :1
# LUT3 :4
# LUT3_L :3
# LUT4 :8
# LUT4_D :2
# LUT4_L :6
# MUXCY :4
# VCC :1
# XORCY :4
# FlipFlops/Latches : 27
# FDC :3
# FDCE :3
# FDCPE :4
# FDE : 16
# FDP :1
# Clock Buffers :1
# BUFGP :1
# IO Buffers : 15
# IBUF :4
# OBUF : 11
===============================================================
==========
===============================================================
==========
TIMING REPORT
Clock Information:
------------------
-----------------------------------+------------------------+-------+
Clock Signal | Clock buffer(FF name) | Load |
-----------------------------------+------------------------+-------+
sysclk | BUFGP | 27 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -4
Timing Detail:
--------------
All values displayed in nanoseconds (ns)
-------------------------------------------------------------------------
Timing constraint: Default period analysis for Clock 'sysclk'
Delay: 9.914ns (Levels of Logic = 3)
Source: bclkx8_delayed (FF)
Destination: rdr_7 (FF)
Source Clock: sysclk rising
Destination Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default OFFSET IN BEFORE for Clock 'sysclk'
Offset: 9.608ns (Levels of Logic = 4)
Source: bclkx8 (PAD)
Destination: rdr_7 (FF)
Destination Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default OFFSET OUT AFTER for Clock 'sysclk'
Offset: 15.783ns (Levels of Logic = 4)
Source: bclkx8_delayed (FF)
Destination: setfe (PAD)
Source Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default path analysis
Delay: 15.477ns (Levels of Logic = 5)
Source: bclkx8 (PAD)
Destination: setfe (PAD)
===============================================================
==========
CPU : 1.97 / 2.91 s | Elapsed : 2.00 / 3.00 s
-->
TRANSMITTER
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart_transmitter is
Port ( bclk,sysclk,rst_b,tdre,loadtdr : in std_logic;
dbus : in std_logic_vector(7 downto 0);
settdre,txd : out std_logic);
end uart_transmitter;
begin
xmit_control : process(state,tdre,bct,bclk_rising)
begin
inc<='0';
clr<='0';
loadtsr<='0';
shfttsr<='0';
start<='0';
case state is
xmit_update:process(sysclk,rst_b)
begin
if(rst_b = '0') then
tsr<= "111111111";
state<=idle;
bct<=0;
bclk_delayed<='0';
elsif(sysclk'event and sysclk='1') then
state <= nextstate;
if (clr='1') then bct<=0;
elsif (inc='1') then bct<=bct+1;
end if;
if (loadtdr='1') then tdr<=dbus;
end if;
if (loadtsr='1') then tsr<=tdr & '1';
end if;
if (start='1') then tsrout<='0';
end if;
if (shfttsr='1') then tsr<='1' & tsr(8 downto 1);
end if;
bclk_delayed<=bclk;
end if;
end process;
end xmit;
===============================================================
==========
* Final Report *
===============================================================
==========
Final Results
RTL Top Level Output File Name : uart_transmitter.ngr
Top Level Output File Name : uart_transmitter
Output Format : NGC
Optimization Goal : Speed
Keep Hierarchy : NO
Design Statistics
# IOs : 15
Macro Statistics :
# Registers :3
# 1-bit register :1
# 8-bit register :1
# 9-bit register :1
# Counters :1
# 4-bit up counter :1
# Multiplexers :1
# 2-to-1 multiplexer :1
Cell Usage :
# BELS : 33
# GND :1
# LUT1 :1
# LUT2 :3
# LUT3_D :1
# LUT3_L :4
# LUT4 :4
# LUT4_D :2
# LUT4_L :8
# MUXCY :4
# VCC :1
# XORCY :4
# FlipFlops/Latches : 25
# FDC :3
# FDCPE :4
# FDE :8
# FDP :1
# FDPE :9
# Clock Buffers :1
# BUFGP :1
# IO Buffers : 14
# IBUF : 12
# OBUF :2
===============================================================
==========
===============================================================
==========
TIMING REPORT
Clock Information:
------------------
-----------------------------------+------------------------+-------+
Clock Signal | Clock buffer(FF name) | Load |
-----------------------------------+------------------------+-------+
sysclk | BUFGP | 25 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -4
Timing Detail:
--------------
All values displayed in nanoseconds (ns)
-------------------------------------------------------------------------
Timing constraint: Default period analysis for Clock 'sysclk'
Delay: 10.396ns (Levels of Logic = 2)
Source: bct_1 (FF)
Destination: tsr_8 (FF)
Source Clock: sysclk rising
Destination Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default OFFSET IN BEFORE for Clock 'sysclk'
Offset: 8.437ns (Levels of Logic = 4)
Source: bclk (PAD)
Destination: bct_3 (FF)
Destination Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default OFFSET OUT AFTER for Clock 'sysclk'
Offset: 10.787ns (Levels of Logic = 2)
Source: state_FFd3 (FF)
Destination: settdre (PAD)
Source Clock: sysclk rising
-------------------------------------------------------------------------
Timing constraint: Default path analysis
Delay: 10.404ns (Levels of Logic = 3)
Source: tdre (PAD)
Destination: settdre (PAD)
===============================================================
==========
CPU : 1.75 / 2.66 s | Elapsed : 1.00 / 2.00 s
-->