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

Subversion Repositories timestamp

[/] [timestamp/] [trunk/] [pcores/] [timestamp/] [hdl/] [vhdl/] [timestamp.vhdl] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robotron
--
2
-- PowerPC 405 APU FCM "timestamp"
3
-- record a time (counter value) of User Defined Instruction execution
4
--
5
-- Marek Peca <mp@duch.cz> 07/2008
6
-- KRT FEL CVUT http://dce.felk.cvut.cz/
7
--
8
 
9
library ieee;
10
use ieee.std_logic_1164.all;
11
use ieee.std_logic_arith.all;
12
use ieee.std_logic_unsigned.all;
13
use ieee.numeric_std.all;
14
library unisim;
15
use unisim.vcomponents.RAMB16;
16
 
17
entity timestamp is
18
  port (
19
    reset: in std_logic;
20
    -- APU i/f:
21
    CPMFCMCLK: in std_logic;
22
    APUFCMFLUSH: in std_logic;
23
    APUFCMDECODED: in std_logic;
24
    APUFCMINSTRVALID: in std_logic;
25
    APUFCMDECUDIVALID: in std_logic;
26
    APUFCMDECUDI: in std_logic_vector (2 downto 0);
27
    APUFCMWRITEBACKOK: in std_logic;
28
    APUFCMRADATA: in std_logic_vector (31 downto 0);
29
    APUFCMRBDATA: in std_logic_vector (31 downto 0);
30
    FCMAPUDONE: out std_logic;
31
    FCMAPUSLEEPNOTREADY: out std_logic;
32
    -- BRAM slave i/f:
33
    BRAM_Rst_B: in std_logic;
34
    BRAM_Clk_B: in std_logic;
35
    BRAM_EN_B: in std_logic;
36
    BRAM_WEN_B: in std_logic_vector (7 downto 0);
37
    BRAM_Addr_B: in std_logic_vector (31 downto 0);
38
    BRAM_Dout_B: in std_logic_vector (63 downto 0);
39
    BRAM_Din_B: out std_logic_vector (63 downto 0);
40
    -- etc.
41
    debug: out std_logic_vector (3 downto 0)
42
  );
43
end timestamp;
44
 
45
architecture timestamp_fcm of timestamp is
46
  type state_type is (IDLE, WAIT_OPERAND);
47
  -- global
48
  signal clock: std_logic;
49
  -- FSM
50
  signal state, next_state: state_type;
51
  signal counter: std_logic_vector (31 downto 0);
52
  signal addr_counter: std_logic_vector (9 downto 0);
53
  signal save_udi_code: std_logic;
54
  signal udi_code: std_logic_vector (2 downto 0);
55
  -- BRAM
56
  signal wea: std_logic;
57
  signal dia0, dia1: std_logic_vector (31 downto 0);
58
  signal addra: std_logic_vector (9 downto 0);
59
begin
60
  clock <= CPMFCMCLK;
61
  dia0 <= counter;
62
  dia1 <= APUFCMRADATA;
63
  addra <= addr_counter;
64
 
65
  -- debug(0) <= addr_counter(0);
66
  -- debug(1) <= APUFCMDECUDIVALID;
67
  -- debug(2) <= APUFCMWRITEBACKOK;
68
  -- debug(3) <= wea;
69
  debug(0) <= CPMFCMCLK;
70
  debug(1) <= APUFCMDECODED;
71
  debug(2) <= APUFCMDECUDIVALID;
72
  debug(3) <= APUFCMWRITEBACKOK;
73
 
74
  seq: process
75
  begin
76
    wait until clock'event and clock = '1';
77
    if reset = '1' then
78
      state <= IDLE;
79
      counter <= X"00000000";
80
      addr_counter <= "0000000000";
81
    else
82
      if save_udi_code = '1' then
83
        udi_code <= APUFCMDECUDI;
84
      end if;
85
      state <= next_state;
86
      counter <= counter + 1;
87
      if wea = '1' then
88
        addr_counter <= addr_counter + 1;
89
      end if;
90
    end if;
91
  end process;
92
 
93
  comb_apu: process (state, udi_code,
94
                     APUFCMFLUSH, APUFCMINSTRVALID, APUFCMDECUDIVALID,
95
                     APUFCMWRITEBACKOK, APUFCMDECUDI)
96
  begin
97
    save_udi_code <= '0';
98
    wea <= '0';
99
    FCMAPUSLEEPNOTREADY <= '0';
100
    FCMAPUDONE <= '0';
101
    case state is
102
      when IDLE =>
103
        if APUFCMFLUSH = '1' then
104
          next_state <= IDLE;
105
        elsif (APUFCMINSTRVALID and APUFCMDECODED and APUFCMDECUDIVALID) = '1' then
106
          if APUFCMWRITEBACKOK = '1' then
107
            -- operands are ready
108
            if APUFCMDECUDI = "000" then
109
              wea <= '1';
110
              FCMAPUDONE <= '1';
111
            end if;
112
          else
113
            save_udi_code <= '1';
114
            next_state <= WAIT_OPERAND;
115
          end if;
116
        end if;
117
      when WAIT_OPERAND =>
118
        FCMAPUSLEEPNOTREADY <= '1';
119
        if APUFCMFLUSH = '1' then
120
          next_state <= IDLE;
121
        elsif APUFCMWRITEBACKOK = '1' then
122
          if udi_code = "000" then
123
            wea <= '1';
124
            FCMAPUDONE <= '1';
125
          end if;
126
        end if;
127
        next_state <= IDLE;
128
    end case;
129
  end process;
130
 
131
--   comb_action: process (action, action_udi_code)
132
  -- -- following block causes "gated clock" warning
133
  -- -- after FCMAPUDONE removal, everything seems to be OK
134
  -- -- what is strange: the same construct above at FCMAPUSLEEPNOTREADY
135
  -- -- causes no warning
136
--   begin
137
--     wea <= '0';
138
--     FCMAPUDONE <= '0';
139
--     if (action = '1') and (action_udi_code = "111") then
140
--       wea <= '1';
141
--       FCMAPUDONE <= '1';
142
--     end if;
143
--   end process;
144
 
145
  bram0: RAMB16
146
    generic map (
147
      INVERT_CLK_DOA_REG => false,
148
      INVERT_CLK_DOB_REG => false,
149
      RAM_EXTENSION_A => "NONE",
150
      RAM_EXTENSION_B => "NONE",
151
      READ_WIDTH_A => 36,
152
      READ_WIDTH_B => 36,
153
      WRITE_MODE_A => "WRITE_FIRST",
154
      WRITE_MODE_B => "WRITE_FIRST",
155
      WRITE_WIDTH_A => 36,
156
      WRITE_WIDTH_B => 36
157
    )
158
    port map (
159
      DOA => open,
160
      DOB => BRAM_Din_B(31 downto 0),
161
      ADDRA(14 downto 5) => addra,
162
      ADDRA(4 downto 0) => "00000",
163
      ADDRB(14 downto 2) => BRAM_Addr_B(12 downto 0),
164
      ADDRB(1 downto 0) => "00",
165
      CASCADEINA => '0', CASCADEINB => '0',
166
      CLKA => clock,
167
      CLKB => BRAM_Clk_B,
168
      DIA => dia0,
169
      DIB => BRAM_Dout_B(31 downto 0),
170
      DIPA => "0000", DIPB => "0000",
171
      ENA => '1',
172
      ENB => BRAM_EN_B,
173
      REGCEA => '1', REGCEB => '1',
174
      SSRA => '0',
175
      SSRB => BRAM_Rst_B,
176
      WEA(0) => wea, WEA(1) => wea, WEA(2) => wea, WEA(3) => wea,
177
      WEB => BRAM_WEN_B(3 downto 0)
178
    );
179
  bram1: RAMB16
180
    generic map (
181
      INVERT_CLK_DOA_REG => false,
182
      INVERT_CLK_DOB_REG => false,
183
      RAM_EXTENSION_A => "NONE",
184
      RAM_EXTENSION_B => "NONE",
185
      READ_WIDTH_A => 36,
186
      READ_WIDTH_B => 36,
187
      WRITE_MODE_A => "WRITE_FIRST",
188
      WRITE_MODE_B => "WRITE_FIRST",
189
      WRITE_WIDTH_A => 36,
190
      WRITE_WIDTH_B => 36
191
    )
192
    port map (
193
      DOA => open,
194
      DOB => BRAM_Din_B(63 downto 32),
195
      ADDRA(14 downto 5) => addra,
196
      ADDRA(4 downto 0) => "00000",
197
      ADDRB(14 downto 2) => BRAM_Addr_B(12 downto 0),
198
      ADDRB(1 downto 0) => "00",
199
      CASCADEINA => '0', CASCADEINB => '0',
200
      CLKA => clock,
201
      CLKB => BRAM_Clk_B,
202
      DIA => dia1,
203
      DIB => BRAM_Dout_B(63 downto 32),
204
      DIPA => "0000", DIPB => "0000",
205
      ENA => '1',
206
      ENB => BRAM_EN_B,
207
      REGCEA => '1', REGCEB => '1',
208
      SSRA => '0',
209
      SSRB => BRAM_Rst_B,
210
      WEA(0) => wea, WEA(1) => wea, WEA(2) => wea, WEA(3) => wea,
211
      WEB => BRAM_WEN_B(7 downto 4)
212
    );
213
end timestamp_fcm;
214
 
215
-- EOF

powered by: WebSVN 2.1.0

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