Hallo,
ich bin gerade dabei eine CPU für mein FPGA board zu synthetisieren. Nun
bin ich auf die Idee gekommen, dass es doch sinnvoll sein kann eine
Instruktion "SLLI" zu implementieren. Diese shiftet ein 32-Bit Register
logisch i-Mal nach links. Nun wollte ich mal wissen, wie man sowas in
VHDL implementieren kann?
Ich habe hier mal meinen Code, jedoch will Xilinx das nicht
synthetisieren. Der Fehler ist in der for-Schleife, hier müssen die
Grenzen Konstant sein und nicht von Variablen abhängen (hier const).
Irgendwelche Tipps, was ich tun kann? Ich dachte villeiecht könnte
Xilinx eine 32-Bit Shifter synthetisieren, mit einem Eingang zum
Angeben, um wie viel geshiftet werden soll...
Hier mein aktueller Code:
1 | library IEEE;
|
2 | use IEEE.std_logic_1164.all;
|
3 | use IEEE.std_logic_misc.all;
|
4 | use IEEE.std_logic_signed.all;
|
5 | use IEEE.numeric_std.all;
|
6 |
|
7 | entity shifter is
|
8 | port (
|
9 | s : in std_logic_vector (4 downto 0);
|
10 | d : in std_logic_vector (31 downto 0);
|
11 | q : out std_logic_vector (31 downto 0)
|
12 | );
|
13 | end shifter;
|
14 |
|
15 | architecture behavior of shifter
|
16 | begin
|
17 | process(s, d)
|
18 | variable const : Integer;
|
19 | variable temp : std_logic_vector(31 downto 0);
|
20 | begin
|
21 | const := conv_integer(s);
|
22 | temp := d;
|
23 |
|
24 | if const >= 1 and const <= 32 then
|
25 | for i in 1 to const loop
|
26 | temp := temp(30 downto 0) & '0'
|
27 | end loop;
|
28 | end if;
|
29 |
|
30 | q <= temp;
|
31 | end process;
|
32 | end behavior;
|
Bitte um Tipps! :)