copyleft: gplv3 added and set repo to public
[calu.git] / cpu / src / extension_7seg_b.vhd
1 --   `Deep Thought', a softcore CPU implemented on a FPGA
2 --
3 --  Copyright (C) 2010 Markus Hofstaetter <markus.manrow@gmx.at>
4 --  Copyright (C) 2010 Martin Perner <e0725782@student.tuwien.ac.at>
5 --  Copyright (C) 2010 Stefan Rebernig <stefan.rebernig@gmail.com>
6 --  Copyright (C) 2010 Manfred Schwarz <e0725898@student.tuwien.ac.at>
7 --  Copyright (C) 2010 Bernhard Urban <lewurm@gmail.com>
8 --
9 --  This program is free software: you can redistribute it and/or modify
10 --  it under the terms of the GNU General Public License as published by
11 --  the Free Software Foundation, either version 3 of the License, or
12 --  (at your option) any later version.
13 --
14 --  This program is distributed in the hope that it will be useful,
15 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 --  GNU General Public License for more details.
18 --
19 --  You should have received a copy of the GNU General Public License
20 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 library IEEE;
23 use IEEE.std_logic_1164.all;
24 use IEEE.numeric_std.all;
25
26 --use work.math_pkg.all;
27 use work.common_pkg.all;
28 use work.core_pkg.all;
29
30 use work.mem_pkg.all;
31 use work.extension_pkg.all;
32 use work.extension_7seg_pkg.all;
33
34 architecture behav of extension_7seg is
35
36 signal s_state, s_state_nxt : sseg_state_rec;
37 signal ext_reg_r  : extmod_rec;
38
39 begin
40
41 seg_syn: process(sys_clk, sys_res_n)
42
43 begin
44
45         if (sys_res_n = RESET_VALUE) then
46                 
47                 s_state.digit0 <= (others => '0');--set(0,7);
48                 s_state.digit1 <= (others => '0');--set(0,7);
49                 s_state.digit2 <= (others => '0');--set(0,7);
50                 s_state.digit3 <= (others => '0');--set(0,7);
51
52                 ext_reg_r.sel <='0';
53                 ext_reg_r.wr_en <= '0';
54                 ext_reg_r.byte_en <= (others => '0');
55                 ext_reg_r.data <= (others => '0');
56                 ext_reg_r.addr <= (others => '0');
57                 
58         elsif rising_edge(sys_clk) then
59                 
60                 s_state <= s_state_nxt;
61                 ext_reg_r <= ext_reg;
62                 
63         end if;
64         
65 end process; 
66
67 seg_asyn: process(s_state, ext_reg_r)   
68
69 begin
70         s_state_nxt <= s_state; 
71
72         if ext_reg_r.sel = '1' and ext_reg_r.wr_en = '1' then
73
74
75 --              case ext_reg_r.byte_en(1 downto 0) is
76 --              when "00" => null;
77 --                      s_state_nxt.digit0 <= digit_decode('0' & ext_reg_r.data(3 downto 0));
78 --                      s_state_nxt.digit1 <= digit_decode('0' & ext_reg_r.data(7 downto 4));
79 --                      s_state_nxt.digit2 <= digit_decode('0' & ext_reg_r.data(11 downto 8));
80 --                      s_state_nxt.digit3 <= digit_decode('0' & ext_reg_r.data(15 downto 12));
81 --              when others => 
82 --                      s_state_nxt.digit0 <= (others => '1');
83 --                      s_state_nxt.digit1 <= (others => '1');
84 --                      s_state_nxt.digit2 <= (others => '1');
85 --                      s_state_nxt.digit3 <= (others => '1');
86 --              end case;
87
88                 if (ext_reg_r.byte_en(0) = '1') then
89                         s_state_nxt.digit0 <= digit_decode('0' & ext_reg_r.data(3 downto 0));
90                         s_state_nxt.digit1 <= digit_decode('0' & ext_reg_r.data(7 downto 4));
91                 end if;
92                 if (ext_reg_r.byte_en(1) = '1') then
93                         s_state_nxt.digit2 <= digit_decode('0' & ext_reg_r.data(11 downto 8));
94                         s_state_nxt.digit3 <= digit_decode('0' & ext_reg_r.data(15 downto 12));
95                 end if;
96
97         end if;
98
99 end process; --ps2_next
100
101 seg_out: process(s_state)
102 begin
103         
104         o_digit0 <= not(s_state.digit0);
105         o_digit1 <= not(s_state.digit1);
106         o_digit2 <= not(s_state.digit2);
107         o_digit3 <= not(s_state.digit3);
108
109 end process;
110
111 end behav;