JeDay 0 January 25, 2006 Posted January 25, 2006 · Report post Не получается с помощью ф-й: SHR SHL самого простого сдвигового регистра сгородить. Может надо место сигналов переменные использовать или еще какой то заковык... Дайте плиз кусочек кода который реализует сдвиг и выдачу результата заборт. Quote Share this post Link to post Share on other sites More sharing options...
vetal 0 January 25, 2006 Posted January 25, 2006 · Report post if фронт then reg<=reg(7 downto 1) & din; end if; out<=reg; Quote Share this post Link to post Share on other sites More sharing options...
sazh 11 January 25, 2006 Posted January 25, 2006 · Report post скачайте с сайта xilinx xst.pdf Многие вопросы отпадут сами собой library ieee; use ieee.std_logic_1164.all; entity shift is port( C, SI, LEFT_RIGHT : in std_logic; PO : out std_logic_vector(7 downto 0)); end shift; architecture archi of shift is signal tmp : std_logic_vector(7 downto 0); begin process © begin if (C'event and C='1') then if (LEFT_RIGHT='0') then tmp <= tmp(6 downto 0) & SI; else tmp <= SI & tmp(7 downto 1); end if; end if; end process; PO <= tmp; end archi; Quote Share this post Link to post Share on other sites More sharing options...
kbz 0 January 27, 2006 Posted January 27, 2006 · Report post library IEEE; use IEEE.std_logic_1164.all; entity sr is port (CLK: in STD_LOGIC; Enable: in STD_LOGIC; new_bit: in STD_LOGIC; out_reg: out STD_LOGIC_VECTOR (3 downto 0) ); end sr; architecture sr of sr is begin process (CLK) variable Reg: STD_LOGIC_VECTOR (3 downto 0); begin if CLK = '1' and CLK'event then if Enable = '1' then for A in 3 downto 1 loop Reg (A) := Reg (A-1); end loop; Reg(0) := new_bit; end if; end if; end process; out_reg <= Reg; end sr; /////////////// P.S.: ан разных ПЛИС разные по описанию регистра сдвига имеют разную производительность (3-5% ) а так, все об одном и том же :) Quote Share this post Link to post Share on other sites More sharing options...
AlexReiki 0 February 5, 2006 Posted February 5, 2006 · Report post :) library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity shift_reg is port(clk,reset : in std_logic; shift_reg: inout std_logic_vector(3 downto 0); in_bit: in std_logic); end entity; architecture behav of shift_reg is begin shift:process(clk,reset) begin if reset ='1' then shift_reg<=(others=>'0'); --shift_reg="0000" elsif rising_edge(clk) then shift_reg<=shr(shift_reg,"01"); shift_reg(1)<=in_bit; end if; end process; end architecture; Quote Share this post Link to post Share on other sites More sharing options...
=AK= 19 February 7, 2006 Posted February 7, 2006 (edited) · Report post Не получается с помощью ф-й: SHR SHL самого простого сдвигового регистра сгородить. Может надо место сигналов переменные использовать или еще какой то заковык... signal MyShReg : unsigned(7 downto 0); signal Din : std_logic; process(Clk,MyShReg,Din) begin if rising_edge(Clk) then MyShReg <= MyShReg sll 1; MyShReg(0) <= Din; end if; end process; Конкретно этот код не проверял, но должно работать Edited February 8, 2006 by =AK= Quote Share this post Link to post Share on other sites More sharing options...
izozella 0 February 14, 2006 Posted February 14, 2006 · Report post Сдвиговый регистр можно реализовать несколькими способами, смотря какая конфигурация - входы/выходы последовательные или параллельные, синхронный или асинхронный сброс/установка, с возможностью загрузки значения или без, ... Вариантов масса. Для примера, сдвиговый регистр с последовательным входом и выходом: 1) shreg <= shreg (6 downto 0) & SI; 2) for i in 0 to 6 loop shreg(i+1) <= shreg(i); end loop; hreg(0) <= SI; 3) используя предопределенные функции SLL, SRL и др. Для этого небходимо подключить библиотеку ieee.numeric_std или ieee.std_logic_arith или ieee.std_logic_unsigned или ieee.std_logic_signed Quote Share this post Link to post Share on other sites More sharing options...