Differences
This shows you the differences between two versions of the page.
— |
synthesizeable_vhdl-model-library:patras:special [2017/03/10 15:25] (current) SSE Minion created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SPECIAL COMPONENTS library ====== | ||
+ | The SPECIAL COMPONENTS library consists of the following 6 generic components: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | |||
+ | The SPECIAL COMPONENTS library can be verified with this testbench: [[.: | ||
+ | |||
+ | ===== bcd_ss ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | -- bcd_ss Entity Description | ||
+ | entity bcd_ss is | ||
+ | port( | ||
+ | Din: in unsigned(3 downto 0); | ||
+ | EN, L: in std_ulogic; | ||
+ | a, b, c, d, e, f, g: out std_ulogic | ||
+ | -------------------- | ||
+ | -- -- | ||
+ | -- | ||
+ | -- f |-| b -- | ||
+ | -- e,g |-| c -- | ||
+ | -- | ||
+ | -- | ||
+ | -- -- | ||
+ | -------------------- | ||
+ | ); | ||
+ | end bcd_ss; | ||
+ | |||
+ | -- bcd_ss Architecture Description | ||
+ | architecture rtl of bcd_ss is | ||
+ | signal l_d: unsigned(3 downto 0) : | ||
+ | signal error : std_ulogic; | ||
+ | begin | ||
+ | Decoder_Process: | ||
+ | begin | ||
+ | if L=' | ||
+ | l_d< | ||
+ | end if; | ||
+ | end process Decoder_Process; | ||
+ | |||
+ | error <= ' | ||
+ | |||
+ | a <= ' | ||
+ | b <= ' | ||
+ | c <= ' | ||
+ | d <= ' | ||
+ | | ||
+ | e <= ' | ||
+ | | ||
+ | | ||
+ | f <= ' | ||
+ | | ||
+ | g <= ' | ||
+ | | ||
+ | end rtl; | ||
+ | </ | ||
+ | |||
+ | ===== hex_ss ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | -- hex_ss Entity Description | ||
+ | entity hex_ss is | ||
+ | port( | ||
+ | Din: in unsigned(3 downto 0); | ||
+ | EN, L: in std_ulogic; | ||
+ | a, b, c, d, e, f, g: out std_ulogic | ||
+ | |||
+ | -------------------- | ||
+ | -- -- | ||
+ | -- | ||
+ | -- f |-| b -- | ||
+ | -- e,g |-| c -- | ||
+ | -- | ||
+ | -- | ||
+ | -- -- | ||
+ | -------------------- | ||
+ | |||
+ | ); | ||
+ | end hex_ss; | ||
+ | |||
+ | -- hex_ss Architecture Description | ||
+ | architecture rtl of hex_ss is | ||
+ | signal l_d: unsigned(3 downto 0) : | ||
+ | signal error : std_ulogic; | ||
+ | begin | ||
+ | |||
+ | Decoder_Process: | ||
+ | begin | ||
+ | if L=' | ||
+ | l_d< | ||
+ | end if; | ||
+ | end process Decoder_Process; | ||
+ | |||
+ | error <= not EN; | ||
+ | |||
+ | a <= ' | ||
+ | l_d=" | ||
+ | b <= ' | ||
+ | l_d=" | ||
+ | c <= ' | ||
+ | l_d=" | ||
+ | d <= ' | ||
+ | l_d=" | ||
+ | e <= ' | ||
+ | l_d=" | ||
+ | f <= ' | ||
+ | l_d=" | ||
+ | g <= ' | ||
+ | l_d=" | ||
+ | end rtl; | ||
+ | </ | ||
+ | |||
+ | ===== nrz_hdb3 ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # HDB3 : High Density Bipolar 3). # | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | -- nrz_hdb3 Entity Description | ||
+ | entity nrz_hdb3 is | ||
+ | port( | ||
+ | RES, CLK, NRZ: in std_ulogic; | ||
+ | POS, NEG: out std_ulogic | ||
+ | ); | ||
+ | end nrz_hdb3; | ||
+ | |||
+ | -- nrz_hdb3 Architecture Description | ||
+ | architecture rtl of nrz_hdb3 is | ||
+ | signal q: unsigned(3 downto 0); | ||
+ | signal zero, vl, ch, pos_neg, qzh: std_ulogic; | ||
+ | |||
+ | begin | ||
+ | ch<=vl xor pos_neg; | ||
+ | zero< | ||
+ | qzh< | ||
+ | |||
+ | POS< | ||
+ | NEG< | ||
+ | |||
+ | NRZ_Process: | ||
+ | begin | ||
+ | if (RES=' | ||
+ | q< | ||
+ | | ||
+ | pos_neg< | ||
+ | elsif (rising_edge(CLK)) then | ||
+ | q(0)< | ||
+ | q(1)< | ||
+ | q(3 downto 2)<=q(2 downto 1); | ||
+ | if (zero=' | ||
+ | vl< | ||
+ | end if; | ||
+ | if(((zero and (not(ch))) or q(3)) = ' | ||
+ | pos_neg< | ||
+ | end if; | ||
+ | end if; | ||
+ | end process NRZ_Process; | ||
+ | end rtl; | ||
+ | </ | ||
+ | |||
+ | ===== hdb3_nrz ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | -- hdb3_nrz Entity Description | ||
+ | entity hdb3_nrz is | ||
+ | port( | ||
+ | RES, CLK, POS, NEG: in std_ulogic; | ||
+ | NRZ, ERR: out std_ulogic | ||
+ | ); | ||
+ | end hdb3_nrz; | ||
+ | |||
+ | -- hdb3_nrz Architecture Description | ||
+ | architecture rtl of hdb3_nrz is | ||
+ | signal s: unsigned(2 downto 0); | ||
+ | signal o_pos, o_neg, q, vln: std_ulogic; | ||
+ | |||
+ | begin | ||
+ | vln< | ||
+ | NRZ< | ||
+ | ERR< | ||
+ | |||
+ | HDB3_Process: | ||
+ | begin | ||
+ | if (RES=' | ||
+ | s< | ||
+ | | ||
+ | o_neg< | ||
+ | q< | ||
+ | elsif (rising_edge(CLK)) then | ||
+ | o_pos< | ||
+ | o_neg< | ||
+ | s(0)< | ||
+ | s(2 downto 1)<=s(1 downto 0); | ||
+ | q< | ||
+ | end if; | ||
+ | end process HDB3_Process; | ||
+ | end rtl; | ||
+ | </ | ||
+ | |||
+ | ===== bcdN_bin ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # error output. | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | ENTITY bcdX_bin IS | ||
+ | GENERIC(X : integer := 2); | ||
+ | PORT( | ||
+ | D: IN unsigned((3*X+1) DOWNTO 0); | ||
+ | Q: OUT unsigned((4*X-1) DOWNTO 0); | ||
+ | E: OUT std_ulogic | ||
+ | ); | ||
+ | END bcdX_bin; | ||
+ | |||
+ | -- bcNx_bin Architecture Description | ||
+ | ARCHITECTURE rtl OF bcdx_bin IS | ||
+ | CONSTANT N: integer :=4*X; -- width of D in bits | ||
+ | CONSTANT M: integer :=X; -- width of D in bcd digits | ||
+ | BEGIN | ||
+ | Convert_Process: | ||
+ | VARIABLE p: unsigned(N+3 DOWNTO 0); | ||
+ | VARIABLE error: std_ulogic: | ||
+ | BEGIN | ||
+ | p: | ||
+ | error: | ||
+ | if (D(N-1 DOWNTO N-4)> | ||
+ | error: | ||
+ | END if; | ||
+ | FOR i IN M-2 DOWNTO 0 loop | ||
+ | if (d((i*4)+3 downto i*4)>" | ||
+ | error: | ||
+ | END if; | ||
+ | p:=p(N-1 downto 0) * " | ||
+ | Conv_Unsigned(Conv_Integer((' | ||
+ | END loop; | ||
+ | Q< | ||
+ | E< | ||
+ | END process Convert_Process; | ||
+ | END rtl; | ||
+ | </ | ||
+ | |||
+ | ===== bin_bcdN ===== | ||
+ | <code vhdl special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # error output. | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | |||
+ | -- bin_bcdX Entity Description | ||
+ | ENTITY bin_bcdX IS | ||
+ | GENERIC(X : integer := 2); | ||
+ | PORT( | ||
+ | D: IN unsigned((4*X-1) DOWNTO 0); | ||
+ | Q: OUT unsigned((3*X+1) DOWNTO 0); | ||
+ | E: OUT std_ulogic | ||
+ | ); | ||
+ | end bin_bcdx; | ||
+ | |||
+ | -- bin_bcdx Architecture Description | ||
+ | ARCHITECTURE rtl OF bin_bcdX IS | ||
+ | CONSTANT N: integer :=3*X+2; -- length of input in bits | ||
+ | CONSTANT M: integer :=X; -- length of output in BCD digits | ||
+ | BEGIN | ||
+ | Convert_Process: | ||
+ | VARIABLE r: unsigned(N+3 DOWNTO 0); | ||
+ | BEGIN | ||
+ | r: | ||
+ | IF D(N-1 DOWNTO N-3)>" | ||
+ | r(3 DOWNTO 0): | ||
+ | ELSE | ||
+ | r(3 DOWNTO 0): | ||
+ | END IF; | ||
+ | FOR i IN 0 TO N-5 loop | ||
+ | r: | ||
+ | FOR j IN 0 TO M-1 loop | ||
+ | IF j*3<i+2 THEN | ||
+ | IF r((j*4)+3 DOWNTO j*4)>" | ||
+ | r((j*4)+3 DOWNTO j*4): | ||
+ | END IF; | ||
+ | END IF; | ||
+ | END loop; | ||
+ | END loop; | ||
+ | r: | ||
+ | Q< | ||
+ | IF Conv_Integer(r(r' | ||
+ | E< | ||
+ | ELSE | ||
+ | E< | ||
+ | END IF; | ||
+ | END PROCESS Convert_Process; | ||
+ | END rtl; | ||
+ | </ | ||
+ | |||
+ | ===== Testbench ===== | ||
+ | <code vhdl test_special.vhd> | ||
+ | -- ############################################################################ | ||
+ | -- # Project | ||
+ | -- # # | ||
+ | -- # Filename | ||
+ | -- # # | ||
+ | -- # Component | ||
+ | -- # # | ||
+ | -- # Model : rtl # | ||
+ | -- # # | ||
+ | -- # Designer | ||
+ | -- # Institute | ||
+ | -- # Date : | ||
+ | -- ############################################################################ | ||
+ | |||
+ | library IEEE; | ||
+ | use IEEE.std_logic_1164.all; | ||
+ | use IEEE.std_logic_arith.all; | ||
+ | use work.useful_functions.ALL; | ||
+ | |||
+ | ENTITY test_special IS | ||
+ | END test_special; | ||
+ | |||
+ | |||
+ | ARCHITECTURE rtl OF test_special IS | ||
+ | |||
+ | | ||
+ | GENERIC(x : INTEGER := 2); | ||
+ | PORT( | ||
+ | D: IN unsigned((3*x+1) DOWNTO 0); | ||
+ | Q: OUT unsigned((4*x-1) DOWNTO 0); | ||
+ | E: OUT std_ulogic | ||
+ | ); | ||
+ | END COMPONENT; | ||
+ | |||
+ | | ||
+ | GENERIC(x : INTEGER := 2); | ||
+ | PORT( | ||
+ | D: IN unsigned((4*x-1) DOWNTO 0); | ||
+ | Q: OUT unsigned((3*x+1) DOWNTO 0); | ||
+ | E: OUT std_ulogic | ||
+ | ); | ||
+ | END COMPONENT; | ||
+ | |||
+ | FOR dec1 : dec_1 USE ENTITY WORK.bcdx_bin(rtl); | ||
+ | FOR dec2 : dec_2 USE ENTITY WORK.bin_bcdx(rtl); | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | BEGIN | ||
+ | dec1: dec_1 | ||
+ | GENERIC MAP(x => 2) | ||
+ | PORT MAP( | ||
+ | D => bcd_input, | ||
+ | Q => bin_output, | ||
+ | E => error1); | ||
+ | |||
+ | dec2: dec_2 | ||
+ | GENERIC MAP(x => 2) | ||
+ | PORT MAP ( | ||
+ | D => bin_output, | ||
+ | Q => bcd_output, | ||
+ | E => error2); | ||
+ | |||
+ | bcd_input < | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | END rtl; | ||
+ | </ | ||