Presentation is loading. Please wait.

Presentation is loading. Please wait.

Flip-Flop 설계.

Similar presentations


Presentation on theme: "Flip-Flop 설계."— Presentation transcript:

1 Flip-Flop 설계

2 Contents Latch vs. Flip-Flop(FF) DFF
Synchronous reset vs. Asynchronous reset Enable Signal vs. variable 실습내용 Circular shifter Logical shifter Arithmetic shifter

3 Latch vs. Flip-Flop(FF)
Asynchronous(비동기) 입력에 의해 출력이 변화하는 기억소자 RS latch, Level-sensitive RS latch, JK latch Flip-Flop(FF) Clock을 사용 클럭에 따라 출력이 변화하는 기억소자 초기화를 위한 동기/비동기 입력이 있을 수 있음(reset) RSFF, DFF, JKFF, TFF clk d_in d_out(F/F) d_out(latch)

4 DFF 클럭 입력의 변화에 따라서 D가 Q로 천이
클럭의 상승에지(rising edge or positive edge) 또는 하강에지(falling edge or negative edge)에서 천이함 Reset과 enable 필요 D Q Q’ Reset’ Enable’ D Q Q’ 1

5 DFF Module entity dff is port( clk, reset, enable : in std_logic;
d : in std_logic; q, q_b: out std_logic ); end entity dff; architecture Behavioral of dff is signal in_q : std_logic; begin q <= in_q; q_b <= not in_q; process( clk, reset) if( reset = '0' ) then in_q <= '0'; elsif( clk = '1' and clk'event ) then if( enable = ‘1' ) then in_q <= d; end if; end process; end architecture Behavioral;

6 DFF Simulation 결과

7 Synchronous vs. Asynchronous Reset
입력 클럭이 변화할 때 작동 Asynchronous reset 입력 클럭과는 상관없이 작동 process( clk ) begin if( clk = '1' and clk'event ) then if( reset = '0' ) then in_q <= '0'; elsif( enable = '0' ) then process( clk, reset ) begin if( reset = '0' ) then in_q <= '0'; elsif( clk = '1' and clk'event ) then if( enable = '0' ) then

8 Enable Synchronous enable elsif( clk = '1' and clk'event ) then
if( enable = '0' ) then in_q <= '1'; else in_q <= d; end if;

9 Signal vs. Variable Ex.) process(clk) process(clk)
variable a : std_logic; begin if clk’event and clk=‘1’ then if rst_n = ‘0’ then d_out <= ‘0’; elsif load = ‘1’ then d_out <= d_in; a := d_out; end if; if a = ‘1’ then state <= “0001”; else state <= “1111”; end process; process(clk) begin if clk’event and clk=‘1’ then if rst_n = ‘0’ then d_out <= ‘0’; elsif load = ‘1’ then d_out <= d_in; sig <= d_out; end if; if sig = ‘1’ then state <= “0001”; else state <= “1111”; end process; 9

10 Shift register 2진 데이터 저장 클럭이 인가될 때 왼쪽 혹은 오른쪽 방향으로 데이터 쉬프트

11 Circular shift 쉬프트 연산시 최상위 혹은 최하위 비트를 버리지 않고 순환하여 최하위 혹은 최상위로 보내는 쉬프트
오른쪽 쉬프트 연산 최하위 비트가 최상위로 이동 왼쪽 쉬프트 연산 최상위 비트가 최하위로 이동 수행전 b3 b2 b1 b0 수행후 b0 b3 b2 b1 수행전 b3 b2 b1 b0 수행후 b2 b1 b0 b3

12 Logical shift 쉬프트 연산시 최상위 혹은 최하위 비트를 0으로 함 오른쪽 쉬프트 연산 왼쪽 쉬프트 연산
최하위 비트가 최상위로 이동 왼쪽 쉬프트 연산 최상위 비트가 최하위로 이동 수행전 b3 b2 b1 b0 수행후 b3 b2 b1 수행전 b3 b2 b1 b0 수행후 b2 b1 b0

13 Arithmetic shift 쉬프트 연산시 부호비트를 유지하면서 쉬프트 오른쪽 쉬프트 연산 왼쪽 쉬프트 연산
양수 일 때 부호 비트는 0으로 유지/음수 일 때 부호 비트는 1로 유지 왼쪽 쉬프트 연산 Logical shift 연산의 왼쪽 쉬프트와 같음 예) 1101 = -3, 왼쪽 산술쉬프트시 1010=-6, 오른쪽 산술쉬프트시 1110=-2 수행전 b3 b2 b1 b0 수행후 b3 b2 b1 수행전 b3 b2 b1 b0 수행후 b2 b1 b0

14 Shift register 실습내용 Mode 입력에 따른 Circular, Logical, Arithmetic shifter 설계 비동기 Reset 및 동기 enable에 의한 동작 제어 Reset Enable MODE Direction CLK Q L X H 00 Parallel IN 01 Circular R Circular L 10 Logical R Logical L 11 Arithmetic R Arithmetic L

15 Shift register Entity entity shifter is
port( clk, reset, enable, dir : in std_logic; mode : in std_logic_vector( 1 downto 0 ); pi : in std_logic_vector( 3 downto 0 ); q : out std_logic_vector( 3 downto 0 ) ); end entity shifter;

16 Shift register Simulation 결과

17 Shift register 주어진 entity를 사용할 것 Clock 주기는 10 ns로 할 것
Testbench는 다음을 따를 것 wait for 103 ns; pi <= “1010”; enable <= '1'; wait for 50 ns; reset <= '1'; enable <= '0'; wait for 60 ns; wait for 100 ns; pi <= "1011"; wait for 40 ns; mode <= "01"; wait for 20 ns; wait for 20 ns; dir <= '1'; wait for 40 ns; mode <= "10"; dir <= '0'; mode <= "00"; pi <= "1010"; mode <= "11"; reset <= '0';


Download ppt "Flip-Flop 설계."

Similar presentations


Ads by Google