mirror of
git://projects.qi-hardware.com/nn-usb-fpga.git
synced 2025-04-21 12:27:27 +03:00
Adding a simple plasma example read write char short int, adding simulations
for this example
This commit is contained in:
@@ -21,12 +21,9 @@
|
||||
-- 0x20000040 GPIO0 Out Clear bits
|
||||
-- 0x20000050 GPIOA In
|
||||
-- 0x20000060 Counter
|
||||
-- 0x20000070 Ethernet transmit count
|
||||
-- IRQ bits:
|
||||
-- 7 GPIO31
|
||||
-- 6 ^GPIO31
|
||||
-- 5 EthernetSendDone
|
||||
-- 4 EthernetReceive
|
||||
-- 3 Counter(18)
|
||||
-- 2 ^Counter(18)
|
||||
-- 1 ^UartWriteBusy
|
||||
@@ -39,7 +36,6 @@ use work.mlite_pack.all;
|
||||
entity plasma is
|
||||
generic(memory_type : string := "XILINX_16X"; --"DUAL_PORT_" "ALTERA_LPM";
|
||||
log_file : string := "UNUSED";
|
||||
ethernet : std_logic := '0';
|
||||
use_cache : std_logic := '0');
|
||||
port(clk : in std_logic;
|
||||
reset : in std_logic;
|
||||
@@ -51,10 +47,7 @@ entity plasma is
|
||||
byte_we : out std_logic_vector(3 downto 0);
|
||||
data_write : out std_logic_vector(31 downto 0);
|
||||
data_read : in std_logic_vector(31 downto 0);
|
||||
mem_pause_in : in std_logic;
|
||||
no_ddr_start : out std_logic;
|
||||
no_ddr_stop : out std_logic;
|
||||
|
||||
mem_pause_in : in std_logic;
|
||||
gpio0_out : out std_logic_vector(31 downto 0);
|
||||
gpioA_in : in std_logic_vector(31 downto 0));
|
||||
end; --entity plasma
|
||||
@@ -69,16 +62,13 @@ architecture logic of plasma is
|
||||
signal cpu_pause : std_logic;
|
||||
|
||||
signal data_read_uart : std_logic_vector(7 downto 0);
|
||||
signal write_enable : std_logic;
|
||||
signal eth_pause_in : std_logic;
|
||||
signal eth_pause : std_logic;
|
||||
signal write_enable : std_logic;
|
||||
signal mem_busy : std_logic;
|
||||
|
||||
signal enable_misc : std_logic;
|
||||
signal enable_uart : std_logic;
|
||||
signal enable_uart_read : std_logic;
|
||||
signal enable_uart_write : std_logic;
|
||||
signal enable_eth : std_logic;
|
||||
|
||||
signal gpio0_reg : std_logic_vector(31 downto 0);
|
||||
signal uart_write_busy : std_logic;
|
||||
@@ -86,8 +76,6 @@ architecture logic of plasma is
|
||||
signal irq_mask_reg : std_logic_vector(7 downto 0);
|
||||
signal irq_status : std_logic_vector(7 downto 0);
|
||||
signal irq : std_logic;
|
||||
signal irq_eth_rec : std_logic;
|
||||
signal irq_eth_send : std_logic;
|
||||
signal counter_reg : std_logic_vector(31 downto 0);
|
||||
|
||||
signal ram_enable : std_logic;
|
||||
@@ -98,29 +86,23 @@ architecture logic of plasma is
|
||||
|
||||
signal cache_check : std_logic;
|
||||
signal cache_checking : std_logic;
|
||||
signal cache_miss : std_logic;
|
||||
signal cache_miss : std_logic;
|
||||
signal cache_hit : std_logic;
|
||||
|
||||
begin --architecture
|
||||
write_enable <= '1' when cpu_byte_we /= "0000" else '0';
|
||||
mem_busy <= eth_pause or mem_pause_in;
|
||||
cache_hit <= cache_checking and not cache_miss;
|
||||
cpu_pause <= (uart_write_busy and enable_uart and write_enable) or --UART busy
|
||||
cache_miss or --Cache wait
|
||||
(cpu_address(28) and not cache_hit and mem_busy); --DDR or flash --DDR in use
|
||||
irq_status <= gpioA_in(31) & not gpioA_in(31) &
|
||||
irq_eth_send & irq_eth_rec &
|
||||
counter_reg(18) & not counter_reg(18) &
|
||||
not uart_write_busy & uart_data_avail;
|
||||
irq <= '1' when (irq_status and irq_mask_reg) /= ZERO(7 downto 0) else '0';
|
||||
gpio0_out(31 downto 29) <= gpio0_reg(31 downto 29);
|
||||
gpio0_out(23 downto 0) <= gpio0_reg(23 downto 0);
|
||||
mem_busy <= mem_pause_in;
|
||||
cache_hit <= cache_checking and not cache_miss;
|
||||
cpu_pause <= '0'; --(uart_write_busy and enable_uart and write_enable) or --UART busy
|
||||
-- cache_miss or --Cache wait
|
||||
-- (cpu_address(28) and not cache_hit and mem_busy); --DDR or flash
|
||||
-- gpio0_out(31 downto 29) <= gpio0_reg(31 downto 29);
|
||||
-- gpio0_out(23 downto 0) <= gpio0_reg(23 downto 0);
|
||||
|
||||
enable_misc <= '1' when cpu_address(30 downto 28) = "010" else '0';
|
||||
enable_uart <= '1' when enable_misc = '1' and cpu_address(7 downto 4) = "0000" else '0';
|
||||
enable_uart_read <= enable_uart and not write_enable;
|
||||
enable_uart_write <= enable_uart and write_enable;
|
||||
enable_eth <= '1' when enable_misc = '1' and cpu_address(7 downto 4) = "0111" else '0';
|
||||
cpu_address(1 downto 0) <= "00";
|
||||
|
||||
u1_cpu: mlite_cpu
|
||||
@@ -161,11 +143,7 @@ begin --architecture
|
||||
cache_check => cache_check, --Stage1: address_next in first 2MB DDR
|
||||
cache_checking => cache_checking, --Stage2
|
||||
cache_miss => cache_miss); --Stage3
|
||||
end generate; --opt_cache2
|
||||
|
||||
no_ddr_start <= not eth_pause and cache_checking;
|
||||
no_ddr_stop <= not eth_pause and cache_miss;
|
||||
eth_pause_in <= mem_pause_in or (not eth_pause and cache_miss and not cache_checking);
|
||||
end generate; --opt_cache2
|
||||
|
||||
misc_proc: process(clk, reset, cpu_address, enable_misc,
|
||||
ram_data_r, data_read, data_read_uart, cpu_pause,
|
||||
@@ -225,8 +203,7 @@ begin --architecture
|
||||
end if;
|
||||
end process;
|
||||
|
||||
ram_enable <= '1' when address_next(30 downto 28) = "000" or
|
||||
cache_check = '1' or cache_miss = '1' else '0';
|
||||
ram_enable <= '1' when address_next(30 downto 28) = "000" or cache_check = '1' or cache_miss = '1' else '0';
|
||||
ram_byte_we <= byte_we_next when cache_miss = '0' else "1111";
|
||||
ram_address(31 downto 13) <= ZERO(31 downto 13);
|
||||
ram_address(12 downto 2) <= (address_next(12) or cache_check) & address_next(11 downto 2)
|
||||
@@ -258,44 +235,10 @@ begin --architecture
|
||||
busy_write => uart_write_busy,
|
||||
data_avail => uart_data_avail);
|
||||
|
||||
dma_gen: if ethernet = '0' generate
|
||||
address <= cpu_address(31 downto 2);
|
||||
byte_we <= cpu_byte_we;
|
||||
data_write <= cpu_data_w;
|
||||
eth_pause <= '0';
|
||||
gpio0_out(28 downto 24) <= ZERO(28 downto 24);
|
||||
irq_eth_rec <= '0';
|
||||
irq_eth_send <= '0';
|
||||
end generate;
|
||||
|
||||
dma_gen2: if ethernet = '1' generate
|
||||
u4_eth: eth_dma
|
||||
port map(
|
||||
clk => clk,
|
||||
reset => reset,
|
||||
enable_eth => gpio0_reg(24),
|
||||
select_eth => enable_eth,
|
||||
rec_isr => irq_eth_rec,
|
||||
send_isr => irq_eth_send,
|
||||
|
||||
address => address, --to DDR
|
||||
byte_we => byte_we,
|
||||
data_write => data_write,
|
||||
data_read => data_read,
|
||||
pause_in => eth_pause_in,
|
||||
|
||||
mem_address => cpu_address(31 downto 2), --from CPU
|
||||
mem_byte_we => cpu_byte_we,
|
||||
data_w => cpu_data_w,
|
||||
pause_out => eth_pause,
|
||||
|
||||
E_RX_CLK => gpioA_in(20),
|
||||
E_RX_DV => gpioA_in(19),
|
||||
E_RXD => gpioA_in(18 downto 15),
|
||||
E_TX_CLK => gpioA_in(14),
|
||||
E_TX_EN => gpio0_out(28),
|
||||
E_TXD => gpio0_out(27 downto 24));
|
||||
end generate;
|
||||
|
||||
end; --architecture logic
|
||||
|
||||
|
||||
Reference in New Issue
Block a user