This repository was archived by the owner on Oct 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathxil_Reconfigurator.vhdl
More file actions
218 lines (186 loc) · 6.56 KB
/
xil_Reconfigurator.vhdl
File metadata and controls
218 lines (186 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
-- EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*-
-- vim: tabstop=2:shiftwidth=2:noexpandtab
-- kate: tab-width 2; replace-tabs off; indent-width 2;
-- =============================================================================
-- Authors: Patrick Lehmann
--
-- Entity: Reconfiguration engine for DRP enabled Xilinx primtives
--
-- Description:
-- -------------------------------------
-- Many complex primitives in a Xilinx device offer a Dynamic Reconfiguration
-- Port (DRP) to reconfigure a primitive at runtime without reconfiguring the
-- whole FPGA.
--
-- This module is a DRP master that can be pre-configured at compile time with
-- different configuration sets. The configuration sets are mapped into a ROM.
-- The user can select a stored configuration with ``ConfigSelect``. Sending a
-- strobe to ``Reconfig`` will start the reconfiguration process. The operation
-- completes with another strobe on ``ReconfigDone``.
--
-- License:
-- =============================================================================
-- Copyright 2007-2016 Technische Universitaet Dresden - Germany
-- Chair of VLSI-Design, Diagnostics and Architecture
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- =============================================================================
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
library PoC;
use PoC.config.all;
use PoC.utils.all;
use PoC.vectors.all;
use PoC.physical.all;
use PoC.xil.all;
entity xil_Reconfigurator is
generic (
DEBUG : boolean := FALSE; --
CLOCK_FREQ : FREQ := 100 MHz; --
CONFIG_ROM : in T_XIL_DRP_CONFIG_ROM := (0 downto 0 => C_XIL_DRP_CONFIG_SET_EMPTY) --
);
port (
Clock : in std_logic;
Reset : in std_logic;
Reconfig : in std_logic; --
ReconfigDone : out std_logic; --
ConfigSelect : in std_logic_vector(log2ceilnz(CONFIG_ROM'length) - 1 downto 0); --
DRP_en : out std_logic; --
DRP_Address : out T_XIL_DRP_ADDRESS; --
DRP_we : out std_logic; --
DRP_DataIn : in T_XIL_DRP_DATA; --
DRP_DataOut : out T_XIL_DRP_DATA; --
DRP_Ack : in std_logic --
);
end entity;
architecture rtl of xil_Reconfigurator is
attribute KEEP : boolean;
attribute FSM_ENCODING : string;
attribute signal_ENCODING : string;
type T_STATE is (
ST_IDLE,
ST_READ_BEGIN, ST_READ_WAIT,
ST_WRITE_BEGIN, ST_WRITE_WAIT,
ST_DONE
);
-- DualConfiguration - Statemachine
signal State : T_STATE := ST_IDLE;
signal NextState : T_STATE;
attribute FSM_ENCODING of State : signal is ite(DEBUG, "gray", "speed1");
signal DataBuffer_en : std_logic;
signal DataBuffer_d : T_XIL_DRP_DATA := (others => '0');
signal ROM_Entry : T_XIL_DRP_CONFIG;
signal ROM_LastConfigWord : std_logic;
signal ConfigSelect_d : std_logic_vector(ConfigSelect'range);
constant CONFIGINDEX_BITS : positive := log2ceilnz(CONFIG_ROM'length);
signal ConfigIndex_rst : std_logic;
signal ConfigIndex_en : std_logic;
signal ConfigIndex_us : unsigned(CONFIGINDEX_BITS - 1 downto 0);
attribute KEEP of ROM_LastConfigWord : signal is DEBUG;
begin
-- configuration ROM
blkCONFIG_ROM : block
signal SetIndex : integer range 0 to CONFIG_ROM'high;
signal RowIndex : T_XIL_DRP_CONFIG_INDEX;
attribute KEEP of SetIndex : signal is DEBUG;
attribute KEEP of RowIndex : signal is DEBUG;
begin
SetIndex <= to_index(ConfigSelect_d, CONFIG_ROM'high);
RowIndex <= to_index(ConfigIndex_us, T_XIL_DRP_CONFIG_INDEX'high);
ROM_Entry <= CONFIG_ROM(SetIndex).Configs(RowIndex);
ROM_LastConfigWord <= to_sl(RowIndex = CONFIG_ROM(SetIndex).LastIndex);
end block;
-- configuration index counter
process(Clock)
begin
if rising_edge(Clock) then
if (ConfigIndex_rst = '1') then
ConfigIndex_us <= (others => '0');
ConfigSelect_d <= ConfigSelect;
elsif (ConfigIndex_en = '1') then
ConfigIndex_us <= ConfigIndex_us + 1;
end if;
end if;
end process;
-- data buffer for DRP configuration words
process(Clock)
begin
if rising_edge(Clock) then
if (Reset = '1') then
DataBuffer_d <= (others => '0');
elsif (DataBuffer_en = '1') then
DataBuffer_d <= ((DRP_DataIn and not ROM_Entry.Mask) or
(ROM_Entry.Data and ROM_Entry.Mask));
end if;
end if;
end process;
-- assign DRP signals
DRP_Address <= ROM_Entry.Address;
DRP_DataOut <= DataBuffer_d;
-- DRP read-modify-write statemachine
process(Clock)
begin
if rising_edge(Clock) then
if (Reset = '1') then
State <= ST_IDLE;
else
State <= NextState;
end if;
end if;
end process;
process(State, Reconfig, ROM_LastConfigWord, DRP_Ack )
begin
NextState <= State;
ReconfigDone <= '0';
-- Dynamic Reconfiguration Port
DRP_en <= '0';
DRP_we <= '0';
-- internal modules
ConfigIndex_rst <= '0';
ConfigIndex_en <= '0';
DataBuffer_en <= '0';
case State is
when ST_IDLE =>
if (Reconfig = '1') then
ConfigIndex_rst <= '1';
NextState <= ST_READ_BEGIN;
end if;
when ST_READ_BEGIN =>
DRP_en <= '1';
DRP_we <= '0';
NextState <= ST_READ_WAIT;
when ST_READ_WAIT =>
if (DRP_Ack = '1') then
DataBuffer_en <= '1';
NextState <= ST_WRITE_BEGIN;
end if;
when ST_WRITE_BEGIN =>
DRP_en <= '1';
DRP_we <= '1';
NextState <= ST_WRITE_WAIT;
when ST_WRITE_WAIT =>
if (DRP_Ack = '1') then
if (ROM_LastConfigWord = '1') then
NextState <= ST_DONE;
else
ConfigIndex_en <= '1';
NextState <= ST_READ_BEGIN;
end if;
end if;
when ST_DONE =>
ReconfigDone <= '1';
NextState <= ST_IDLE;
end case;
end process;
end architecture;