From: Markus Hofstätter Date: Thu, 2 Dec 2010 16:11:09 +0000 (+0100) Subject: modified: first approach to pointers. not finished, alu missing etc. X-Git-Tag: bootrom_v1~98 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=calu.git;a=commitdiff_plain;h=ac25724c599f80d5b8c83eea332daa78aa767e8a modified: first approach to pointers. not finished, alu missing etc. --- diff --git a/cpu/src/alu_pkg.vhd b/cpu/src/alu_pkg.vhd index bb15c6a..7a9564e 100755 --- a/cpu/src/alu_pkg.vhd +++ b/cpu/src/alu_pkg.vhd @@ -15,6 +15,10 @@ package alu_pkg is sign : std_logic; carry : std_logic; end record; + + constant PADDR_WIDTH : integer := 2; + type pointers_t is array(0 to 2**PADDR_WIDTH-1) of gp_register_t; + subtype paddr_t is std_logic_vector(PADDR_WIDTH-1 downto 0); subtype status_t is byte_t; --type alu_interal_rec is record @@ -26,14 +30,12 @@ package alu_pkg is result_addr : gp_addr_t; status : status_rec; - --stackpointer : gp_register_t; alu_jump : std_logic; brpr : std_logic; reg_op : std_logic; mem_op : std_logic; - --new_val : std_logic; mem_en : std_logic; hw_op : std_logic; diff --git a/cpu/src/common_pkg.vhd b/cpu/src/common_pkg.vhd index 2379165..3790d0f 100755 --- a/cpu/src/common_pkg.vhd +++ b/cpu/src/common_pkg.vhd @@ -30,6 +30,7 @@ package common_pkg is constant NUM_OP_OPT_WIDTH : INTEGER := 6; constant COND_WIDTH : INTEGER := 4; + constant DATA_END_ADDR : integer := ((2**DATA_ADDR_WIDTH)-1); subtype instruction_word_t is std_logic_vector(WORD_WIDTH-1 downto 0); diff --git a/cpu/src/extension.vhd b/cpu/src/extension.vhd index ab53a3c..aa19e9d 100644 --- a/cpu/src/extension.vhd +++ b/cpu/src/extension.vhd @@ -17,14 +17,17 @@ entity extension_gpm is --System inputs clk : in std_logic; reset : in std_logic; - -- Standartinterface + -- general extension interface ext_reg : in extmod_rec; data_out : out gp_register_t; -- Input alu_nxt : in alu_result_rec; + paddr : in paddr_t; + pinc : in std_logic; + pwr_en : in std_logic; -- Ouput - psw : out status_rec - + psw : out status_rec; + pval : out gp_register_t ); diff --git a/cpu/src/extension_b.vhd b/cpu/src/extension_b.vhd index a035511..0c18a7d 100644 --- a/cpu/src/extension_b.vhd +++ b/cpu/src/extension_b.vhd @@ -11,26 +11,105 @@ use work.extension_pkg.all; architecture behav of extension_gpm is type gpm_internal is record status : status_rec; + preg : pointers_t; end record gpm_internal; signal reg, reg_nxt : gpm_internal; + begin syn : process (clk, reset) begin if (reset = RESET_VALUE) then reg.status <= ('0','0','0','0'); + reg.pointers <= (others => (std_logic_vector(to_unsigned(DATA_END_ADDR,DATA_ADDR_WIDTH))); elsif rising_edge(clk) then reg <= reg_nxt; end if; end process syn; -asyn : process (clk, reset, alu_nxt) +asyn : process (clk, reset, reg, alu_nxt, ext_reg, pval, pwr_en, pinc, paddr) + variable reg_nxt_v : gpm_internal; + variable incb : gp_register_t; + variable sel_pval : gp_register_t; begin - reg_nxt.status <= alu_nxt.status; -end process asyn; + reg_nxt_v := reg; + + psw <= reg.status; + data_out <= (others => '0'); + + incb := (others => '0'); + incb(0) := '1'; + if pinc = '1' then + incb := (others => '1'); + end if; + + if (ext_reg.sel = '1') and ext_reg.wr_en = '1' then + case ext_reg.addr(1 downto 0) is + when "00" => + if ext_reg.byte_en(0) = '1' then + reg_nxt_v.psw := (ext_reg.data(0),ext_reg.data(1),ext_reg.data(3),ext_reg.data(2)); + psw <= reg_nxt_v.psw; + end if; + when "01" => + --STACK_POINTER + if ext_reg.byte_en(0) = '1' then + reg_next_v.preg(0)(byte_t'range) := ext_reg.data(byte_t'range); + end if; + if ext_reg.byte_en(1) = '1' then + reg_next_v.preg(0)((byte_t'length*2)-1 downto byte_t'length) := + ext_reg.data((byte_t'length*2)-1 downto byte_t'length) ; + end if; + if ext_reg.byte_en(2) = '1' then + reg_next_v.preg(0)((byte_t'length*3)-1 downto byte_t'length*2) := + ext_reg.data((byte_t'length*3)-1 downto byte_t'length*2) ; + end if; + if ext_reg.byte_en(3) = '1' then + reg_next_v.preg(0)((byte_t'length*4)-1 downto byte_t'length*3) := + ext_reg.data((byte_t'length*4)-1 downto byte_t'length*3) ; + end if; + when others => null; + end case; + end if; -psw <= reg.status; + if (ext_reg.sel = '1') and wr_en = '0' then + case ext_reg.addr(1 downto 0) is + when "00" => + if ext_reg.byte_en(0) = '1' then + data_out(3 downto 0) <= (reg.status.sign, reg.status.carry, reg.status.oflo, reg.status.zero); + end if; + when "01" => + --STACK_POINTER + if ext_reg.byte_en(0) = '1' then + data_out(byte_t'range) <= reg.preg(0)(byte_t'range); + end if; + if ext_reg.byte_en(1) = '1' then + data_out((byte_t'length*2)-1 downto byte_t'length) <= + reg_preg(0)((byte_t'length*2)-1 downto byte_t'length) ; + end if; + if ext_reg.byte_en(2) = '1' then + data_out((byte_t'length*3)-1 downto 2*byte_t'length) <= + reg_preg(0)((byte_t'length*3)-1 downto 2*byte_t'length) ; + end if; + if ext_reg.byte_en(3) = '1' then + data_out((byte_t'length*4)-1 downto 3*byte_t'length) <= + reg_preg(0)((byte_t'length*4)-1 downto 3*byte_t'length) ; + end if; + when others => null; + end case; + end if; + + + sel_pval := reg_nxt_v.preg(unsigned(paddr)); + pval <= sel_pval; + if pwr_en = '1' then + reg_nxt_v.preg(to_integer(unsigned(paddr))) := std_logic_vector(unsigned(sel_pval)+unsigned(incb)); + end if; + + reg_nxt_v.status := alu_nxt.status; + + reg_nxt <= reg_nxt_v; +end process asyn; end behav; diff --git a/cpu/src/extension_pkg.vhd b/cpu/src/extension_pkg.vhd index 14253d6..daa2306 100644 --- a/cpu/src/extension_pkg.vhd +++ b/cpu/src/extension_pkg.vhd @@ -46,13 +46,17 @@ constant EXT_GPMP_ADDR: ext_addrid_t := x"FFFFFFF"; --System inputs clk : in std_logic; reset : in std_logic; - -- Standartinterface + -- general extension interface ext_reg : in extmod_rec; data_out : out gp_register_t; -- Input alu_nxt : in alu_result_rec; + paddr : in paddr_t; + pinc : in std_logic; + pwr_en : in std_logic; -- Ouput - psw : out status_rec + psw : out status_rec; + pval : out gp_register_t );