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

Subversion Repositories raytrac

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

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 142 jguarin200
        generic (
32
                width : integer := 32;
33
                widthadmemblock : integer := 9
34
                --!external_readable_widthad :                          
35
        )
36 134 jguarin200
        port (
37
 
38 139 jguarin200
                clk,rst:in std_logic;
39 142 jguarin200
 
40
                adda,addb:out std_logic_vector (widthadmemblock-1 downto 0);
41
                sync_chain_d:out std_logic;
42
 
43
                --! Instruction Q, instruction.
44
                instrQq:in std_logic_vector(width-1 downto 0);
45
 
46
 
47
 
48
                --! apempty, arithmetical pipeline empty.
49
                arithPbusy, instrQempty ,resultQfull: in std_logic;
50
 
51
                --! DataPath Control uca code.
52
                dpc_uca : out std_logic_vector (2 downto 0);
53
 
54
 
55 134 jguarin200
        );
56
end entity;
57 139 jguarin200
 
58
architecture sm_arch of sm is
59
 
60 142 jguarin200
        type macState is (FLUSH_TO_NEXT_INSTRUCTION,EXECUTE_INSTRUCTION);
61 139 jguarin200
        signal state : macState;
62
        constant rstMasterValue : std_logic:='0';
63
 
64 142 jguarin200
        component customCounter
65
        generic (
66
                width : integer
67
 
68
        );
69
        port (
70
                clk,rst,go,set  : in std_logic;
71
                setValue                : in std_Logic_vector(width-1 downto 0);
72
                count                   : out std_logic_vector(width-1 downto 0)
73
        )
74 139 jguarin200
 
75 142 jguarin200
        signal addt0_blocka,addt0_blockb,set_Value_A,set_Value_B : std_logic_vector(widthadmemblock-1 downto 0);
76
        signal add_condition_a, add_condition_b,set_a,set_b : std_logic;
77
        signal s_dpc_uca, s_instrQ_uca : std_logic_vector(2 downto 0);
78
        signal s_block_start_a, s_block_start_b, s_block_end_a, s_block_end_b : std_logic_vector(4 downto 0);
79 139 jguarin200
 
80 142 jguarin200
 
81
 
82 134 jguarin200
begin
83 142 jguarin200
 
84
        --! Bloques asignados
85
        s_block_start_a <= instrQq(width-4 downto width-8);
86
        s_block_start_b <= instrQq(width-14 downto width-18);
87
        s_block_end_a <= instrQq(width-9 downto width-13);
88
        s_block_end_b <= instrQq(width-19 downto width-)
89 139 jguarin200
 
90 142 jguarin200
        --! Address Counters
91
        counterA:customCounter
92
        port map (clk,rst,add_condition_a,set_a,instrQq(width-4 downto width-8)&x"0",addt0_blocka);
93
        counterB:customCounter
94
        port map (clk,rst,add_condition_b,set_b,instrQq(width-9 downto width-12)&x"0",addt0_blockb);
95
        adda <= addt0_blocka;
96
        addb <= addt0_blockb;
97 139 jguarin200
 
98 142 jguarin200
        --! uca code 
99
        s_instrQ_uca <= instrQq(31 downto 29);
100 139 jguarin200
 
101
 
102
        sm_proc:
103
        process (clk,rst)
104
        begin
105
                if rst=rstMasterValue then
106
                        state <= IDLE;
107
                        ird_ack <= '0';
108 142 jguarin200
                elsif clk='1' and clk'event then
109 139 jguarin200
 
110
                        case state is
111 142 jguarin200
                                when FLUSH_TO_NEXT_INSTRUCTION =>
112
 
113
                                        --! Chequear si hay una instruccion en la salida de la cola de instruccioens.
114
                                        if instrQempty='0' then
115 139 jguarin200
 
116 142 jguarin200
                                                --! Chequear si la cola de resultados tiene espacio.
117
                                                if resultQfull='0' then
118
 
119
                                                        --! Si el codigo de instruccion (uca) que se encuentra en el DPC es igual al que se encuentra en la instruccion de la salida de la cola de instrucciones, entonces no hay mas validaciones que hacer. 
120
 
121
 
122
                                                                --! Now check that arithmetic pipline is not busy 
123
                                                                if arithPbusy='0' then
124
 
125
 
126
                                when EXECUTE_INSTRUCTION =>
127
                                        if addt1_blockb(4 downto 0)=x"1f" and addt1_blocka=x"1f" then
128
                                                if addt1_blockb(8 downto )
129
                                        else
130
 
131 139 jguarin200
                                        end if;
132
                        end case;
133
                end if;
134
        end process;
135 142 jguarin200
 
136
        nxtadda_proc:
137
        process ()
138 134 jguarin200
end architecture;

powered by: WebSVN 2.1.0

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