added: alu jumps
authorMarkus Hofstätter <markus.hofstaetter@gmx.net>
Wed, 1 Dec 2010 15:14:16 +0000 (16:14 +0100)
committerMarkus Hofstätter <markus.hofstaetter@gmx.net>
Wed, 1 Dec 2010 15:14:16 +0000 (16:14 +0100)
cpu/src/alu.vhd
cpu/src/alu_b.vhd
cpu/src/alu_pkg.vhd
cpu/src/common_pkg.vhd

index b68e7c012e75c07501a726854a98c0707fb4957d..82656ab0b28e494f3e0a845218449c0ac852adce 100755 (executable)
@@ -17,7 +17,8 @@ entity alu is
                        op_group : in op_info_t;\r
                        left_operand : in gp_register_t;\r
                        right_operand : in gp_register_t;
-                        displacement : in gp_register_t;\r
+                        displacement : in gp_register_t;
+                       prog_cnt    : in instr_addr_t;\r
                        op_detail : in op_opt_t;\r
                        alu_state  : in alu_result_rec;\r
                        alu_result : out alu_result_rec;
index 340536561a4e7e9f407c9ba8b28be2afe2235f4f..8399d6087e835d11d1375fc5a43e4c7d5bf10c27 100755 (executable)
@@ -46,21 +46,24 @@ calc: process(left_operand, right_operand,displacement, cond, op_group, op_detai
        variable res_prod : std_logic;\r
        variable cond_met : std_logic;\r
        variable mem_en : std_logic;
-        variable mem_op : std_logic;\r
+        variable mem_op : std_logic;
+       variable alu_jmp : std_logic;\r
 begin\r
        result_v := alu_state;\r
        \r
-       result_v.result := add_result.result;\r
        res_prod := '1';\r
        mem_en := '0';
-        mem_op := '0';\r
-        addr <= add_result.result;
+        mem_op := '0';
+       alu_jump := '0';\r
+  
         left <= left_operand;
         right <= right_operand;
 
         addr <= add_result.result;
         data <= right_operand;\r
-       \r
+       
+       result_v.result := add_result.result;
+\r
        case cond is\r
        when COND_NZERO =>\r
                cond_met := not(alu_state.status.zero);\r
@@ -96,7 +99,9 @@ begin
                cond_met := '0';\r
        when others => null;\r
        end case;\r
-       \r
+       
+       cond_met := cond_met and (alu_state.alu_jmp xnor alu_state.brpr);
+\r
        case op_group is\r
        when ADDSUB_OP =>\r
                result_v := add_result;\r
@@ -119,7 +124,13 @@ begin
                 if op_detail(ST_OPT) = '1' then
                         right <= displacement;
                         mem_en := '1';
-                end if;\r
+                end if;
+       when JMP_OP =>
+               if op_detail(JMP_REG_OPT) = '0' then
+                       left <= prog_cnt;
+               end if;
+               result_v.alu_jmp := '1';
+       when JMP_ST_OP => null;\r
        end case;\r
        \r
 \r
@@ -137,6 +148,7 @@ begin
        result_v.reg_op := not(op_detail(NO_DST_OPT)) and res_prod and cond_met;\r
        result_v.mem_en := mem_en and cond_met;
         result_v.mem_op := mem_op and cond_met;
+       result_v.alu_jmp := alu_jmp and cond_met;
         \r
        alu_result <= result_v;\r
        \r
index 16c1099ace925b32aefa2dda682b4e6398200557..f1c99dc317aae28d2233df2158e8c99407147c86 100755 (executable)
@@ -85,6 +85,7 @@ package alu_pkg is
                        left_operand : in gp_register_t;
                        right_operand : in gp_register_t;
                         displacement : in gp_register_t;
+                       prog_cnt : in instr_addr_t;
                        op_detail : in op_opt_t;
                        alu_state  : in alu_result_rec;
                        alu_result : out alu_result_rec;
index dd6350c8a020a5508e153033b99ed10aa185ed41..03e61cd8c39c07cfa79967462c103d42d80fd625 100755 (executable)
@@ -52,14 +52,15 @@ package common_pkg is
        constant ARITH_OPT : integer := 1;
        
        constant CARRY_OPT : integer := 2;
-       constant ST_OPT  : integer := 2;
 
        constant RIGHT_OPT : integer := 3;
+       constant JMP_REG_OPT : integer := 3;
+       constant ST_OPT  : integer := 3;
        
        constant NO_PSW_OPT : integer := 4;--no sharing
        constant NO_DST_OPT : integer := 5; --no sharing
        
-       type op_info_t is (ADDSUB_OP,AND_OP,OR_OP, XOR_OP,SHIFT_OP, LDST_OP);
+       type op_info_t is (ADDSUB_OP,AND_OP,OR_OP, XOR_OP,SHIFT_OP, LDST_OP, JMP_OP, JMP_ST_OP);
        subtype op_opt_t is std_logic_vector(NUM_OP_OPT_WIDTH-1 downto 0);
        
        
@@ -106,6 +107,7 @@ package common_pkg is
                brpr : std_logic;
 
                displacement : gp_register_t;
+               prog_cnt     : instr_addr_t;
                
                src1 : gp_register_t;
                src2 : gp_register_t;