1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.std_logic_unsigned.all;
|
4 | use ieee.numeric_std.all;
|
5 |
|
6 | entity xillydemo is
|
7 | port (
|
8 | PCIE_PERST_B_LS : IN std_logic;
|
9 | PCIE_REFCLK_N : IN std_logic;
|
10 | PCIE_REFCLK_P : IN std_logic;
|
11 | PCIE_RX_N : IN std_logic_vector(3 DOWNTO 0);
|
12 | PCIE_RX_P : IN std_logic_vector(3 DOWNTO 0);
|
13 | GPIO_LED : OUT std_logic_vector(3 DOWNTO 0);
|
14 | PCIE_TX_N : OUT std_logic_vector(3 DOWNTO 0);
|
15 | PCIE_TX_P : OUT std_logic_vector(3 DOWNTO 0));
|
16 | end xillydemo;
|
17 |
|
18 | architecture sample_arch of xillydemo is
|
19 | signal tmp : std_logic_vector(7 DOWNTO 0);
|
20 |
|
21 |
|
22 | component xillybus
|
23 | port (
|
24 | PCIE_PERST_B_LS : IN std_logic;
|
25 | PCIE_REFCLK_N : IN std_logic;
|
26 | PCIE_REFCLK_P : IN std_logic;
|
27 | PCIE_RX_N : IN std_logic_vector(3 DOWNTO 0);
|
28 | PCIE_RX_P : IN std_logic_vector(3 DOWNTO 0);
|
29 | GPIO_LED : OUT std_logic_vector(3 DOWNTO 0);
|
30 | PCIE_TX_N : OUT std_logic_vector(3 DOWNTO 0);
|
31 | PCIE_TX_P : OUT std_logic_vector(3 DOWNTO 0);
|
32 | bus_clk : OUT std_logic;
|
33 | quiesce : OUT std_logic;
|
34 |
|
35 | user_r_read_8_rden : OUT std_logic;
|
36 | user_r_read_8_empty : IN std_logic;
|
37 | user_r_read_8_data : IN std_logic_vector(7 DOWNTO 0);
|
38 | user_r_read_8_eof : IN std_logic;
|
39 | user_r_read_8_open : OUT std_logic;
|
40 | user_w_write_8_wren : OUT std_logic;
|
41 | user_w_write_8_full : IN std_logic;
|
42 | user_w_write_8_data : OUT std_logic_vector(7 DOWNTO 0);
|
43 | user_w_write_8_open : OUT std_logic);
|
44 | end component;
|
45 |
|
46 | component fifo_8x2048
|
47 | port (
|
48 | clk: IN std_logic;
|
49 | srst: IN std_logic;
|
50 | din: IN std_logic_VECTOR(7 downto 0);
|
51 | wr_en: IN std_logic;
|
52 | rd_en: IN std_logic;
|
53 | dout: OUT std_logic_VECTOR(7 downto 0);
|
54 | full: OUT std_logic;
|
55 | empty: OUT std_logic);
|
56 | end component;
|
57 |
|
58 |
|
59 | -- Synplicity black box declaration
|
60 | attribute syn_black_box : boolean;
|
61 | attribute syn_black_box of fifo_8x2048: component is true;
|
62 |
|
63 | signal bus_clk : std_logic;
|
64 | signal quiesce : std_logic;
|
65 |
|
66 | signal reset_8 : std_logic;
|
67 |
|
68 | signal ram_addr : integer range 0 to 31;
|
69 |
|
70 | signal user_r_read_8_rden : std_logic;
|
71 | signal user_r_read_8_empty : std_logic;
|
72 | signal user_r_read_8_data : std_logic_vector(7 DOWNTO 0);
|
73 | signal user_r_read_8_eof : std_logic;
|
74 | signal user_r_read_8_open : std_logic;
|
75 | signal user_w_write_8_wren : std_logic;
|
76 | signal user_w_write_8_full : std_logic;
|
77 | signal user_w_write_8_data : std_logic_vector(7 DOWNTO 0);
|
78 | signal user_w_write_8_open : std_logic;
|
79 | signal wr_en : std_logic := '0';
|
80 | signal din : std_logic_vector(user_w_write_8_data'range) := (others => '0');
|
81 |
|
82 | begin
|
83 | xillybus_ins : xillybus
|
84 | port map (
|
85 | -- Ports related to /dev/xillybus_read_8
|
86 | -- FPGA to CPU signals:
|
87 | user_r_read_8_rden => user_r_read_8_rden,
|
88 | user_r_read_8_empty => user_r_read_8_empty,
|
89 | user_r_read_8_data => user_r_read_8_data,
|
90 | user_r_read_8_eof => user_r_read_8_eof,
|
91 | user_r_read_8_open => user_r_read_8_open,
|
92 |
|
93 | -- Ports related to /dev/xillybus_write_8
|
94 | -- CPU to FPGA signals:
|
95 | user_w_write_8_wren => user_w_write_8_wren,
|
96 | user_w_write_8_full => user_w_write_8_full,
|
97 | user_w_write_8_data => user_w_write_8_data,
|
98 | user_w_write_8_open => user_w_write_8_open,
|
99 |
|
100 | -- General signals
|
101 | PCIE_PERST_B_LS => PCIE_PERST_B_LS,
|
102 | PCIE_REFCLK_N => PCIE_REFCLK_N,
|
103 | PCIE_REFCLK_P => PCIE_REFCLK_P,
|
104 | PCIE_RX_N => PCIE_RX_N,
|
105 | PCIE_RX_P => PCIE_RX_P,
|
106 | GPIO_LED => GPIO_LED,
|
107 | PCIE_TX_N => PCIE_TX_N,
|
108 | PCIE_TX_P => PCIE_TX_P,
|
109 | bus_clk => bus_clk,
|
110 | quiesce => quiesce
|
111 | );
|
112 |
|
113 | process (bus_clk)
|
114 |
|
115 | begin
|
116 |
|
117 | if (bus_clk'event and bus_clk = '1') then
|
118 | wr_en <= user_w_write_8_wren;
|
119 | if (user_w_write_8_wren = '1') then
|
120 | din <= user_w_write_8_data;
|
121 | if (din(5)='1') then
|
122 | din(5)<='0';
|
123 | elsif (din(5)='0') then
|
124 | din(5)<='1';
|
125 | end if;
|
126 | end if;
|
127 | end if;
|
128 |
|
129 | end process;
|
130 |
|
131 | -- 8-bit loopback
|
132 |
|
133 | fifo_8 : fifo_8x2048
|
134 | port map(
|
135 | clk => bus_clk,
|
136 | srst => reset_8,
|
137 | din => din,
|
138 | wr_en => wr_en,
|
139 | rd_en => user_r_read_8_rden,
|
140 | dout => user_r_read_8_data,
|
141 | full => user_w_write_8_full,
|
142 | empty => user_r_read_8_empty
|
143 | );
|
144 |
|
145 | reset_8 <= not (user_w_write_8_open or user_r_read_8_open);
|
146 |
|
147 | user_r_read_8_eof <= '0';
|
148 |
|
149 | end sample_arch;
|