Układy Cyfrowe i Systemy Wbudowane 2 XC4000: LUT jako ROM Układy FPGA cz. 2 dr inż. Jarosław Sugier Jaroslaw.Sugier@pwr.edu.pl W-4/K-9, pok. 227 C-3 FPGA(2) - 1 FPGA(2) - 2 ROM32X1 VHDL inference example ROM 16x2b -- ROM type declaration type rom_type is array (0 to 15) of STD_LOGIC_VECTOR(1 downto 0); constant ROM : rom_type := (0 => "00", 1 to 7 => "01", others => "11"); -- Address & output buses signal Addr : STD_LOGIC_VECTOR(3 downto 0); signal DOut : STD_LOGIC_VECTOR(1 downto 0); -- Distr. ROM = single concurrent assignment (asynchr. read!) DOut <= ROM( to_integer( unsigned( Addr ) ) ); use IEEE.NUMERIC_STD.ALL DOut <= ROM( to_integer( unsigned( Addr ) ) ); FPGA(2) - 3 use IEEE.STD_LOGIC_UNSIGNED.ALL DOut <= ROM( conv_integer( Addr ) ); FPGA(2) - 4 Asynchroniczna pamięć RAM (RAM16X1) Synchroniczna pamięć RAM (RAM16X1S) Speed grades 4-1: TWC 8.0 min ns TAS 2.0 min ns TWP 4.0 min ns TDS 4.0 0.8 min ns TAH 2.5 2.0 min ns TDH 2.0 min ns TWC address write cycle time Speed grades 4-1: TWOS 10.3 5.6 (16x2) 11.6 7.0 (32x1) max ns TILO 2.7 1.3 max ns TWSS 2.2 1.5 min ns TDSS 3.5 1.5 min ns TASS 2.8 1.5 min ns TWHS TDHS 0 min ns TAHS 7.5 4.0 min ns TWPS 1 max ms TWCS 15.0 8.0 min ns FPGA(2) - 5 TWCS address write cycle time (clock K period) FPGA(2) - 6 1
VHDL inference template example single port RAM16X1S type ram_type is array (0 to 15) of STD_LOGIC; signal RAM : ram_type; -- if needed initialize here Pamięć RAM dwuportowa (RAM16X1D) -- Write functionality process (CLK) if rising_edge( CLK ) then if (WE = '1') then RAM( to_integer( unsigned( A ) ) ) <= DI; -- Read functionality DO <= RAM( to_integer( unsigned( A ) ) ); FPGA(2) - 7 FPGA(2) - 8 VHDL inference template example dual port RAM16X1D type ram_type is array (0 to 15) of STD_LOGIC; signal RAM : ram_type; -- if needed initialize here -- Write functionality process (CLK) if rising_edge( CLK ) then if (WE = '1') then RAM( to_integer( unsigned( A ) ) ) <= DI; -- Read functionality DO <= RAM( to_integer( unsigned( A ) ) ); DPO <= RAM( to_integer( unsigned( DPRA ) ) ); FPGA(2) - 9 FPGA(2) - 10 Spartan-3E Zajętość zasobów FPGA(2) - 11 FPGA(2) - 12 2
Nowość: LUT jako rejestr przesuwny Np.: rejestry o stałej długości FPGA(2) - 13 FPGA(2) - 14 Np.: rejestry o długości dynamicznej VHDL inference example FPGA(2) - 15 FPGA(2) - 16 Blokowa pamięć RAM Praca jednoportowa (A) Spartan-II (A) Spartan-II: od 4k x 1 do 256 x 16 (B) Spartan-3 (B) Spartan-3: od 16k x 1 do 512 x 32 + dodatkowe bity parzystości FPGA(2) - 17 FPGA(2) - 18 3
Operacje podstawowe Wyprowadzenia (XC3S) FPGA(2) - 19 FPGA(2) - 20 Synchroniczny zapis oraz odczyt Odczyt podczas zapisu: trzy tryby Rysunek dla organizacji 256 x 16 (XC2S) XC3S: WRITE_MODE = WRITE_FIRST FPGA(2) - 21 FPGA(2) - 22 XST User Guide (14.7): process (clk) -- Write-First Mode if rising_edge( clk ) then if en = 1 then if we = 1 then RAM(to_integer(unsigned(addr))) <= di; do <= di; else do <= RAM(to_integer(unsigned(addr))); process (clk) -- Read-First Mode if rising_edge( clk ) then if en = 1 then if we = 1 then RAM(to_integer(unsigned(addr))) <= di; do <= RAM(to_integer(unsigned(addr))) ; FPGA(2) - 23 Praca dwuportowa FPGA(2) - 24 4
XST User Guide: DP RAM with different clocks Clock-to-clock set-up type ram_type is array of STD_LOGIC_VECTOR; shared variable RAM : ram_type; process( CLKA ) if rising_edge( CLKA ) then if ENA = 1 then if WEA = 1 then RAM(to_integer(ADDRA)) := DIA; DOA <= RAM(to_integer(ADDRA)); For Read-First mode: DOA <= RAM(... if WEA... RAM(... process( CLKB )... as above but for CLKB, ADDRB, etc.... FPGA(2) - 25 FPGA(2) - 26 Przykłady zastosowań Wykorzystanie obu portów: Długie bufory cykliczne Dwa niezależne moduły 256 x 72 FPGA(2) - 27 FPGA(2) - 28 Szybkie liczniki o dowolnym cyklu (ROM) FPGA(2) - 29 FPGA(2) - 30 5
Maszyny stanów (ROM) Złożone funkcje logiczne (ROM) FPGA(2) - 31 FPGA(2) - 32 Układy generacji przeniesienia Lepiej: C3 A3 B3 S3 C2 A2 B2 S2 C1 A1 B1 S1 C0 A0 B0 S0 0 A B CIN COUT 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 A = B, COUT = A A B, COUT = CIN A = B, COUT = A FPGA(2) - 33 FPGA(2) - 34 Przy mnożeniu FPGA(2) - 35 FPGA(2) - 36 6
Przykład: ADD8 Przykład: ADSU8 FPGA(2) - 37 FPGA(2) - 38 Liczniki binarne Przykład: CC8CE FPGA(2) - 39 FPGA(2) - 40 Przykład: CC8CLED Wielowejściowe funktory AND, OR FPGA(2) - 41 FPGA(2) - 42 7
Komparatory (COMPMC16) FPGA(2) - 43 8