bff38e9a11c80fa38e1044e0c1560f932ebde021
[calu.git] / cpu / src / extension_b.vhd
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use IEEE.numeric_std.all;
4
5 use work.common_pkg.all;
6 use work.core_pkg.all;
7
8 use work.mem_pkg.all;
9 use work.extension_pkg.all;
10
11 architecture behav of extension_gpm is
12
13 type pointers_t is array( 0 to ((2**(paddr_t'length))-1)) of ext_addr_t;
14
15 type gpm_internal is record
16     status : status_rec;
17         preg : pointers_t;
18 end record gpm_internal;
19
20 signal reg, reg_nxt : gpm_internal;
21
22
23 begin
24 syn : process (clk, reset)
25 begin
26         if (reset = RESET_VALUE) then
27                 reg.status <= (others=>'0');
28                 reg.preg <= (others => (std_logic_vector(to_unsigned(DATA_END_ADDR,reg.preg(0)'length))));
29         elsif rising_edge(clk) then
30                 reg <= reg_nxt;
31         end if;
32 end process syn;
33
34 asyn : process (clk, reset, reg, psw_nxt, ext_reg, pwr_en, pinc, paddr)
35         variable reg_nxt_v : gpm_internal;
36         variable incb : ext_addr_t;
37         variable sel_pval, sel_pval_nxt : ext_addr_t;
38         
39         variable data_out_v : gp_register_t;
40         variable data_v : gp_register_t;
41         variable tmp_data  : gp_register_t;
42         
43 begin
44         reg_nxt_v := reg;
45         data_v  := ext_reg.data;
46
47         psw <= reg.status;
48         
49         data_out_v := (others => '0');
50
51         incb(0) := '1';
52         if pinc = '1' then
53                 incb(incb'high downto 1) := (others => '1');
54         else
55                 incb(incb'high downto 1) := (others => '0');
56         end if;
57
58         sel_pval:= reg_nxt_v.preg(0);
59         sel_pval_nxt := std_logic_vector(unsigned(sel_pval)+unsigned(incb));
60         if pwr_en = '1' then
61                 reg_nxt_v.preg(0) := sel_pval_nxt;
62         end if;
63
64         reg_nxt_v.status := psw_nxt;
65         
66         reg_nxt <= reg_nxt_v;
67         data_out <= data_out_v;
68         
69         pval <= (others =>'0');
70         pval(pval'high downto BYTEADDR) <= sel_pval;
71         pval_nxt <= (others =>'0');
72         pval_nxt(pval'high downto BYTEADDR) <= sel_pval_nxt;
73 end process asyn;
74
75 end behav;
76