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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [sm.vhd] - Blame information for rev 141

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 134 jguarin200
--! @file sm.vhd
2
--! @brief Maquina de Estados. Controla la operación interna y genera los mecanismos de sincronización con el exterior (interrupciones). 
3
--! @author Julián Andrés Guarín Reyes
4
--------------------------------------------------------------
5
-- RAYTRAC
6
-- Author Julian Andres Guarin
7
-- sm.vhd
8
-- This file is part of raytrac.
9
-- 
10
--     raytrac is free software: you can redistribute it and/or modify
11
--     it under the terms of the GNU General Public License as published by
12
--     the Free Software Foundation, either version 3 of the License, or
13
--     (at your option) any later version.
14
-- 
15
--     raytrac is distributed in the hope that it will be useful,
16
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
17
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
--     GNU General Public License for more details.
19
-- 
20
--     You should have received a copy of the GNU General Public License
21
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
 
24
library ieee;
25
use ieee.std_logic_1164.all;
26 139 jguarin200
use ieee.std_logic_unsigned.all;
27 134 jguarin200
 
28
 
29
 
30
entity sm is
31
        port (
32
 
33 139 jguarin200
                clk,rst:in std_logic;
34
                add0,add1:out std_logic_vector (8 downto 0);
35
                iq:in std_logic_vector(31 downto 0);
36
                read_memory,ird_ack:out std_logic;
37
                ucsa:out std_logic(3 downto 0);
38
                iempty ,  rfull, opq_empty : in std_logic;
39 134 jguarin200
        );
40
end entity;
41 139 jguarin200
 
42
architecture sm_arch of sm is
43
 
44
        type macState is (IDLE,EXECUTING,FLUSHING);
45
        signal state : macState;
46
        constant rstMasterValue : std_logic:='0';
47
 
48
 
49
 
50
 
51
        signal sadd0,sadd1:std_logic_vector (8 downto 0);
52
        signal schunk0o,schunk0f,schunk1o,schunk1f: std_logic_vector (3 downto 0);
53
        signal sadd0_now,sadd0_next,sadd0_reg:std_logic_vector(8 downto 0);
54
        signal sadd1_now,sadd1_next,sadd1_reg:std_logic_vector(8 downto 0);
55
        signal sadd0_adder_bit,sadd1_adder_bit,sena:std_logic;
56
 
57
 
58 134 jguarin200
begin
59 139 jguarin200
 
60
 
61
        schunk0o(3 downto 0) <=  iq(19 downto 16);
62
        schunk0f(3 downto 0) <=  iq(15 downto 12);
63
        schunk1o(3 downto 0) <= iq(11 downto 8);
64
        schunk1f(3 downto 0) <= iq(7 downto 4);
65
 
66
        ucsa <= iq(3 downto 0);
67
 
68
        sadd0_next <= sadd0_now+sadd0_adder_bit;
69
        sadd1_next <= sadd1_now+sadd1_adder_bit;
70
 
71
 
72
        sm_comb:
73
        process (state)
74
        begin
75
                case state is
76
                        when IDLE =>
77
                                sadd0_now <= schunk0o(3 downto 0)&x"0";
78
                                sadd1_now <= schunk1o(3 downto 0)&x"0";
79
                        when others =>
80
                                sadd0_now <= sadd0_next;
81
                                sadd1_now <= sadd1_next;
82
                end case;
83
 
84
        end process;
85 134 jguarin200
 
86
 
87 139 jguarin200
        sm_proc:
88
        process (clk,rst)
89
        begin
90
                if rst=rstMasterValue then
91
                        state <= IDLE;
92
                        ird_ack <= '0';
93
                elsif clk='1' and clk'event and sena='1' then
94
 
95
                        case state is
96
                                when IDLE =>
97
                                        if rfull='0' and iempty='0' then
98
                                                state <= EXECUTING;
99
                                                read_memory <= '1';
100
                                        end if;
101
                                when EXCUTING =>
102
                                        if rfull='0' then
103
                                                if sadd1_now=schunk1f&"11111" then
104
                                                        if sadd0_now=schunk0f&"11111" then
105
                                                                state <= FLUSHING;
106
 
107
                                                        end if;
108
                                                end if;
109
                                        end if;
110
                                when FLUSHING =>
111
                                        if opq_empty='1' then
112
 
113
                                        end if;
114
                        end case;
115
                end if;
116
 
117
        end process;
118 134 jguarin200
 
119
 
120
end architecture;

powered by: WebSVN 2.1.0

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