Forum: Test Formeltest mit LaTeX


von scherg (Gast)


Lesenswert?

Latex Formel test

: Bearbeitet durch Admin
von Detlef _. (detlef_a)


Lesenswert?

1
----------------------------------------------------------------------------------
2
-- Company:
3
-- Engineer:
4
--
5
-- Create Date:    14:35:25 06/11/2015
6
-- Design Name:
7
-- Module Name:    Binary2bcd - Behavioral
8
-- Project Name:
9
-- Target Devices:
10
-- Tool versions:
11
-- Description:
12
--
13
-- Dependencies:
14
--
15
-- Revision:
16
-- Revision 0.01 - File Created
17
-- Additional Comments:
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use ieee.std_logic_unsigned.all;
23
entity Binary2bcd is
24
    Port ( binary_in : in  STD_LOGIC_VECTOR (7 downto 0);
25
           sela : in  STD_LOGIC;
26
           selb : in  STD_LOGIC;
27
           segment7 : out  STD_LOGIC_VECTOR (6 downto 0));
28
end Binary2bcd;
29
30
architecture Behavioral of Binary2bcd is
31
begin
32
33
p1: process (sela, selb, binary_in) is
34
 variable hex_src : std_logic_vector (4 downto 0) ;
35
 variable bcd     : std_logic_vector (11 downto 0) ;
36
 variable act : STD_LOGIC_VECTOR (3 downto 0);
37
 variable ones : STD_LOGIC_VECTOR (3 downto 0);
38
 variable tens : STD_LOGIC_VECTOR (3 downto 0);
39
 variable huns : STD_LOGIC_VECTOR (3 downto 0);
40
 variable sel : STD_LOGIC_VECTOR (1 downto 0);
41
42
begin
43
44
    bcd             := (others => '0') ;
45
    bcd(2 downto 0) := binary_in(7 downto 5) ;
46
    hex_src         := binary_in(4 downto 0) ;
47
    sel             := sela & selb;
48
49
    for i in hex_src'range loop
50
        if bcd(3 downto 0) > "0100" then
51
            bcd(3 downto 0) := bcd(3 downto 0) + "0011" ;
52
        end if ;
53
        if bcd(7 downto 4) > "0100" then
54
            bcd(7 downto 4) := bcd(7 downto 4) + "0011" ;
55
        end if ;
56
        -- No roll over for hundred digit, since in 0 .. 2
57
58
        bcd := bcd(10 downto 0) & hex_src(hex_src'left) ; -- shift bcd + 1
59
new entry
60
        hex_src := hex_src(hex_src'left - 1 downto hex_src'right) & '0' ;
61
-- shift src + pad with 0
62
    end loop ;
63
64
    huns := bcd(11 downto 8);
65
    tens := bcd(7  downto 4);
66
    ones := bcd(3  downto 0);
67
68
 case sel is
69
   when "00" =>   act := huns;
70
   when "01" =>   act := tens;
71
   when "10" =>   act := ones;
72
   when "11" =>   act := ones;
73
    when others => act := ones;
74
 end case;
75
 case act is
76
    when "0000"=> segment7 <="0000001";  -- '0'
77
    when "0001"=> segment7 <="1001111";  -- '1'
78
    when "0010"=> segment7 <="0010010";  -- '2'
79
    when "0011"=> segment7 <="0000110";  -- '3'
80
    when "0100"=> segment7 <="1001100";  -- '4'
81
    when "0101"=> segment7 <="0100100";  -- '5'
82
    when "0110"=> segment7 <="0100000";  -- '6'
83
    when "0111"=> segment7 <="0001111";  -- '7'
84
    when "1000"=> segment7 <="0000000";  -- '8'
85
    when "1001"=> segment7 <="0000100";  -- '9'
86
    when others=> segment7 <="1111111";
87
 end case;
88
 ---segment7 <= bcd(6 downto 0);
89
end process;
90
end Behavioral;

: Bearbeitet durch User
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.