OpenCores
URL https://opencores.org/ocsvn/signed_unsigned_multiplier_and_divider/signed_unsigned_multiplier_and_divider/trunk

Subversion Repositories signed_unsigned_multiplier_and_divider

[/] [signed_unsigned_multiplier_and_divider/] [trunk/] [sequencer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    10:09:31 03/10/2018 
6
-- Design Name: 
7
-- Module Name:    sequencer - 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
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
use work.sys_primegen_package.all;
32
 
33
entity sequencer is
34
    Port ( reset : in  STD_LOGIC;
35
           clk : in  STD_LOGIC;
36
           operation : in  STD_LOGIC_VECTOR (2 downto 0);
37
           condition : in  STD_LOGIC;
38
           directvalue : in  STD_LOGIC_VECTOR (7 downto 0);
39
           uIP : out  STD_LOGIC_VECTOR (7 downto 0));
40
end sequencer;
41
 
42
architecture Behavioral of sequencer is
43
 
44
type ip_stack is array(0 to 3) of integer range 0 to 255;
45
 
46
signal ip: ip_stack;
47
signal ip_sp: integer range 0 to 3; -- 2 bit "stack pointer" allows 4 level nesting
48
 
49
begin
50
 
51
setnextip: process(reset, clk, operation, condition, directvalue)
52
begin
53
        if (reset = '1') then
54
                ip_sp <= 0;
55
                ip(0) <= 0;
56
        else
57
                if (rising_edge(clk)) then
58
                        case operation is
59
                                when if_next_else_next =>
60
                                        ip(ip_sp) <= ip(ip_sp) + 1;
61
 
62
                                when if_next_else_repeat =>
63
                                        if (condition = '1') then
64
                                                ip(ip_sp) <= ip(ip_sp) + 1;
65
                                        end if;
66
 
67
                                when if_goto_else_next  =>
68
                                        if (condition = '1') then
69
                                                ip(ip_sp) <= to_integer(unsigned(directvalue));
70
                                        else
71
                                                ip(ip_sp) <= ip(ip_sp) + 1;
72
                                        end if;
73
 
74
                                when if_gosub_else_next =>
75
                                        if (condition = '1') then
76
                                                ip(ip_sp) <= ip(ip_sp) + 1;
77
                                                ip(ip_sp + 1) <= to_integer(unsigned(directvalue));
78
                                                ip_sp <= ip_sp + 1;
79
                                        else
80
                                                ip(ip_sp) <= ip(ip_sp) + 1;
81
                                        end if;
82
 
83
                                when if_gosub_else_repeat =>
84
                                        if (condition = '1') then
85
                                                ip(ip_sp) <= ip(ip_sp) + 1;
86
                                                ip(ip_sp + 1) <= to_integer(unsigned(directvalue));
87
                                                ip_sp <= ip_sp + 1;
88
                                        end if;
89
 
90
                                when if_return_else_next =>
91
                                        if (condition = '1') then
92
                                                ip_sp <= ip_sp - 1;
93
                                        else
94
                                                ip(ip_sp) <= ip(ip_sp) + 1;
95
                                        end if;
96
 
97
                                when if_goto_else_start =>
98
                                        if (condition = '1') then
99
                                                ip(ip_sp) <= to_integer(unsigned(directvalue));
100
                                        else
101
                                                ip_sp <= 0;
102
                                                ip(0) <= 0;
103
                                        end if;
104
 
105
                                when others =>
106
                                        null;
107
                        end case;
108
                end if;
109
        end if;
110
end process;
111
 
112
with ip_sp select
113
        uIP <=  std_logic_vector(to_unsigned(ip(0), 8)) when 0,
114
                                std_logic_vector(to_unsigned(ip(1), 8)) when 1,
115
                                std_logic_vector(to_unsigned(ip(2), 8)) when 2,
116
                                std_logic_vector(to_unsigned(ip(3), 8)) when others;
117
 
118
end Behavioral;
119
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.