L
LeBlanc
Guest
Haluan vain ilmoittaa whit DAC edellä SPI, mutta se ei kävele kuin odotettu.Kanisteri joku auttaa minua perusteet.
kiitos
library IEEE;
käytön IEEE.STD_LOGIC_1164.ALL;
käytön IEEE.STD_LOGIC_ARITH.ALL;
käytön IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Kommentit seuraavia kirjaston ilmoitus, jos instantiating
---- Tahansa Xilinx perusalkioiden tämän koodin.
- Kirjasto UNISIM;
- käyttö UNISIM.VComponents.all;
yksikkö sinus on
Port (CLK: in STD_LOGIC;
clk2_p: out std_logic;
SPI_MOSI: out std_logic;
SPI_SS_B: out std_logic;
AMP_CS: out std_logic;
AD_CONV: out std_logic;
SF_CEO: out std_logic;
FPGA_INIT_B: out std_logic;
- imput_word_t: out std_logic;
DAC_CS: out std_logic;
SPI_SCK: out std_logic;
SPI_MISO: in std_logic;
kuormitus: out STD_LOGIC
)
lopussa sinus;
architecture Behavioral of sinus_574mhz on
signaali shift_reg: std_logic_vector (11 downto 0): = (others => '0 ');
signaali shift_reg1: std_logic: = '0 ';
signaali zl: std_logic_vector (5 downto 0): = (others => '0 ');
signaali sine: std_logic_vector (11 downto 0): = (others => '0 ');
signaali stop: std_logic: = '0 ';
signal lämpötila: std_logic_vector (23 downto 0): = (others => '0 ');
vakio ZERO: std_logic_vector (23 downto 0): = "000000000000000000000000";
signaali CLK2: std_logic: = '0 ';
signaali CLK3: std_logic: = '0 ';
signaali serial_data: std_logic: = '0 ';Osan sinus
satama (
CLK: IN std_logic;
SINE: OUT std_logic_vector (11 downto 0));
komponenttirakenne;
aloittaa
- imput_word_t <= clk2;
- adress <= "1111";
- command <= "0011";
- SPI_SCK <= clk3;
SPI_SS_B <= '1 ';
AMP_CS <= '1 ';
AD_CONV <= '0 ';
SF_CEO <= '1 ';
FPGA_INIT_B <= '1 ';
- imput_word <= Command & osoite & sine & "XXXX";
clk2_p <= clk2;
bloc_1: sinus
portti kartta (
CLK => CLK,
SINE => SINE);
prosessi (clk2)
aloittaa
jos (clk2'event ja clk2 = '0 ') then
SPI_SCK <= clk3;
jos stop = '1 'then
SPI_SCK <= '0 ';
end if;
end if;
end process;
-------------------------------------------------- ---------------------------
prosessi (clk3, clk2)
aloittaa
jos clk2'event ja clk2 = '1 'then
Jos clk3 = '0 'then
zl <= zl 1 - komento (4)
end if;
end if;
end process;
prosessi (clk3, clk2)
aloittaa
jos clk2'event ja clk2 = '1 'then
Jos clk3 = '0 'then
Jos zl on
kun "000000" =>
DAC_CS <= '0 ';
pysäkki <= '0 ';
SPI_MOSI <= '0 '; - tiedot (23);
kun "000001" =>
SPI_MOSI <= '0 '; - tiedot (23);
kun "000010" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000011" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000100" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000101" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000110" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000111" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "001000" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001001" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001010" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001011" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001100" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001101" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001110" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001111" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010000" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010001" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010010" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010011" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010100" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010101" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010110" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010111" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun muut => - DAC_CS <= '1 '; - command_o <=' X ';
vuoden osalta;
jos zl = "011000" sitten
DAC_CS <= '1 ';
pysäkki <= '1 ';
end if;
end if;
end if;
end process;
prosessi (clk2)
aloittaa
Jos rising_edge (clk2) jälkeen
temp <= temp (22 downto 0) & SPI_MISO;
shift_reg1 <= temp (23);
end if;
end process;
-------------------------------------------------- ------------------------------------------
prosessi (CLK) on
muuttuja var_zustand_vektor: std_logic_vector (1 downto 0) = "00";
muuttuja var_zaehler_vektor: integer range 0-249: = 0;
aloittaajos (CLK'event ja CLK = '1 ') then
CASE var_zustand_vektor on
kun "00" =>
Jos var_zaehler_vektor = 124 sitten
var_zustand_vektor: = "01";
muuten
var_zaehler_vektor: = var_zaehler_vektor 1;
CLK2 <= '1 ';
end if;
kun "01" =>
Jos var_zaehler_vektor = 249 sitten
var_zustand_vektor: = "00";
var_zaehler_vektor: = 0;
muuten
var_zaehler_vektor: = var_zaehler_vektor 1;
CLK2 <= '0 ';
end if;
kun muut =>
var_zustand_vektor: = "00";
End asia;
end if;
end process;
prosessi (CLK2) on
aloittaa
jos (CLK2'event JA CLK2 = '1 ') then
jos (clk3 = '0 ') then
clk3 <= '1 ';
muuten
clk3 <= '0 ';
end if;
end if;
end process;-------------------------------------------------- -------------------------prosessi (clk2)
aloittaa
Jos rising_edge (clk2) jälkeen
- kuorma <= shift_reg (11);
shift_reg <= sine;
kuormituksella: <= shift_reg (11);
shift_reg (11 downto 1) <= shift_reg (10 downto 0);
end if;
end process;lopussa Behavioral;
kiitos
library IEEE;
käytön IEEE.STD_LOGIC_1164.ALL;
käytön IEEE.STD_LOGIC_ARITH.ALL;
käytön IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Kommentit seuraavia kirjaston ilmoitus, jos instantiating
---- Tahansa Xilinx perusalkioiden tämän koodin.
- Kirjasto UNISIM;
- käyttö UNISIM.VComponents.all;
yksikkö sinus on
Port (CLK: in STD_LOGIC;
clk2_p: out std_logic;
SPI_MOSI: out std_logic;
SPI_SS_B: out std_logic;
AMP_CS: out std_logic;
AD_CONV: out std_logic;
SF_CEO: out std_logic;
FPGA_INIT_B: out std_logic;
- imput_word_t: out std_logic;
DAC_CS: out std_logic;
SPI_SCK: out std_logic;
SPI_MISO: in std_logic;
kuormitus: out STD_LOGIC
)
lopussa sinus;
architecture Behavioral of sinus_574mhz on
signaali shift_reg: std_logic_vector (11 downto 0): = (others => '0 ');
signaali shift_reg1: std_logic: = '0 ';
signaali zl: std_logic_vector (5 downto 0): = (others => '0 ');
signaali sine: std_logic_vector (11 downto 0): = (others => '0 ');
signaali stop: std_logic: = '0 ';
signal lämpötila: std_logic_vector (23 downto 0): = (others => '0 ');
vakio ZERO: std_logic_vector (23 downto 0): = "000000000000000000000000";
signaali CLK2: std_logic: = '0 ';
signaali CLK3: std_logic: = '0 ';
signaali serial_data: std_logic: = '0 ';Osan sinus
satama (
CLK: IN std_logic;
SINE: OUT std_logic_vector (11 downto 0));
komponenttirakenne;
aloittaa
- imput_word_t <= clk2;
- adress <= "1111";
- command <= "0011";
- SPI_SCK <= clk3;
SPI_SS_B <= '1 ';
AMP_CS <= '1 ';
AD_CONV <= '0 ';
SF_CEO <= '1 ';
FPGA_INIT_B <= '1 ';
- imput_word <= Command & osoite & sine & "XXXX";
clk2_p <= clk2;
bloc_1: sinus
portti kartta (
CLK => CLK,
SINE => SINE);
prosessi (clk2)
aloittaa
jos (clk2'event ja clk2 = '0 ') then
SPI_SCK <= clk3;
jos stop = '1 'then
SPI_SCK <= '0 ';
end if;
end if;
end process;
-------------------------------------------------- ---------------------------
prosessi (clk3, clk2)
aloittaa
jos clk2'event ja clk2 = '1 'then
Jos clk3 = '0 'then
zl <= zl 1 - komento (4)
end if;
end if;
end process;
prosessi (clk3, clk2)
aloittaa
jos clk2'event ja clk2 = '1 'then
Jos clk3 = '0 'then
Jos zl on
kun "000000" =>
DAC_CS <= '0 ';
pysäkki <= '0 ';
SPI_MOSI <= '0 '; - tiedot (23);
kun "000001" =>
SPI_MOSI <= '0 '; - tiedot (23);
kun "000010" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000011" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000100" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000101" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000110" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "000111" =>
SPI_MOSI <= '1 '; - tiedot (23);
kun "001000" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001001" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001010" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001011" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001100" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001101" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001110" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "001111" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010000" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010001" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010010" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010011" =>
SPI_MOSI <= shift_reg (11) - tiedot (23);
kun "010100" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010101" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010110" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun "010111" =>
SPI_MOSI <= 'X'; - tiedot (23);
kun muut => - DAC_CS <= '1 '; - command_o <=' X ';
vuoden osalta;
jos zl = "011000" sitten
DAC_CS <= '1 ';
pysäkki <= '1 ';
end if;
end if;
end if;
end process;
prosessi (clk2)
aloittaa
Jos rising_edge (clk2) jälkeen
temp <= temp (22 downto 0) & SPI_MISO;
shift_reg1 <= temp (23);
end if;
end process;
-------------------------------------------------- ------------------------------------------
prosessi (CLK) on
muuttuja var_zustand_vektor: std_logic_vector (1 downto 0) = "00";
muuttuja var_zaehler_vektor: integer range 0-249: = 0;
aloittaajos (CLK'event ja CLK = '1 ') then
CASE var_zustand_vektor on
kun "00" =>
Jos var_zaehler_vektor = 124 sitten
var_zustand_vektor: = "01";
muuten
var_zaehler_vektor: = var_zaehler_vektor 1;
CLK2 <= '1 ';
end if;
kun "01" =>
Jos var_zaehler_vektor = 249 sitten
var_zustand_vektor: = "00";
var_zaehler_vektor: = 0;
muuten
var_zaehler_vektor: = var_zaehler_vektor 1;
CLK2 <= '0 ';
end if;
kun muut =>
var_zustand_vektor: = "00";
End asia;
end if;
end process;
prosessi (CLK2) on
aloittaa
jos (CLK2'event JA CLK2 = '1 ') then
jos (clk3 = '0 ') then
clk3 <= '1 ';
muuten
clk3 <= '0 ';
end if;
end if;
end process;-------------------------------------------------- -------------------------prosessi (clk2)
aloittaa
Jos rising_edge (clk2) jälkeen
- kuorma <= shift_reg (11);
shift_reg <= sine;
kuormituksella: <= shift_reg (11);
shift_reg (11 downto 1) <= shift_reg (10 downto 0);
end if;
end process;lopussa Behavioral;