Carry Look-ahead Adder Design

Carry Look-ahead Adder(캐리 예측 덧셈기)
 전가산기를 이용한 Ripple Carry Adder는 많은 bit의 연산을 하려고 할 때
지연되는 시간이 길어지는 단점을 갖는다.
 CLA(Carry Look-ahead Adder)의 경우는 carry의 발생을 bit입력시
바로 계산하여 시간의 지연 없이 바로 덧셈연산을 수행할 수 있는 장점을 갖는다.
 * 참고: http://en.wikipedia.org/wiki/Carry_lookahead_adder

< RTL(Register Transfer Level) Schematic >

사용자 삽입 이미지
사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2009/04/10 19:44 2009/04/10 19:44

Leave a comment
[로그인][오픈아이디란?]

2's compliment & Absolute Unit


2의 보수를 만드는 Unit의 경우 부호가 없는 8bit의 데이터를 입력받은 후
1의 보수를 취하기 위해 ~ 연산을 수행하였다.
그 뒤에 1을 더하여 2의 보수를 구하고 그 결과를 16bit로 확장하기 위해 { 비트1, 비트2 }로 묶었다.

절대값을 취하는 Unit의 경우 입력받은 데이터는 10bit의 signed number이다.
따라서 입력한 bit가 양수인지 음수인지 파악하기 위해 최상위 비트(MSB)값에 대한 조건문을 추가한다.
그 값이 참일 경우 음수임을 의미하므로, 1을 빼고 1의 보수를 취해서 양수로 만들어준다.
MSB가 0인 경우 양수이므로, 입력받은 데이터를 그대로 출력한다.

사용자 삽입 이미지

< 2's Complement Unit Simulation Result >

사용자 삽입 이미지
< Absolute Unit >
< Test Bench >

more..

크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2009/03/27 18:30 2009/03/27 18:30

Leave a comment
[로그인][오픈아이디란?]

4-Bit Ripple Carry Adder


반가산기 모듈을 이용해서 전가산기를 만들었다.(2개의 반가산기와 OR gate를 결합)
전가산기 4개를 직렬로 구성하여 4bit Ripple Carry Adder를 만들게 된다.
아래 그림은 Test Bech를 이용한 Simulation결과이다.

사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2009/03/20 18:58 2009/03/20 18:58

Leave a comment
[로그인][오픈아이디란?]

10 input-4 output Encoder

                     <ABEL CODE>

module E10x4BCD;
title '10 inputs to 4 outputs - BCD Encoder';
Enc10x4 device 'P22V10';

"Input pins
I0,I1,I2,I3,I4,I5,I6,I7,I8,I9 pin 2,3,4,5,6,7,8,9,10,11;
"output pins
O1,O2,O3,O4 pin 23,22,21,20;

equations
O1 = I0#I2#I4#I6#I8;
O2 = I1#I2#I5#I6;
O3 = I3#I4#I5#I6;
O4 = I7#I8;
end E10x4BCD;

                 <VHDL CODE>

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity Enc10x4 is
    port ( input : in std_logic_vector(9 downto 0);
    output : out std_logic_vector(3 downto 0));
end Enc10x4;

architecture Enc10x4_arch of Enc10x4 is
begin
    process(input)
    begin
    if  (input = "0000000000" or input = "1000000000") then
       output <= "0000";
    else
       for i in 8 downto 0 loop
         if (input(i) >= '1') then
          output <= conv_std_logic_vector(i+1,4);
         end if
       end loop;         
    end if;
    end process;
end Enc10x4_arch;

사용자 삽입 이미지
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2008/03/25 19:03 2008/03/25 19:03

Leave a comment
[로그인][오픈아이디란?]

4 Bits to BCD Code

library IEEE;
use IEEE.std_logic_1164.all;

entity bcdconv is
    port ( digit_in : in std_logic_vector(3 downto 0);
    bcd_out : out std_logic_vector(4 downto 0));
end bcdconv;

architecture bcdconv_arch of bcdconv is
begin
    process(digit_in)
    begin
    if  (digit_in > "1001") then   
       bcd_out(4) <= '1';
       bcd_out(3) <= '0';
       bcd_out(2) <= digit_in(2) and digit_in(1);
       bcd_out(1) <= not digit_in(1);
       bcd_out(0) <= digit_in(0);
    else
       bcd_out(4) <= '0';         
       for i in 3 downto 0 loop
         bcd_out(i) <= digit_in(i);
       end loop;    
    end if;
    end process;
end bcdconv_arch;

사용자 삽입 이미지
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2008/03/22 17:39 2008/03/22 17:39

Leave a comment
[로그인][오픈아이디란?]

PGM for 74x49 (7 segments decoders)

        <ABEL CODE>

module SSEGDEC
title 'asdfas'
SEGDEC device 'P22V10';

"input pins
!BL pin 2;
D,C,B,A pin 3,4,5,6;
"output pins
Oa,Ob,Oc,Od,Oe,Of,Og pin 23,22,21,20,19,18,17;
Out = [Oa,Ob,Oc,Od,Oe,Of,Og];

equations
when (!BL==1) then Oa = (!A&!C)#(A&B&!D)#(A&C&!D)#(B&C&D)#(!A&D)#(!B&!C&D);
when (!BL==1) then Ob = (!C&!D)#(!A&!B&!D)#(A&B&!D)#(A&!B&D)#(!A&!C);
when (!BL==1) then Oc = (!B&!D)#(A&!D)#(A&!B)#(C&!D)#(!C&D);
when (!BL==1) then Od = (!A&!B&!C)#(A&!B&C)#(A&B&!C)#(A&B&!D)#(!A&C&D);
when (!BL==1) then Oe = (!A&!C)#(C&D)#(!A&B)#(B&D);
when (!BL==1) then Of = (!A&!B)#(!C&D)#(B&D)#(!B&C&!D)#(!A&C&!D);
when (!BL==1) then Og = (!A&B)#(A&D)#(!C&D)#(B&!C)#(!B&C&!D);
when (!BL==0) then Out = 0;
end SSEGDEC

        <VHDL CODE>

library IEEE;
use IEEE.std_logic_1164.all;

entity segdec is
 port ( num_in : in std_logic_vector(3 downto 0);
 num_out : out std_logic_vector(6 downto 0);
 BL_L : in std_logic );
end segdec;

architecture segdec_arch of segdec is
begin
 process(num_in, BL_L)
 begin
 if  (BL_L) = '1' then
        case  num_in is
   when "0000" => num_out <= "1111110";
   when "0001" => num_out <= "0110000";
   when "0010" => num_out <= "1101101";
   when "0011" => num_out <= "1111001";
   when "0100" => num_out <= "0110011";
   when "0101" => num_out <= "1011011";
   when "0110" => num_out <= "0011111";
   when "0111" => num_out <= "1110000";
   when "1000" => num_out <= "1111111";
   when "1001" => num_out <= "1110011";
   when "1010" => num_out <= "1110111";
   when "1011" => num_out <= "0011111";
   when "1100" => num_out <= "1001110";
   when "1101" => num_out <= "0111101";
   when "1110" => num_out <= "1001111";
   when "1111" => num_out <= "1000111";
   when others => num_out <= "0000000";
  end case;
  else
  num_out <= "0000000";
 end if;
 end process;
end segdec_arch;

사용자 삽입 이미지
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2008/03/22 16:18 2008/03/22 16:18

Leave a comment
[로그인][오픈아이디란?]

library IEEE;
use IEEE.Std_Logic_arith.all;
use IEEE.Std_Logic_1164.all;
entity conv is
    port ( input : in std_logic_vector (7 downto 0);   -- std_logic_vector 입력과 integer 입력
           input_i : in integer
           output: out std_logic_vector (7 downto 0);  -- std_logic_vector 출력과 integer 출력
           output_i : out integer );
end conv;

architecture conv_int of conv is                     -- std_logic_vector를 integer로 변환
  function conv_integer (X: std_logic_vector) return integer is
    variable result: integer;                         -- 결과로 result 변수 지정
    begin
      result := 0;                                     -- result값 초기화
      for i in X'range loop                            -- std_logic_vector 배열의 크기 만큼 반복
        result := result * 2;                          -- 2진수의 10진수 변경을 위해 2를 곱함
        case X(i) is
            when '0' | 'L' => null;
            when '1' | 'H' => result := result +1;     -- 배열의 값이 1일 때 result에 1을 더함
            when others    => null;
        end case;
      end loop;
      return result;
  end conv_integer;
 
  begin
  output_i <= conv_integer(input);                     -- 결과를 output_i에 출력
end conv_int;

architecture conv_vec of conv is                  -- integer를 std_logic_vector로 변환
  function conv_vector (Y, L: INTEGER) return std_logic_vector is
    constant y_length : integer := L;                 -- 변환할 std_logic_vector의 크기 지정
    variable result2: std_logic_vector ( y_length-1 downto 0); -- 지정한 크기의 vector 변수 지정
    variable y2: integer := Y;                        -- 입력한 integer를 y2 변수로 지정
    variable y_div, y_eq, y_res: integer := 0 ;       -- 몫,곱,나머지를 위한 변수를 지정, 초기화
   
begin
      if ( y2 >= 0) then                                -- 입력이 0보다 클 때 수행
          for i in 0 to y_length-1 loop                 -- 지정한 크기 만큼 반복 수행
            y_div := y2 / 2;                            -- 입력을 2로 나눔
            y_eq := y_div * 2;                          -- 2로 나눈 몫에 2를 곱하고
            y_res := y2 - y_eq;                         -- 원래의 값에서 빼서 나머지를 구함
            if (y_res >= 1) then                        -- 나머지가 1이면
              result2(i) := '1';                        --  std_logic_vector에 1을 입력
            else
              result2(i) := '0';                        --  std_logic_vector에 0을 입력
            end if;
            y2 := y2 / 2;                               -- 입력 값을 2로 나누고 위로 반복
          end loop;
      else
          for i in y_length-1 downto 0 loop             -- 입력이 0보다 작으면 모든 값을 0으로 지정
            result2(i) := '0';
          end loop;
      end if;
      return result2;  
  end conv_vector;
     
  begin
  output <= conv_vector(input_i,8);
end conv_vec;

<conv_integer 시뮬레이션 결과>
사용자 삽입 이미지
<conv_vector 시뮬레이션 결과>
사용자 삽입 이미지
참고 사이트: http://www.vhdl-online.de/tutorial/ , http://esd.cs.ucr.edu/labs/tutorial/
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2007/11/24 23:53 2007/11/24 23:53

Leave a comment
[로그인][오픈아이디란?]

ABEL - Prime number detector

<ABL 코드>
module pdetector
title '4 bit prime number detecting code by changkyu'
PDETECT device 'P16V8C';

"input pins
N0, N1, N2, N3 pin 2,3,4,5;

"output pins
F pin 19;

"definition
NUM = [N3, N2, N1, N0];

equations
F = !N3&N0 # N2&!N1&N0 # !N2&N1&N0 # !N3&!N2&N1;

test_vectors
([N3, N2, N1, N0] -> [F])
 [ 0,  0,  0,  0] -> [0];
 [ 0,  0,  0,  1] -> [1];
 [ 0,  0,  1,  0] -> [1];
 [ 0,  0,  1,  1] -> [1];
 [ 0,  1,  0,  0] -> [0];
 [ 0,  1,  0,  1] -> [1];
 [ 0,  1,  1,  0] -> [0];
 [ 0,  1,  1,  1] -> [1];
 [ 1,  0,  0,  0] -> [0];
 [ 1,  0,  0,  1] -> [0];
 [ 1,  0,  1,  0] -> [0];
 [ 1,  0,  1,  1] -> [1];
 [ 1,  1,  0,  0] -> [0];
 [ 1,  1,  0,  1] -> [1];
 [ 1,  1,  1,  0] -> [0];
 [ 1,  1,  1,  1] -> [0];

end pdetector
<JED 파일 일부분>
ABEL(tm) Version 2.00b  JEDEC file for: P16V8C
Created on: 15-Nov-107 02:06 PM
4 bit prime number detecting code by changkyu*
QP20* QF2194*
L0000
11111111111111111111111111111111
01111111111110111111111111111111
01111011011111111111111111111111
01110111101111111111111111111111
11110111101110111111111111111111
00000000000000000000000000000000
                (중간생략)
V0001 X0000XXXXNXNXXXXXXLN*
V0002 X1000XXXXNXNXXXXXXHN*
V0003 X0100XXXXNXNXXXXXXHN*
V0004 X1100XXXXNXNXXXXXXHN*
V0005 X0010XXXXNXNXXXXXXLN*
V0006 X1010XXXXNXNXXXXXXHN*
V0007 X0110XXXXNXNXXXXXXLN*
V0008 X1110XXXXNXNXXXXXXHN*
V0009 X0001XXXXNXNXXXXXXLN*
V0010 X1001XXXXNXNXXXXXXLN*
V0011 X0101XXXXNXNXXXXXXLN*
V0012 X1101XXXXNXNXXXXXXHN*
V0013 X0011XXXXNXNXXXXXXLN*
V0014 X1011XXXXNXNXXXXXXHN*
V0015 X0111XXXXNXNXXXXXXLN*
V0016 X1111XXXXNXNXXXXXXLN*
C1C5F*
4F60
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2007/11/17 02:13 2007/11/17 02:13

Leave a comment
[로그인][오픈아이디란?]

ABEL - 2x4 decoder

<ABL 코드>
module
decoder2to4
title '2 to 4 decoder abel code by changkyu'
DCODER device 'P16V8C';

"input pins
I0, I1 pin 2,3;
EN pin 4;

"output pins
Y0, Y1, Y2, Y3 pin 16,17,18,19;

"constants
X = .X.;

equations
Y0 = EN & !I0 & !I1;
Y1 = EN & !I1 & I0;
Y2 = EN & I1 & !I0;
Y3 = EN & I1 & I0;

test_vectors
([EN, I1, I0] -> [Y3, Y2, Y1, Y0])
[  0,.X.,.X.] -> [ 0,  0,  0,  0];
[  1,  0,  0] -> [ 0,  0,  0,  1];
[  1,  0,  1] -> [ 0,  0,  1,  0];
[  1,  1,  0] -> [ 0,  1,  0,  0];
[  1,  1,  1] -> [ 1,  0,  0,  0];

end decoder2to4
<DOC 출력>
ABEL(tm) Version 2.00b  -  Document Generator             15-Nov-107 01:28 PM
2 to 4 decoder abel code by changkyu
Chip diagram for Module decoder2to4

Device DCODER
                            P16V8C

                 ----------\       /----------
                 |         \     /           |
                 |          -----            |
                 |  1                    20  | Vcc            
                 |                           |
              I0 |  2                    19  | Y3             
                 |                           |
              I1 |  3                    18  | Y2             
                 |                           |
              EN |  4                    17  | Y1             
                 |                           |
                 |  5                    16  | Y0             
                 |                           |
                 |  6                    15  |                
                 |                           |
                 |  7                    14  |                
                 |                           |
                 |  8                    13  |                
                 |                           |
                 |  9                    12  |                
                 |                           |
             GND | 10                    11  |                
                 |                           |
                 |                           |
                 -----------------------------

end of module decoder2to4
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2007/11/17 02:05 2007/11/17 02:05

Leave a comment
[로그인][오픈아이디란?]

ABEL - Hamming Code

<ABL 코드>
module
Hamming_Code

title 'Hamming code converter'

HAMCVT device 'P22V10';

 

" Input pins

I1, I2, I3             pin 2, 3, 4;

 

" Output pins

D1, D2, D3             pin 23, 22, 21;

P1, P2, P3, P4         pin 20, 19, 18, 17;

T                      pin 16;

 

" Constant definition

L,H = 0,1;

M = 0;                 "even or odd set

 

equations

D1 = I1;

D2 = I2;

D3 = I3;

P1 = I2 $ I1 $ M;      "xor 연산을 통해 1 확인

P2 = I3 $ I1 $ M;

P3 = I3 $ I2 $ M;

T = I1 $ I2 $ I3;      "입력 데이터의 even parity를 구하기 위해 사용

P4 = T $ P1 $ P2 $ P3; "T와 패티티 비트에서 even parity를 구함

 

test_vectors

([I1, I2, I3] -> [D1, D2, D3, P1, P2, P3, P4])  "I1 I2 I3의 해밍코드

[  L,  L,  L] -> [ L,  L,  L,  L,  L,  L,  L];

[  L,  L,  H] -> [ L,  L,  H,  L,  H,  H,  H];

[  L,  H,  L] -> [ L,  H,  L,  H,  L,  H,  H];

[  L,  H,  H] -> [ L,  H,  H,  H,  H,  L,  L];

[  H,  L,  L] -> [ H,  L,  L,  H,  H,  L,  H];

[  H,  L,  H] -> [ H,  L,  H,  H,  L,  H,  L];

[  H,  H,  L] -> [ H,  H,  L,  L,  H,  H,  L];

[  H,  H,  H] -> [ H,  H,  H,  L,  L,  L,  H];

 

end Hamming_Code

<컴파일 결과>
FUSEMAP ABEL-PLD(tm) 3.21

Copyright 1983-1990 Data I/O Corp. All Rights Reserved.

module Hamming_Code

_device HAMCVT  'P22V10'

 29 of 132 terms used,  8 vectors included

FUSEMAP complete.  Time: 0 seconds

 

SIMULATE ABEL-PLD(tm) 3.20

Copyright 1983-1990 Data I/O Corp. All Rights Reserved.

module Hamming_Code

_device HAMCVT  'P22V10'

........

8 out of 8 vectors passed.

SIMULATE complete. Time: 0 seconds

 

DOCUMENT ABEL-PLD(tm) 3.20

Copyright 1983-1990 Data I/O Corp. All Rights Reserved.

module Hamming_Code

_device HAMCVT

DOCUMENT complete.  Time: 0 seconds

          * 참고 사이트: http://www.seas.upenn.edu/~ese201/abel/abel_primer.html
크리에이티브 커먼즈 라이센스
Creative Commons License

"HDL" 카테고리의 다른 글

Posted by downright

2007/11/17 02:01 2007/11/17 02:01

Leave a comment
[로그인][오픈아이디란?]