AABELLUS

laba5

May 21st, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.02 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_arith.all; -- CONV_STD_LOGIC_VECTOR(int, size)
  4. use std.textio.all;
  5.  
  6. entity transform_vec is
  7. end entity;
  8.  
  9. architecture arch of transform_vec is
  10.  
  11.     signal vec1:std_logic_vector(0 to 7):="X01ZW010";
  12.     signal vec2:std_logic_vector(0 to 7):="X01ZX010";
  13.     signal rvec1,rvec2:std_logic_vector(0 to 7);
  14.    
  15.     function transform_vec_to_x01z
  16.         (main_vec:std_logic_vector(0 to 7))
  17.         return std_logic_vector is   
  18.         variable final_vec : std_logic_vector(main_vec'range);
  19.     begin  
  20.         loopi: for i in main_vec'range loop
  21.             case main_vec(i) is
  22.                 when '0' => final_vec(i):= '0';
  23.                 when '1' => final_vec(i):= '1';
  24.                 when 'X' => final_vec(i):= 'X';
  25.                 when 'Z' => final_vec(i):= 'Z';
  26.                 when others => assert(false)
  27.                                report "Error value"
  28.                                severity error;
  29.             end case;
  30.         end loop loopi;
  31.         return final_vec;
  32.     end transform_vec_to_x01z;
  33. begin                                                
  34.     rvec1 <= transform_vec_to_x01z(vec1);        
  35.     rvec2 <= transform_vec_to_x01z(vec2);
  36. end;
Advertisement
Add Comment
Please, Sign In to add comment