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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_cpu.vhd] - Blame information for rev 8

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

Line No. Rev Author Line
1 7 jshamlet
-- Copyright (c)2006, Jeremy Seth Henry
2
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 
24
-- VHDL Units :  Open8_CPU
25
-- Description:  VHDL model of the V8 uRISC 8-bit processor core
26
-- Notes      :  Generic definitions
27
--            :  Stack_Start_Address - determines the initial (reset) value of
28
--            :   the stack pointer. Also used for the RSP instruction if
29
--            :   Allow_Stack_Address_Move is 0.
30
--            :
31
--            :  Allow_Stack_Address_Move - When set to 1, allows the RSP to be
32
--            :   programmed via thet RSP instruction. If enabled, the contents
33
--            :   of R1:R0 are used to initialize the stack pointer.
34
--            :
35
--            :  ISR_Start_Addr - determines the location of the interrupt
36
--            :   service vector table. There are 8 service vectors, or 16
37
--            :   bytes, which must be allocated to either ROM or RAM.
38
--            :
39
--            :  Program_Start_Addr - Determines the initial value of the
40
--            :   program counter.
41
--            :
42
--            :  Default_Interrupt_Mask - Determines the intial value of the
43
--            :   interrupt mask. To remain true to the original core, which
44
--            :   had no interrupt mask, this should be set to x"FF". Otherwise
45
--            :   it can be initialized to any value.
46
--            :
47
--            :  Enable_CPU_Halt - determines whether the CPU_Halt pin is
48
--            :   connected or not. This signal is typically used to halt the
49
--            :   processor for a few cycles when accessing slower peripherals,
50
--            :   but may also be used to single step the processor. If this
51
--            :   feature isn't used, it can be disabled to increase Fmax.
52
--            :
53
--            :  The CPU_Halt signal can be used to access slower peripherals
54
--            :   by allowing the device to "pause" the CPU. This can be used,
55
--            :   for example, to write to a standard LCD panel, which requires
56
--            :   a 4MHz interface, by halting on writes. Alternately, devices
57
--            :   such as SDRAM controllers, can pause the processor until the
58
--            :   data is ready to be presented.
59
--            :
60
--            :  The Enable_Auto_Increment generic can be used to modify the
61
--            :   indexed instructions such that specifying an odd register
62
--            :   will use the next lower register pair, post-incrementing the
63
--            :   value in that pair. IOW, specifying STX R1 will instead
64
--            :   result in STX R0++, or R0 = {R1:R0}; {R1:R0} + 1
65
--            :
66
--            : Instructions USR and USR2 have been replaced with DBNZ, and MUL
67
--            :  respectively. DBNZ decrements the specified register, and will
68
--            :  branch if the result is non-zero (Zero flag is not set). MUL
69
--            :  places the result of R0 * Rn into R1:R0, and executes in two
70
--            :  cycles. (R1:R0 = R0 * Rn)
71
--            :
72
-- Revision History
73
-- Author          Date     Change
74
------------------ -------- ---------------------------------------------------
75
-- Seth Henry      07/19/06 Design Start
76
 
77
library ieee;
78
  use ieee.std_logic_1164.all;
79
  use ieee.std_logic_unsigned.all;
80
  use ieee.std_logic_arith.all;
81
 
82
library work;
83
use work.Open8_pkg.all;
84
 
85
entity Open8_CPU is
86
  generic(
87
    Stack_Start_Addr         : ADDRESS_TYPE := x"007F"; -- Top of Stack
88
    Allow_Stack_Address_Move : std_logic    := '0';     -- Use Normal v8 RSP
89
    ISR_Start_Addr           : ADDRESS_TYPE := x"0080"; -- Bottom of ISR vec's
90
    Program_Start_Addr       : ADDRESS_TYPE := x"0090"; -- Initial PC location
91
    Default_Interrupt_Mask   : DATA_TYPE    := x"FF";   -- Enable all Ints
92
    Enable_CPU_Halt          : std_logic    := '0';     -- Disable HALT pin
93
    Enable_Auto_Increment    : std_logic    := '0' );   -- Modify indexed instr
94
  port(
95
    Clock                    : in  std_logic;
96
    Reset_n                  : in  std_logic;
97
    CPU_Halt                 : in  std_logic;
98
    Interrupts               : in  INTERRUPT_BUNDLE;
99
    --
100
    Address                  : out ADDRESS_TYPE;
101
    Rd_Data                  : in  DATA_TYPE;
102
    Rd_Enable                : out std_logic;
103
    Wr_Data                  : out DATA_TYPE;
104
    Wr_Enable                : out std_logic );
105
end entity;
106
 
107
architecture rtl of Open8_CPU is
108
  subtype OPCODE_TYPE  is std_logic_vector(4 downto 0);
109
  subtype SUBOP_TYPE   is std_logic_vector(2 downto 0);
110
 
111
  -- Most of the ALU instructions are the same as their Opcode equivalents with
112
  -- three exceptions (for IDLE, UPP2, and MUL2)
113
  constant ALU_INC           : OPCODE_TYPE := "00000"; -- x"00"
114
  constant ALU_ADC           : OPCODE_TYPE := "00001"; -- x"01"
115
  constant ALU_TX0           : OPCODE_TYPE := "00010"; -- x"02"
116
  constant ALU_OR            : OPCODE_TYPE := "00011"; -- x"03"
117
  constant ALU_AND           : OPCODE_TYPE := "00100"; -- x"04"
118
  constant ALU_XOR           : OPCODE_TYPE := "00101"; -- x"05"
119
  constant ALU_ROL           : OPCODE_TYPE := "00110"; -- x"06"
120
  constant ALU_ROR           : OPCODE_TYPE := "00111"; -- x"07"
121
  constant ALU_DEC           : OPCODE_TYPE := "01000"; -- x"08"
122
  constant ALU_SBC           : OPCODE_TYPE := "01001"; -- x"09"
123
  constant ALU_ADD           : OPCODE_TYPE := "01010"; -- x"0A"
124
  constant ALU_STP           : OPCODE_TYPE := "01011"; -- x"0B"
125
  constant ALU_BTT           : OPCODE_TYPE := "01100"; -- x"0C"
126
  constant ALU_CLP           : OPCODE_TYPE := "01101"; -- x"0D"
127
  constant ALU_T0X           : OPCODE_TYPE := "01110"; -- x"0E"
128
  constant ALU_CMP           : OPCODE_TYPE := "01111"; -- x"0F"
129
  constant ALU_POP           : OPCODE_TYPE := "10001"; -- x"11"
130
  constant ALU_MUL           : OPCODE_TYPE := "10110"; -- x"16"
131
  constant ALU_UPP           : OPCODE_TYPE := "11000"; -- x"18"
132
  constant ALU_LDI           : OPCODE_TYPE := "11100"; -- x"1C"
133
  constant ALU_LDX           : OPCODE_TYPE := "11110"; -- x"1E"
134
 
135
  constant ALU_IDLE          : OPCODE_TYPE := "10000"; -- x"10"
136
  constant ALU_UPP2          : OPCODE_TYPE := "10010"; -- x"11"
137
  constant ALU_RFLG          : OPCODE_TYPE := "10011"; -- x"12"
138
 
139
  constant FL_ZERO           : integer := 0;
140
  constant FL_CARRY          : integer := 1;
141
  constant FL_NEG            : integer := 2;
142
  constant FL_INT_EN         : integer := 3;
143
  constant FL_GP1            : integer := 4;
144
  constant FL_GP2            : integer := 5;
145
  constant FL_GP3            : integer := 6;
146
  constant FL_GP4            : integer := 7;
147
 
148
  type ALU_CTRL_TYPE is record
149
    Oper                     : OPCODE_TYPE;
150
    Reg                      : SUBOP_TYPE;
151
    Data                     : DATA_TYPE;
152
  end record;
153
 
154
  constant ACCUM             : SUBOP_TYPE := "000";
155
  constant INT_FLAG          : SUBOP_TYPE := "011";
156
 
157
  -- There are only 8 byte-wide registers - and the write register is always 0,
158
  --  so there is little point in making a RAM out of this
159
  type REGFILE_TYPE is array (0 to 7) of DATA_TYPE;
160
 
161
  subtype FLAG_TYPE is DATA_TYPE;
162
 
163
  type PC_MODES is ( PC_IDLE, PC_REV1, PC_REV2, PC_INCR, PC_LOAD );
164
 
165
  type PC_CTRL_TYPE is record
166
    Oper                     : PC_MODES;
167
    Offset                   : DATA_TYPE;
168
    Addr                     : ADDRESS_TYPE;
169
  end record;
170
 
171
  type SP_MODES is ( SP_IDLE, SP_RSET, SP_POP, SP_PUSH );
172
 
173
  type SP_CTRL_TYPE is record
174
    Oper                     : SP_MODES;
175
    Addr                     : ADDRESS_TYPE;
176
  end record;
177
 
178
  type INT_CTRL_TYPE is record
179
    Mask_Set                 : std_logic;
180
    Mask_Data                : DATA_TYPE;
181
    Soft_Ints                : INTERRUPT_BUNDLE;
182
    Incr_ISR                 : std_logic;
183
  end record;
184
 
185
  type AS_MODES is ( ADDR_PC, ADDR_SP, ADDR_IMM, ADDR_ISR);
186
 
187
  type ADDR_CTRL_TYPE is record
188
    Src                      : AS_MODES;
189
  end record;
190
 
191
  type DP_MODES is ( DATA_IDLE, DATA_REG, DATA_FLAG, DATA_PC );
192
 
193
  type DATA_CTRL_TYPE is record
194
    Src                      : DP_MODES;
195
    Reg                      : SUBOP_TYPE;
196
  end record;
197
 
198
  signal Halt                : std_logic;
199
  signal ALU_Ctrl            : ALU_CTRL_TYPE;
200
  signal ALU_Regs            : REGFILE_TYPE;
201
  signal ALU_Flags           : FLAG_TYPE;
202
  signal PC_Ctrl             : PC_CTRL_TYPE;
203
  signal SP_Ctrl             : SP_CTRL_TYPE;
204
  signal AS_Ctrl             : ADDR_CTRL_TYPE;
205
  signal DP_Ctrl             : DATA_CTRL_TYPE;
206
  signal INT_Ctrl            : INT_CTRL_TYPE;
207
  signal Int_Req, Int_Ack    : std_logic;
208
  signal Int_RTI             : std_logic;
209
  signal Int_Mask            : DATA_TYPE;
210
  signal PC                  : ADDRESS_TYPE;
211
  signal SP                  : ADDRESS_TYPE;
212
  signal ISR                 : ADDRESS_TYPE;
213
  signal IMM                 : ADDRESS_TYPE;
214
begin
215
 
216
Halt_Disabled_fn: if( Enable_CPU_Halt = '0' )generate
217
  Halt                       <= '0';
218
end generate;
219
 
220
Halt_Enabled_fn: if( Enable_CPU_Halt = '1' )generate
221
  Halt                       <= CPU_Halt;
222
end generate;
223
 
224
-------------------------------------------------------------------------------
225
-- ALU (Arithmetic / Logic Unit
226
-- Notes:
227
-- 1) Infers a multiplier in Xilinx/Altera parts - should be checked in others
228
-------------------------------------------------------------------------------
229
 
230
Open8_ALU : block is
231
 
232
  -- Preinitialization is for simulation only - check actual reset conditions
233
  signal Regfile_D, Regfile  : REGFILE_TYPE := (others => (others => '0') );
234
  signal Flags_D, Flags      : FLAG_TYPE    := (others => '0');
235
  signal Mult                : ADDRESS_TYPE := (others => '0');
236
 
237
  signal Sum                 : std_logic_vector(8 downto 0) := (others => '0');
238
  signal Addend_A, Addend_B  : DATA_TYPE    := (others => '0');
239
  signal Carry               : std_logic    := '0';
240
 
241
begin
242
 
243
  ALU_Regs                   <= Regfile;
244
  ALU_Flags                  <= Flags;
245
 
246
  ALU_proc: process( ALU_Ctrl, Regfile, Flags, Mult, Sum )
247
    variable Index             : integer range 0 to 7 := 0;
248
    variable Temp              : std_logic_vector(8 downto 0);
249
  begin
250
    Regfile_D                <= Regfile;
251
    Flags_D                  <= Flags;
252
    Addend_A                 <= x"00";
253
    Addend_B                 <= x"00";
254
    Carry                    <= '0';
255
 
256
    Temp                     := (others => '0');
257
    Index                    := conv_integer(ALU_Ctrl.Reg);
258
 
259
    case ALU_Ctrl.Oper is
260
      when ALU_INC | ALU_UPP => -- Rn = Rn + 1 : Flags N,C,Z
261
        Addend_A             <= x"01";
262
        Addend_B             <= Regfile(Index);
263
        Flags_D(FL_CARRY)    <= Sum(8);
264
        Regfile_D(Index)     <= Sum(7 downto 0);
265
        -- ALU_INC and ALU_UPP are essentially the same, except that ALU_UPP
266
        --  doesn't set the N or Z flags. Note that the MSB can be used to
267
        --  distinguish between the two ALU modes.
268
        if( ALU_Ctrl.Oper(4) = '0' )then
269
          Flags_D(FL_ZERO)   <= '0';
270
          if( Sum(7 downto 0) = 0 )then
271
            Flags_D(FL_ZERO) <= '1';
272
          end if;
273
          Flags_D(FL_NEG)    <= Sum(7);
274
        end if;
275
 
276
      when ALU_UPP2 => -- Rn = Rn + C
277
        Addend_A             <= x"00";
278
        Addend_B             <= Regfile(Index);
279
        Carry                <= Flags(FL_CARRY);
280
        Flags_D(FL_CARRY)    <= Sum(8);
281
        Regfile_D(Index)     <= Sum(7 downto 0);
282
 
283
      when ALU_ADC => -- R0 = R0 + Rn + C : Flags N,C,Z
284
        Addend_A             <= Regfile(0);
285
        Addend_B             <= Regfile(Index);
286
        Carry                <= Flags(FL_CARRY);
287
        Flags_D(FL_ZERO)     <= '0';
288
        if( Sum(7 downto 0) = 0 )then
289
          Flags_D(FL_ZERO)   <= '1';
290
        end if;
291
        Flags_D(FL_CARRY)    <= Sum(8);
292
        Flags_D(FL_NEG)      <= Sum(7);
293
        Regfile_D(0)         <= Sum(7 downto 0);
294
 
295
      when ALU_TX0 => -- R0 = Rn : Flags N,Z
296
        Temp                 := "0" & Regfile(Index);
297
        Flags_D(FL_ZERO)     <= '0';
298
        if( Temp(7 downto 0) = 0 )then
299
          Flags_D(FL_ZERO)   <= '1';
300
        end if;
301
        Flags_D(FL_NEG)      <= Temp(7);
302
        Regfile_D(0)         <= Temp(7 downto 0);
303
 
304
      when ALU_OR  => -- R0 = R0 | Rn : Flags N,Z
305
        Temp(7 downto 0)     := Regfile(0) or Regfile(Index);
306
        Flags_D(FL_ZERO)     <= '0';
307
        if( Temp(7 downto 0) = 0 )then
308
          Flags_D(FL_ZERO)   <= '1';
309
        end if;
310
        Flags_D(FL_NEG)      <= Temp(7);
311
        Regfile_D(0)         <= Temp(7 downto 0);
312
 
313
      when ALU_AND => -- R0 = R0 & Rn : Flags N,Z
314
        Temp(7 downto 0)     := Regfile(0) and Regfile(Index);
315
        Flags_D(FL_ZERO)     <= '0';
316
        if( Temp(7 downto 0) = 0 )then
317
          Flags_D(FL_ZERO)   <= '1';
318
        end if;
319
        Flags_D(FL_NEG)      <= Temp(7);
320
        Regfile_D(0)         <= Temp(7 downto 0);
321
 
322
      when ALU_XOR => -- R0 = R0 ^ Rn : Flags N,Z
323
        Temp(7 downto 0)     := Regfile(0) xor Regfile(Index);
324
        Flags_D(FL_ZERO)     <= '0';
325
        if( Temp(7 downto 0) = 0 )then
326
          Flags_D(FL_ZERO)   <= '1';
327
        end if;
328
        Flags_D(FL_NEG)      <= Temp(7);
329
        Regfile_D(0)         <= Temp(7 downto 0);
330
 
331
      when ALU_ROL => -- Rn = Rn<<1,C : Flags N,C,Z
332
        Temp                 := Regfile(Index) & Flags(FL_CARRY);
333
        Flags_D(FL_ZERO)     <= '0';
334
        if( Temp(7 downto 0) = 0 )then
335
          Flags_D(FL_ZERO)   <= '1';
336
        end if;
337
        Flags_D(FL_CARRY)    <= Temp(8);
338
        Flags_D(FL_NEG)      <= Temp(7);
339
        Regfile_D(Index)     <= Temp(7 downto 0);
340
 
341
      when ALU_ROR => -- Rn = C,Rn>>1 : Flags N,C,Z
342
        Temp                 := Regfile(Index)(0) & Flags(FL_CARRY) &
343
                                Regfile(Index)(7 downto 1);
344
        Flags_D(FL_ZERO)     <= '0';
345
        if( Temp(7 downto 0) = 0 )then
346
          Flags_D(FL_ZERO)   <= '1';
347
        end if;
348
        Flags_D(FL_CARRY)    <= Temp(8);
349
        Flags_D(FL_NEG)      <= Temp(7);
350
        Regfile_D(Index)     <= Temp(7 downto 0);
351
 
352
      when ALU_DEC => -- Rn = Rn - 1 : Flags N,C,Z
353
        Addend_A             <= Regfile(Index);
354
        Addend_B             <= x"FF";
355
        Flags_D(FL_ZERO)     <= '0';
356
        if( Sum(7 downto 0) = 0 )then
357
          Flags_D(FL_ZERO)   <= '1';
358
        end if;
359
        Flags_D(FL_CARRY)    <= Sum(8);
360
        Flags_D(FL_NEG)      <= Sum(7);
361
        Regfile_D(Index)     <= Sum(7 downto 0);
362
 
363
      when ALU_SBC => -- Rn = R0 - Rn - C : Flags N,C,Z
364
        Addend_A             <= Regfile(0);
365
        Addend_B             <= not Regfile(Index);
366
        Carry                <= Flags(FL_CARRY);
367
        Flags_D(FL_ZERO)     <= '0';
368
        if( Sum(7 downto 0) = 0 )then
369
          Flags_D(FL_ZERO)   <= '1';
370
        end if;
371
        Flags_D(FL_CARRY)    <= Sum(8);
372
        Flags_D(FL_NEG)      <= Sum(7);
373
        Regfile_D(0)         <= Sum(7 downto 0);
374
 
375
      when ALU_ADD => -- R0 = R0 + Rn : Flags N,C,Z
376
        Addend_A             <= Regfile(0);
377
        Addend_B             <= Regfile(Index);
378
        Flags_D(FL_CARRY)    <= Sum(8);
379
        Regfile_D(0)         <= Sum(7 downto 0);
380
        Flags_D(FL_ZERO)     <= '0';
381
        if( Sum(7 downto 0) = 0 )then
382
          Flags_D(FL_ZERO)   <= '1';
383
        end if;
384
        Flags_D(FL_NEG)      <= Sum(7);
385
 
386
      when ALU_STP => -- Sets bit(n) in the Flags register
387
        Flags_D(Index)         <= '1';
388
 
389
      when ALU_BTT => -- Tests if R0 is negative or zero. No change to R0
390
        Temp                 := "0" & Regfile(Index);
391
        Flags_D(FL_ZERO)     <= '0';
392
        if( Temp(7 downto 0) = 0 )then
393
          Flags_D(FL_ZERO)   <= '1';
394
        end if;
395
        Flags_D(FL_NEG)      <= Temp(7);
396
 
397
      when ALU_CLP => -- Clears bit(n) in the Flags register
398
        Flags_D(Index)         <= '0';
399
 
400
      when ALU_T0X => -- Rn = R0 : Flags N,Z
401
        Temp                 := "0" & Regfile(0);
402
        Flags_D(FL_ZERO)     <= '0';
403
        if( Temp(7 downto 0) = 0 )then
404
          Flags_D(FL_ZERO)   <= '1';
405
        end if;
406
        Flags_D(FL_NEG)      <= Temp(7);
407
        Regfile_D(Index)     <= Temp(7 downto 0);
408
 
409
      when ALU_CMP => -- Sets Flags on R0 - Rn : Flags N,C,Z
410
        Addend_A             <= Regfile(0);
411
        Addend_B             <= not Regfile(Index);
412
        Carry                <= '1';
413
        Flags_D(FL_ZERO)     <= '0';
414
        if( Sum(7 downto 0) = 0 )then
415
          Flags_D(FL_ZERO)   <= '1';
416
        end if;
417
        Flags_D(FL_CARRY)    <= Sum(8);
418
        Flags_D(FL_NEG)      <= Sum(7);
419
 
420
      when ALU_MUL => -- Stage 1 of 2 {R1:R0} = R0 * Rn : Flags N,Z
421
        Regfile_D(0)         <= Mult(7 downto 0);
422
        Regfile_D(1)         <= Mult(15 downto 8);
423
        Flags_D(FL_ZERO)     <= '0';
424
        if( Mult = 0 )then
425
          Flags_D(FL_ZERO)   <= '1';
426
        end if;
427
 
428
      when ALU_LDI | ALU_POP => -- Rn <= Data : Flags N,Z
429
        -- The POP instruction doesn't alter the flags, so we need to check
430
        if( ALU_Ctrl.Oper = ALU_LDI )then
431
          Flags_D(FL_ZERO)   <= '0';
432
          if( ALU_Ctrl.Data = 0 )then
433
            Flags_D(FL_ZERO) <= '1';
434
          end if;
435
          Flags_D(FL_NEG)    <= ALU_Ctrl.Data(7);
436
        end if;
437
        Regfile_D(Index)     <= ALU_Ctrl.Data;
438
 
439
      when ALU_LDX => -- R0 <= Data : Flags N,Z
440
        Flags_D(FL_ZERO)     <= '0';
441
        if( ALU_Ctrl.Data = 0 )then
442
          Flags_D(FL_ZERO)   <= '1';
443
        end if;
444
        Flags_D(FL_NEG)      <= ALU_Ctrl.Data(7);
445
        Regfile_D(0)         <= ALU_Ctrl.Data;
446
 
447
      when ALU_RFLG =>
448
        Flags_D              <= ALU_Ctrl.Data;
449
 
450
      when others => null;
451
    end case;
452
  end process;
453
 
454
  -- 8-bit Adder with carry
455
  Sum                        <= ("0" & Addend_A) + ("0" & Addend_B) + Carry;
456
 
457
  -- We need to infer a hardware multipler, so we create a special clocked
458
  --  process with no reset or clock enable
459
  M_Reg: process( Clock )
460
  begin
461
    if( rising_edge(Clock) )then
462
      Mult                   <= Regfile(0) *
463
                                Regfile(conv_integer(ALU_Ctrl.Reg));
464
    end if;
465
  end process;
466
 
467
  S_Regs: process( Reset_n, Clock )
468
  begin
469
    if( Reset_n = '0' )then
470
      for i in 0 to 7 loop
471
        Regfile(i)           <= (others => '0');
472
      end loop;
473
      Flags                  <= x"00";
474
    elsif( rising_edge(Clock) )then
475
      if( Halt = '0' )then
476
        Regfile              <= Regfile_D;
477
        Flags                <= Flags_D;
478
      end if;
479
    end if;
480
  end process;
481
 
482
end block;
483
 
484
-------------------------------------------------------------------------------
485
-- Program Counter
486
-------------------------------------------------------------------------------
487
 
488
Open8_PC : block is
489
  -- Preinitialization is for simulation only - check actual reset conditions
490
  signal PC_Q                : ADDRESS_TYPE := (others => '0');
491
  signal Rewind_1_2n         : std_logic    := '0';
492
begin
493
 
494
  PC                         <= PC_Q;
495
 
496
  -- This sets the carry input on the "rewind" adder. If the rewind command is
497
  --  PC_REV2, then we clear the carry. Otherwise, we leave it high.
498
  Rewind_PC_Calc: process( PC_Ctrl )
499
  begin
500
    Rewind_1_2n              <= '1';
501
    if( PC_Ctrl.Oper = PC_REV2 )then
502
      Rewind_1_2n            <= '0';
503
    end if;
504
  end process;
505
 
506
  Program_Counter: process( Reset_n, Clock, Halt, PC_Ctrl, PC_Q, Rewind_1_2n )
507
    variable PC_Offset_SX    : ADDRESS_TYPE := x"0000";
508
  begin
509
    PC_Offset_SX(15 downto 8):= (others => PC_Ctrl.Offset(7));
510
    PC_Offset_SX(7 downto 0) := PC_Ctrl.Offset;
511
    if( Reset_n = '0' )then
512
      PC_Q                   <= Program_Start_Addr;
513
    elsif( rising_edge(Clock) )then
514
      if( Halt = '0' )then
515
        case PC_Ctrl.Oper is
516
          when PC_IDLE =>
517
            null;
518
          when PC_REV1 | PC_REV2 =>
519
            PC_Q             <= PC_Q - 2 + Rewind_1_2n;
520
          when PC_INCR =>
521
            PC_Q             <= PC_Q + PC_Offset_SX - 2;
522
          when PC_LOAD =>
523
            PC_Q             <= PC_Ctrl.Addr;
524
        end case;
525
      end if;
526
    end if;
527
  end process;
528
 
529
end block;
530
 
531
-------------------------------------------------------------------------------
532
-- Stack Pointer
533
-------------------------------------------------------------------------------
534
 
535
Open8_SP : block is
536
  -- Preinitialization is for simulation only - check actual reset conditions
537
  signal SP_Q                : ADDRESS_TYPE := (others => '0');
538
begin
539
 
540
  SP                         <= SP_Q;
541
 
542
  Stack_Pointer: process( Reset_n, Clock )
543
  begin
544
    if( Reset_n = '0' )then
545
      SP_Q                   <= Stack_Start_Addr;
546
    elsif( rising_edge(Clock) )then
547
      if( Halt = '0' )then
548
        case SP_Ctrl.Oper is
549
          when SP_IDLE => null;
550
          when SP_RSET => SP_Q <= SP_Ctrl.Addr;
551
          when SP_POP  => SP_Q <= SP_Q + 1;
552
          when SP_PUSH => SP_Q <= SP_Q - 1;
553
        end case;
554
      end if;
555
    end if;
556
  end process;
557
 
558
end block;
559
 
560
-------------------------------------------------------------------------------
561
-- Interrupt Controller
562
-------------------------------------------------------------------------------
563
 
564
Open8_INT : block is
565
 
566
  -- Preinitialization is for simulation only - check actual reset conditions
567
  constant INT_VECTOR_0      : ADDRESS_TYPE := ISR_Start_Addr;
568
  constant INT_VECTOR_1      : ADDRESS_TYPE := ISR_Start_Addr+2;
569
  constant INT_VECTOR_2      : ADDRESS_TYPE := ISR_Start_Addr+4;
570
  constant INT_VECTOR_3      : ADDRESS_TYPE := ISR_Start_Addr+6;
571
  constant INT_VECTOR_4      : ADDRESS_TYPE := ISR_Start_Addr+8;
572
  constant INT_VECTOR_5      : ADDRESS_TYPE := ISR_Start_Addr+10;
573
  constant INT_VECTOR_6      : ADDRESS_TYPE := ISR_Start_Addr+12;
574
  constant INT_VECTOR_7      : ADDRESS_TYPE := ISR_Start_Addr+14;
575
 
576
  signal i_Ints              : INTERRUPT_BUNDLE             := (others => '0');
577
  signal Pending_D           : INTERRUPT_BUNDLE             := (others => '0');
578
  signal Pending             : INTERRUPT_BUNDLE             := (others => '0');
579
  signal Wait_for_FSM        : std_logic := '0';
580
  signal Mask                : std_logic_vector(6 downto 0) := (others => '0');
581
  signal ISR_D, ISR_Q        : ADDRESS_TYPE                 := (others => '0');
582
 
583
  type INT_HIST is array (0 to 8) of integer range 0 to 7;
584
  signal History             : INT_HIST                     := (others => 0);
585
  signal Int_Trig            : std_logic                    := '0';
586
  signal Hist_Level          : integer range 0 to 7         := 0;
587
  signal Hist_Ptr            : integer range 0 to 8         := 0;
588
 
589
begin
590
  Int_Mask                   <= Mask & '1';
591
  ISR                        <= ISR_Q;
592
 
593
  Int_Mask_proc: process( Mask, Interrupts, INT_Ctrl )
594
    variable S_Mask          : std_logic_vector(7 downto 0);
595
  begin
596
    S_Mask                   := Mask & '1';
597
    for i in 0 to 7 loop
598
      i_Ints(i)              <= (Interrupts(i) or INT_Ctrl.Soft_Ints(i))
599
                                and S_Mask(i);
600
    end loop;
601
  end process;
602
 
603
  Int_Ctrl_proc: process( i_Ints, Pending, Wait_for_FSM, ISR_Q, INT_Ctrl,
604
                          History, Hist_Ptr )
605
  begin
606
    ISR_D                    <= ISR_Q;
607
    Pending_D                <= Pending;
608
    Int_Trig                 <= '0';
609
    Hist_Level               <= 0;
610
 
611
    -- Record any incoming interrupts to the pending buffer
612
    if( i_Ints > 0 )then
613
      Pending_D              <= i_Ints;
614
    end if;
615
 
616
    -- Incr_ISR allows the CPU Core to advance the vector address to pop the
617
    --  lower half of the address.
618
    if( INT_Ctrl.Incr_ISR = '1' )then
619
      ISR_D                  <= ISR_Q + 1;
620
    end if;
621
 
622
    -- Only mess with interrupt signals while the CPU core is not currently
623
    --  working with the ISR address (ie, not loading a new service vector)
624
    if( Wait_for_FSM = '0' and Pending > 0 )then
625
      if( Pending(0) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 0) )then
626
        ISR_D                <= INT_VECTOR_0;
627
        Pending_D(0)         <= '0';
628
        Hist_Level           <= 0;
629
        Int_Trig             <= '1';
630
      elsif( Pending(1) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 1) )then
631
        ISR_D                <= INT_VECTOR_1;
632
        Pending_D(1)         <= '0';
633
        Hist_Level           <= 1;
634
        Int_Trig             <= '1';
635
      elsif( Pending(2) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 2) )then
636
        ISR_D                <= INT_VECTOR_2;
637
        Pending_D(2)         <= '0';
638
        Hist_Level           <= 2;
639
        Int_Trig             <= '1';
640
      elsif( Pending(3) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 3) )then
641
        ISR_D                <= INT_VECTOR_3;
642
        Pending_D(3)         <= '0';
643
        Hist_Level           <= 3;
644
        Int_Trig             <= '1';
645
      elsif( Pending(4) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 4) )then
646
        ISR_D                <= INT_VECTOR_4;
647
        Pending_D(4)         <= '0';
648
        Hist_Level           <= 4;
649
        Int_Trig             <= '1';
650
      elsif( Pending(5) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 5) )then
651
        ISR_D                <= INT_VECTOR_5;
652
        Pending_D(5)         <= '0';
653
        Hist_Level           <= 5;
654
        Int_Trig             <= '1';
655
      elsif( Pending(6) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 6) )then
656
        ISR_D                <= INT_VECTOR_6;
657
        Pending_D(6)         <= '0';
658
        Hist_Level           <= 6;
659
        Int_Trig             <= '1';
660
      elsif( Pending(7) = '1' and (Hist_Ptr = 0 or History(Hist_Ptr) > 7) )then
661
        ISR_D                <= INT_VECTOR_7;
662
        Pending_D(7)         <= '0';
663
        Hist_Level           <= 7;
664
        Int_Trig             <= '1';
665
      end if;
666
    end if;
667
  end process;
668
 
669
  S_Regs: process( Reset_n, Clock )
670
  begin
671
    if( Reset_n = '0' )then
672
      Int_Req                <= '0';
673
      Pending                <= x"00";
674
      Wait_for_FSM           <= '0';
675
      Mask                   <= Default_Interrupt_Mask(7 downto 1);
676
      ISR_Q                  <= INT_VECTOR_0;
677
      for i in 0 to 8 loop
678
        History(i)           <= 0;
679
      end loop;
680
      Hist_Ptr               <= 0;
681
    elsif( rising_edge(Clock) )then
682
      if( Halt = '0' )then
683
        Int_Req              <= Wait_for_FSM and (not Int_Ack);
684
        Pending              <= Pending_D;
685
        -- Reset the Wait_for_FSM flag on Int_Ack
686
        if( Int_Ack = '1' )then
687
          Wait_for_FSM       <= '0';
688
        -- Set the Wait_for_FSM flag on Int_Trig
689
        elsif( Int_Trig = '1' )then
690
          Wait_for_FSM       <= '1';
691
        end if;
692
             if( INT_Ctrl.Mask_Set = '1' )then
693
          Mask               <= INT_Ctrl.Mask_Data(7 downto 1);
694
                  end if;
695
                  ISR_Q                <= ISR_D;
696
                  if( Int_Trig = '1' )then
697
                    History(Hist_Ptr+1) <= Hist_Level;
698
                    Hist_Ptr           <= Hist_Ptr + 1;
699
                  elsif( Int_RTI = '1' and Hist_Ptr > 0 )then
700
                    Hist_Ptr           <= Hist_Ptr - 1;
701
                  end if;
702
      end if;
703
    end if;
704
  end process;
705
 
706
end block;
707
 
708
-------------------------------------------------------------------------------
709
-- State Logic / Instruction Decoding & Execution
710
-------------------------------------------------------------------------------
711
 
712
Open8_FSM : block is
713
 
714
  -- These are all the primary instructions/op-codes (upper 5-bits)
715
  constant OP_INC            : OPCODE_TYPE := "00000";
716
  constant OP_ADC            : OPCODE_TYPE := "00001";
717
  constant OP_TX0            : OPCODE_TYPE := "00010";
718
  constant OP_OR             : OPCODE_TYPE := "00011";
719
  constant OP_AND            : OPCODE_TYPE := "00100";
720
  constant OP_XOR            : OPCODE_TYPE := "00101";
721
  constant OP_ROL            : OPCODE_TYPE := "00110";
722
  constant OP_ROR            : OPCODE_TYPE := "00111";
723
  constant OP_DEC            : OPCODE_TYPE := "01000";
724
  constant OP_SBC            : OPCODE_TYPE := "01001";
725
  constant OP_ADD            : OPCODE_TYPE := "01010";
726
  constant OP_STP            : OPCODE_TYPE := "01011";
727
  constant OP_BTT            : OPCODE_TYPE := "01100";
728
  constant OP_CLP            : OPCODE_TYPE := "01101";
729
  constant OP_T0X            : OPCODE_TYPE := "01110";
730
  constant OP_CMP            : OPCODE_TYPE := "01111";
731
  constant OP_PSH            : OPCODE_TYPE := "10000";
732
  constant OP_POP            : OPCODE_TYPE := "10001";
733
  constant OP_BR0            : OPCODE_TYPE := "10010";
734
  constant OP_BR1            : OPCODE_TYPE := "10011";
735
  constant OP_DBNZ           : OPCODE_TYPE := "10100"; -- USR
736
  constant OP_INT            : OPCODE_TYPE := "10101";
737
  constant OP_MUL            : OPCODE_TYPE := "10110"; -- USR2
738
  constant OP_STK            : OPCODE_TYPE := "10111";
739
  constant OP_UPP            : OPCODE_TYPE := "11000";
740
  constant OP_STA            : OPCODE_TYPE := "11001";
741
  constant OP_STX            : OPCODE_TYPE := "11010";
742
  constant OP_STO            : OPCODE_TYPE := "11011";
743
  constant OP_LDI            : OPCODE_TYPE := "11100";
744
  constant OP_LDA            : OPCODE_TYPE := "11101";
745
  constant OP_LDX            : OPCODE_TYPE := "11110";
746
  constant OP_LDO            : OPCODE_TYPE := "11111";
747
 
748
  -- These are all specific sub-opcodes for OP_STK / 0xB8 (lower 3-bits)
749
  constant SOP_RSP           : SUBOP_TYPE := "000";
750
  constant SOP_RTS           : SUBOP_TYPE := "001";
751
  constant SOP_RTI           : SUBOP_TYPE := "010";
752
  constant SOP_BRK           : SUBOP_TYPE := "011";
753
  constant SOP_JMP           : SUBOP_TYPE := "100";
754
  constant SOP_SMSK          : SUBOP_TYPE := "101";
755
  constant SOP_GMSK          : SUBOP_TYPE := "110";
756
  constant SOP_JSR           : SUBOP_TYPE := "111";
757
 
758
  -- Preinitialization is for simulation only - check actual reset conditions
759
  type CPU_STATES is (
760
      -- Instruction fetch & Decode
761
    PIPE_FILL_0, PIPE_FILL_1, PIPE_FILL_2, INSTR_DECODE,
762
    -- Branching
763
    BRN_C1, DBNZ_C1, JMP_C1, JMP_C2,
764
    -- Loads
765
    LDA_C1, LDA_C2, LDA_C3, LDA_C4, LDI_C1, LDO_C1, LDX_C1, LDX_C2, LDX_C3,
766
    -- Stores
767
    STA_C1, STA_C2, STA_C3, STO_C1, STX_C1, STX_C2,
768
    -- 2-cycle math
769
    MUL_C1, UPP_C1,
770
    -- Stack
771
    PSH_C1, POP_C1, POP_C2, POP_C3, POP_C4,
772
    -- Subroutines & Interrupts
773
    WAIT_FOR_INT, ISR_C1, ISR_C2, ISR_C3, JSR_C1, JSR_C2,
774
    RTS_C1, RTS_C2, RTS_C3, RTS_C4, RTS_C5, RTI_C6,
775
    -- Debugging
776
    BRK_C1 );
777
 
778
  signal CPU_Next_State      : CPU_STATES := PIPE_FILL_0;
779
  signal CPU_State           : CPU_STATES := PIPE_FILL_0;
780
 
781
  type CACHE_MODES is (CACHE_IDLE, CACHE_INSTR, CACHE_OPER1, CACHE_OPER2,
782
                       CACHE_PREFETCH );
783
  signal Cache_Ctrl          : CACHE_MODES := CACHE_IDLE;
784
 
785
  signal Opcode              : OPCODE_TYPE := (others => '0');
786
  signal SubOp, SubOp_p1     : SUBOP_TYPE  := (others => '0');
787
  -- synthesis translate_off
788
  signal Instruction         : DATA_TYPE   := (others => '0');
789
  -- synthesis translate_on
790
  signal Prefetch            : DATA_TYPE   := (others => '0');
791
  signal Operand1, Operand2  : DATA_TYPE   := (others => '0');
792
 
793
  signal Instr_Prefetch      : std_logic   := '0';
794
 
795
  signal Ack_D, Ack_Q, Ack_Q1: std_logic   := '0';
796
  signal Int_RTI_D           : std_logic   := '0';
797
 
798
begin
799
 
800
  -- synthesis translate_off
801
  Instruction                <= Opcode & SubOp;
802
  -- synthesis translate_on
803
 
804
  State_Logic: process(CPU_State, ALU_Regs, ALU_Flags, Int_Mask, Opcode,
805
                       SubOp , SubOp_p1, Operand1, Operand2, Int_Req )
806
    variable Reg, Reg_1      : integer range 0 to 7 := 0;
807
    variable Offset_SX       : ADDRESS_TYPE;
808
  begin
809
    CPU_Next_State           <= CPU_State;
810
    Cache_Ctrl               <= CACHE_IDLE;
811
    --
812
    ALU_Ctrl.Oper            <= ALU_IDLE;
813
    ALU_Ctrl.Reg             <= ACCUM;
814
    ALU_Ctrl.Data            <= x"00";
815
    --
816
    PC_Ctrl.Oper             <= PC_IDLE;
817
 
818
    PC_Ctrl.Offset           <= x"03";
819
    PC_Ctrl.Addr             <= x"0000";
820
    --
821
    SP_Ctrl.Oper             <= SP_IDLE;
822
    --
823
    AS_Ctrl.Src              <= ADDR_PC;
824
    IMM                      <= x"0000";
825
    --
826
    DP_Ctrl.Src              <= DATA_IDLE;
827
    DP_Ctrl.Reg              <= ACCUM;
828
    --
829
    INT_Ctrl.Mask_Set        <= '0';
830
    INT_Ctrl.Soft_Ints       <= x"00";
831
    INT_Ctrl.Incr_ISR        <= '0';
832
    Ack_D                    <= '0';
833
    Int_RTI_D                <= '0';
834
 
835
    -- Assign the most common value of Reg and Reg1 outside the case structure
836
    --  to simplify things.
837
    Reg                      := conv_integer(SubOp);
838
    Reg_1                    := conv_integer(SubOp_p1);
839
    Offset_SX(15 downto 0)   := (others => Operand1(7));
840
    Offset_SX(7 downto 0)    := Operand1;
841
 
842
    case CPU_State is
843
-------------------------------------------------------------------------------
844
-- Initial Instruction fetch & decode
845
-------------------------------------------------------------------------------
846
      when PIPE_FILL_0 =>
847
        CPU_Next_State       <= PIPE_FILL_1;
848
        PC_Ctrl.Oper         <= PC_INCR;
849
 
850
      when PIPE_FILL_1 =>
851
        CPU_Next_State       <= PIPE_FILL_2;
852
        PC_Ctrl.Oper         <= PC_INCR;
853
 
854
      when PIPE_FILL_2 =>
855
        CPU_Next_State       <= INSTR_DECODE;
856
        Cache_Ctrl           <= CACHE_INSTR;
857
        PC_Ctrl.Oper         <= PC_INCR;
858
 
859
      when INSTR_DECODE =>
860
        CPU_Next_State       <= INSTR_DECODE;
861
        Cache_Ctrl           <= CACHE_INSTR;
862
 
863
        case Opcode is
864
          when OP_PSH =>
865
            CPU_Next_State   <= PSH_C1;
866
            Cache_Ctrl       <= CACHE_PREFETCH;
867
            PC_Ctrl.Oper     <= PC_REV1;
868
            DP_Ctrl.Src      <= DATA_REG;
869
            DP_Ctrl.Reg      <= SubOp;
870
 
871
          when OP_POP =>
872
            CPU_Next_State   <= POP_C1;
873
            Cache_Ctrl       <= CACHE_PREFETCH;
874
            PC_Ctrl.Oper     <= PC_REV2;
875
            SP_Ctrl.Oper     <= SP_POP;
876
 
877
          when OP_BR0 | OP_BR1 =>
878
            CPU_Next_State   <= BRN_C1;
879
            Cache_Ctrl       <= CACHE_OPER1;
880
            PC_Ctrl.Oper     <= PC_INCR;
881
 
882
          when OP_DBNZ =>
883
            CPU_Next_State   <= DBNZ_C1;
884
            Cache_Ctrl       <= CACHE_OPER1;
885
            PC_Ctrl.Oper     <= PC_INCR;
886
            ALU_Ctrl.Oper    <= ALU_DEC;
887
            ALU_Ctrl.Reg     <= SubOp;
888
 
889
          when OP_INT =>
890
            PC_Ctrl.Oper     <= PC_INCR;
891
            if( Int_Mask(Reg) = '1' )then
892
              CPU_Next_State <= WAIT_FOR_INT;
893
              INT_Ctrl.Soft_Ints(Reg) <= '1';
894
            end if;
895
 
896
          when OP_STK =>
897
            case SubOp is
898
              when SOP_RSP  =>
899
                PC_Ctrl.Oper <= PC_INCR;
900
                SP_Ctrl.Oper <= SP_RSET;
901
 
902
              when SOP_RTS | SOP_RTI =>
903
                CPU_Next_State <= RTS_C1;
904
                Cache_Ctrl   <= CACHE_IDLE;
905
                SP_Ctrl.Oper <= SP_POP;
906
 
907
              when SOP_BRK  =>
908
                CPU_Next_State <= BRK_C1;
909
                PC_Ctrl.Oper <= PC_REV2;
910
 
911
              when SOP_JMP  =>
912
                CPU_Next_State <= JMP_C1;
913
                Cache_Ctrl   <= CACHE_OPER1;
914
 
915
              when SOP_SMSK =>
916
                PC_Ctrl.Oper <= PC_INCR;
917
                INT_Ctrl.Mask_Set <= '1';
918
 
919
              when SOP_GMSK =>
920
                PC_Ctrl.Oper <= PC_INCR;
921
                ALU_Ctrl.Oper<= ALU_LDI;
922
                ALU_Ctrl.Reg <= ACCUM;
923
                ALU_Ctrl.Data<= Int_Mask;
924
 
925
              when SOP_JSR =>
926
                CPU_Next_State <= JSR_C1;
927
                Cache_Ctrl   <= CACHE_OPER1;
928
                DP_Ctrl.Src  <= DATA_PC;
929
                DP_Ctrl.Reg  <= ACCUM+1;
930
 
931
              when others => null;
932
            end case;
933
 
934
          when OP_MUL =>
935
            CPU_Next_State   <= MUL_C1;
936
            Cache_Ctrl       <= CACHE_PREFETCH;
937
 
938
            -- We need to back the PC up by 1, and all it to refill. An
939
            --  unfortunate consequence of the pipelining. We can get away with
940
            --  only 1 extra clock by pre-fetching the next instruction, though
941
            PC_Ctrl.Oper     <= PC_REV1;
942
            -- Multiplication is automatic, but requires a single clock cycle.
943
            --  We need to specify the register for Rn (R1:R0 = R0 * Rn) now,
944
            --   but will issue the multiply command on the next clock to copy
945
            --   the results to the specified register.
946
            ALU_Ctrl.Oper    <= ALU_IDLE;
947
            ALU_Ctrl.Reg     <= SubOp; -- Rn
948
 
949
          when OP_UPP =>
950
            CPU_Next_State   <= UPP_C1;
951
            Cache_Ctrl       <= CACHE_PREFETCH;
952
            PC_Ctrl.Oper     <= PC_REV1;
953
            ALU_Ctrl.Oper    <= Opcode;
954
            ALU_Ctrl.Reg     <= SubOp;
955
 
956
          when OP_LDA =>
957
            CPU_Next_State   <= LDA_C1;
958
            Cache_Ctrl       <= CACHE_OPER1;
959
 
960
          when OP_LDI =>
961
            CPU_Next_State   <= LDI_C1;
962
            Cache_Ctrl       <= CACHE_OPER1;
963
            PC_Ctrl.Oper     <= PC_INCR;
964
 
965
          when OP_LDO =>
966
            CPU_Next_State   <= LDO_C1;
967
            Cache_Ctrl       <= CACHE_OPER1;
968
            PC_Ctrl.Oper     <= PC_REV2;
969
 
970
          when OP_LDX =>
971
            CPU_Next_State   <= LDX_C1;
972
            PC_Ctrl.Oper     <= PC_REV2;
973
            AS_Ctrl.Src      <= ADDR_IMM;
974
            -- If auto-increment is disabled, use the specified register pair,
975
            --  otherwise, for an odd:even pair, and issue the first half of
976
            --  a UPP instruction to the ALU
977
            if( Enable_Auto_Increment = '0' )then
978
              IMM            <= ALU_Regs(Reg_1) & ALU_Regs(Reg);
979
            else
980
              Reg            := conv_integer(SubOp(2 downto 1) & '0');
981
              Reg_1          := conv_integer(SubOp(2 downto 1) & '1');
982
              IMM            <= ALU_Regs(Reg_1) & ALU_Regs(Reg);
983
              if( SubOp(0) = '1' )then
984
                ALU_Ctrl.Oper<= ALU_UPP;
985
                ALU_Ctrl.Reg <= SubOp(2 downto 1) & '0';
986
              end if;
987
            end if;
988
 
989
          when OP_STA =>
990
            CPU_Next_State   <= STA_C1;
991
            Cache_Ctrl       <= CACHE_OPER1;
992
 
993
          when OP_STO =>
994
            CPU_Next_State   <= STO_C1;
995
            Cache_Ctrl       <= CACHE_OPER1;
996
            PC_Ctrl.Oper     <= PC_REV2;
997
            DP_Ctrl.Src      <= DATA_REG;
998
            DP_Ctrl.Reg      <= ACCUM;
999
 
1000
          when OP_STX =>
1001
            CPU_Next_State   <= STX_C1;
1002
            Cache_Ctrl       <= CACHE_PREFETCH;
1003
            PC_Ctrl.Oper     <= PC_REV2;
1004
            DP_Ctrl.Src      <= DATA_REG;
1005
            DP_Ctrl.Reg      <= ACCUM;
1006
 
1007
          when others =>
1008
            PC_Ctrl.Oper     <= PC_INCR;
1009
            ALU_Ctrl.Oper    <= Opcode;
1010
            ALU_Ctrl.Reg     <= SubOp;
1011
 
1012
        end case;
1013
 
1014
-------------------------------------------------------------------------------
1015
-- Program Control (BR0_C1, BR1_C1, DBNZ_C1, JMP )
1016
-------------------------------------------------------------------------------
1017
 
1018
      when BRN_C1 =>
1019
        CPU_Next_State       <= INSTR_DECODE;
1020
        Cache_Ctrl           <= CACHE_INSTR;
1021
        PC_Ctrl.Oper         <= PC_INCR;
1022
        if( ALU_Flags(Reg) = Opcode(0) )then
1023
          CPU_Next_State     <= PIPE_FILL_0;
1024
          Cache_Ctrl         <= CACHE_IDLE;
1025
          PC_Ctrl.Offset     <= Operand1;
1026
        end if;
1027
 
1028
      when DBNZ_C1 =>
1029
        CPU_Next_State       <= INSTR_DECODE;
1030
        Cache_Ctrl           <= CACHE_INSTR;
1031
        PC_Ctrl.Oper         <= PC_INCR;
1032
        if( ALU_Flags(FL_ZERO) = '0' )then
1033
          CPU_Next_State     <= PIPE_FILL_0;
1034
          Cache_Ctrl         <= CACHE_IDLE;
1035
          PC_Ctrl.Offset     <= Operand1;
1036
        end if;
1037
 
1038
      when JMP_C1 =>
1039
        CPU_Next_State       <= JMP_C2;
1040
        Cache_Ctrl           <= CACHE_OPER2;
1041
 
1042
      when JMP_C2 =>
1043
        CPU_Next_State       <= PIPE_FILL_0;
1044
        PC_Ctrl.Oper         <= PC_LOAD;
1045
        PC_Ctrl.Addr         <= Operand2 & Operand1;
1046
 
1047
-------------------------------------------------------------------------------
1048
-- Data Storage - Load from memory (LDA, LDI, LDO, LDX)
1049
-------------------------------------------------------------------------------
1050
 
1051
      when LDA_C1 =>
1052
        CPU_Next_State       <= LDA_C2;
1053
        Cache_Ctrl           <= CACHE_OPER2;
1054
 
1055
      when LDA_C2 =>
1056
        CPU_Next_State       <= LDA_C3;
1057
        AS_Ctrl.Src          <= ADDR_IMM;
1058
        IMM                  <= Operand2 & Operand1;
1059
 
1060
      when LDA_C3 =>
1061
        CPU_Next_State       <= LDA_C4;
1062
        PC_Ctrl.Oper         <= PC_INCR;
1063
 
1064
      when LDA_C4 =>
1065
        CPU_Next_State       <= LDI_C1;
1066
        Cache_Ctrl           <= CACHE_OPER1;
1067
        PC_Ctrl.Oper         <= PC_INCR;
1068
 
1069
      when LDI_C1 =>
1070
        CPU_Next_State       <= INSTR_DECODE;
1071
        Cache_Ctrl           <= CACHE_INSTR;
1072
        PC_Ctrl.Oper         <= PC_INCR;
1073
        ALU_Ctrl.Oper        <= ALU_LDI;
1074
        ALU_Ctrl.Reg         <= SubOp;
1075
        ALU_Ctrl.Data        <= Operand1;
1076
 
1077
      when LDO_C1 =>
1078
        CPU_Next_State       <= LDX_C1;
1079
        AS_Ctrl.Src          <= ADDR_IMM;
1080
        PC_Ctrl.Oper         <= PC_INCR;
1081
        if( Enable_Auto_Increment = '1' )then
1082
          Reg                := conv_integer(SubOp(2 downto 1) & '0');
1083
          Reg_1              := conv_integer(SubOp(2 downto 1) & '1');
1084
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg)) + Offset_SX;
1085
          if( SubOp(0) = '1' )then
1086
            ALU_Ctrl.Oper<= ALU_UPP;
1087
            ALU_Ctrl.Reg <= SubOp(2 downto 1) & '0';
1088
          end if;
1089
        else
1090
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg)) + Offset_SX;
1091
        end if;
1092
 
1093
      when LDX_C1 =>
1094
        CPU_Next_State       <= LDX_C2;
1095
        PC_Ctrl.Oper         <= PC_INCR;
1096
 
1097
      when LDX_C2 =>
1098
        CPU_Next_State       <= LDX_C3;
1099
        PC_Ctrl.Oper         <= PC_INCR;
1100
        Cache_Ctrl           <= CACHE_OPER1;
1101
 
1102
      when LDX_C3 =>
1103
        CPU_Next_State       <= INSTR_DECODE;
1104
        Cache_Ctrl           <= CACHE_INSTR;
1105
        PC_Ctrl.Oper         <= PC_INCR;
1106
        ALU_Ctrl.Oper        <= ALU_LDX;
1107
        ALU_Ctrl.Reg         <= ACCUM;
1108
        ALU_Ctrl.Data        <= Operand1;
1109
 
1110
-------------------------------------------------------------------------------
1111
-- Data Storage - Load from memory (STA, STO, STX)
1112
-------------------------------------------------------------------------------
1113
      when STA_C1 =>
1114
        CPU_Next_State       <= STA_C2;
1115
        Cache_Ctrl           <= CACHE_OPER2;
1116
        DP_Ctrl.Src          <= DATA_REG;
1117
        DP_Ctrl.Reg          <= SubOp;
1118
 
1119
      when STA_C2 =>
1120
        CPU_Next_State       <= STA_C3;
1121
        AS_Ctrl.Src          <= ADDR_IMM;
1122
        IMM                  <= Operand2 & Operand1;
1123
        PC_Ctrl.Oper         <= PC_INCR;
1124
 
1125
      when STA_C3 =>
1126
        CPU_Next_State       <= PIPE_FILL_2;
1127
        Cache_Ctrl           <= CACHE_PREFETCH;
1128
        PC_Ctrl.Oper         <= PC_INCR;
1129
 
1130
      when STO_C1 =>
1131
        Cache_Ctrl           <= CACHE_PREFETCH;
1132
        PC_Ctrl.Oper         <= PC_INCR;
1133
        AS_Ctrl.Src          <= ADDR_IMM;
1134
        -- If auto-increment is disabled, just load the registers normally
1135
        if( Enable_Auto_Increment = '0' )then
1136
          CPU_Next_State     <= PIPE_FILL_1;
1137
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg)) + Offset_SX;
1138
        -- Otherwise, enforce the even register rule, and check the LSB to see
1139
        --  if we should perform the auto-increment on the register pair
1140
        else
1141
          CPU_Next_State     <= STX_C2;
1142
          Reg                := conv_integer(SubOp(2 downto 1) & '0');
1143
          Reg_1              := conv_integer(SubOp(2 downto 1) & '1');
1144
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg)) + Offset_SX;
1145
          if( SubOp(0) = '1' )then
1146
            ALU_Ctrl.Oper    <= ALU_UPP;
1147
            ALU_Ctrl.Reg     <= SubOp(2 downto 1) & '0';
1148
          end if;
1149
        end if;
1150
 
1151
      when STX_C1 =>
1152
        PC_Ctrl.Oper         <= PC_INCR;
1153
        AS_Ctrl.Src          <= ADDR_IMM;
1154
        -- If auto-increment is disabled, just load the registers normally
1155
        if( Enable_Auto_Increment = '0' )then
1156
          CPU_Next_State     <= PIPE_FILL_1;
1157
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg));
1158
        -- Otherwise, enforce the even register rule, and check the LSB to see
1159
        --  if we should perform the auto-increment on the register pair
1160
        else
1161
          CPU_Next_State     <= STX_C2;
1162
          Reg                := conv_integer(SubOp(2 downto 1) & '0');
1163
          Reg_1              := conv_integer(SubOp(2 downto 1) & '1');
1164
          IMM                <= (ALU_Regs(Reg_1) & ALU_Regs(Reg));
1165
          if( SubOp(0) = '1' )then
1166
            ALU_Ctrl.Oper    <= ALU_UPP;
1167
            ALU_Ctrl.Reg     <= SubOp(2 downto 1) & '0';
1168
          end if;
1169
        end if;
1170
 
1171
      when STX_C2 =>
1172
        CPU_Next_State       <= PIPE_FILL_2;
1173
        PC_Ctrl.Oper         <= PC_INCR;
1174
        ALU_Ctrl.Oper        <= ALU_UPP2;
1175
        ALU_Ctrl.Reg         <= SubOp(2 downto 1) & '1';
1176
 
1177
-------------------------------------------------------------------------------
1178
-- Multi-Cycle Math Operations (UPP, MUL)
1179
-------------------------------------------------------------------------------
1180
      -- Because we have to backup the pipeline by 1 to refetch the 2nd
1181
      --  instruction/first operand, we have to return through PF2
1182
 
1183
      when MUL_C1 =>
1184
        CPU_Next_State       <= PIPE_FILL_2;
1185
        PC_Ctrl.Oper         <= PC_INCR;
1186
        ALU_Ctrl.Oper        <= ALU_MUL;
1187
 
1188
      when UPP_C1 =>
1189
        CPU_Next_State       <= PIPE_FILL_2;
1190
        PC_Ctrl.Oper         <= PC_INCR;
1191
        ALU_Ctrl.Oper        <= ALU_UPP2;
1192
        ALU_Ctrl.Reg         <= SubOp_p1;
1193
 
1194
-------------------------------------------------------------------------------
1195
-- Basic Stack Manipulation (PSH, POP, RSP)
1196
-------------------------------------------------------------------------------
1197
      when PSH_C1 =>
1198
        CPU_Next_State       <= PIPE_FILL_1;
1199
        AS_Ctrl.Src          <= ADDR_SP;
1200
        SP_Ctrl.Oper         <= SP_PUSH;
1201
 
1202
      when POP_C1 =>
1203
        CPU_Next_State       <= POP_C2;
1204
        AS_Ctrl.Src          <= ADDR_SP;
1205
 
1206
      when POP_C2 =>
1207
        CPU_Next_State       <= POP_C3;
1208
        PC_Ctrl.Oper         <= PC_INCR;
1209
 
1210
      when POP_C3 =>
1211
        CPU_Next_State       <= POP_C4;
1212
        Cache_Ctrl           <= CACHE_OPER1;
1213
        PC_Ctrl.Oper         <= PC_INCR;
1214
 
1215
      when POP_C4 =>
1216
        CPU_Next_State       <= INSTR_DECODE;
1217
        Cache_Ctrl           <= CACHE_INSTR;
1218
        PC_Ctrl.Oper         <= PC_INCR;
1219
        ALU_Ctrl.Oper        <= ALU_POP;
1220
        ALU_Ctrl.Reg         <= SubOp;
1221
        ALU_Ctrl.Data        <= Operand1;
1222
 
1223
-------------------------------------------------------------------------------
1224
-- Subroutines & Interrupts (RTS, JSR)
1225
-------------------------------------------------------------------------------
1226
      when WAIT_FOR_INT => -- For soft interrupts only, halt the PC
1227
        CPU_Next_State       <= WAIT_FOR_INT;
1228
 
1229
      when ISR_C1 =>
1230
        CPU_Next_State       <= ISR_C2;
1231
        AS_Ctrl.Src          <= ADDR_ISR;
1232
        INT_Ctrl.Incr_ISR    <= '1';
1233
        PC_Ctrl.Oper         <= PC_INCR;
1234
        -- Rewind the PC by 3 to compensate for the pipeline registers
1235
        PC_Ctrl.Offset       <= x"FF";
1236
 
1237
      when ISR_C2 =>
1238
        CPU_Next_State       <= ISR_C3;
1239
        AS_Ctrl.Src          <= ADDR_ISR;
1240
        DP_Ctrl.Src          <= DATA_FLAG;
1241
 
1242
      when ISR_C3 =>
1243
        CPU_Next_State       <= JSR_C1;
1244
        Cache_Ctrl           <= CACHE_OPER1;
1245
        AS_Ctrl.Src          <= ADDR_SP;
1246
        SP_Ctrl.Oper         <= SP_PUSH;
1247
        DP_Ctrl.Src          <= DATA_PC;
1248
        DP_Ctrl.Reg          <= ACCUM+1;
1249
        ALU_Ctrl.Oper        <= ALU_STP;
1250
        ALU_Ctrl.Reg         <= INT_FLAG;
1251
        Ack_D                <= '1';
1252
 
1253
      when JSR_C1 =>
1254
        CPU_Next_State       <= JSR_C2;
1255
        Cache_Ctrl           <= CACHE_OPER2;
1256
        AS_Ctrl.Src          <= ADDR_SP;
1257
        SP_Ctrl.Oper         <= SP_PUSH;
1258
        DP_Ctrl.Src          <= DATA_PC;
1259
        DP_Ctrl.Reg          <= ACCUM;
1260
 
1261
      when JSR_C2 =>
1262
        CPU_Next_State       <= PIPE_FILL_0;
1263
        AS_Ctrl.Src          <= ADDR_SP;
1264
        SP_Ctrl.Oper         <= SP_PUSH;
1265
        PC_Ctrl.Oper         <= PC_LOAD;
1266
        PC_Ctrl.Addr         <= Operand2 & Operand1;
1267
 
1268
      when RTS_C1 =>
1269
        CPU_Next_State       <= RTS_C2;
1270
        AS_Ctrl.Src          <= ADDR_SP;
1271
        SP_Ctrl.Oper         <= SP_POP;
1272
 
1273
      when RTS_C2 =>
1274
        CPU_Next_State       <= RTS_C3;
1275
        AS_Ctrl.Src          <= ADDR_SP;
1276
        -- if this is an RTI, then we need to POP the flags
1277
        if( SubOp = SOP_RTI )then
1278
          SP_Ctrl.Oper       <= SP_POP;
1279
        end if;
1280
 
1281
      when RTS_C3 =>
1282
        CPU_Next_State       <= RTS_C4;
1283
        Cache_Ctrl           <= CACHE_OPER1;
1284
        -- It doesn't really matter what is on the address bus for RTS, while
1285
        --  it does for RTI, so we make this the default
1286
        AS_Ctrl.Src          <= ADDR_SP;
1287
 
1288
      when RTS_C4 =>
1289
        CPU_Next_State       <= RTS_C5;
1290
        Cache_Ctrl           <= CACHE_OPER2;
1291
 
1292
      when RTS_C5 =>
1293
        CPU_Next_State       <= PIPE_FILL_0;
1294
        PC_Ctrl.Oper         <= PC_LOAD;
1295
        PC_Ctrl.Addr         <= Operand2 & Operand1;
1296
        if( SubOp = SOP_RTI )then
1297
          CPU_Next_State     <= RTI_C6;
1298
          Cache_Ctrl         <= CACHE_OPER1;
1299
        end if;
1300
 
1301
      when RTI_C6 =>
1302
        CPU_Next_State       <= PIPE_FILL_1;
1303
        PC_Ctrl.Oper         <= PC_INCR;
1304
        ALU_Ctrl.Oper        <= ALU_RFLG;
1305
        ALU_Ctrl.Data        <= Operand1;
1306
        PC_Ctrl.Oper         <= PC_INCR;
1307
        Int_RTI_D            <= '1';
1308
 
1309
-------------------------------------------------------------------------------
1310
-- Debugging (BRK) Performs a 5-clock NOP
1311
-------------------------------------------------------------------------------
1312
      when BRK_C1 =>
1313
        CPU_Next_State       <= PIPE_FILL_0;
1314
 
1315
      when others => null;
1316
    end case;
1317
 
1318
    -- Interrupt service routines can only begin during the decode and wait
1319
    --  states to avoid corruption due to incomplete instruction execution
1320
    if( Int_Req = '1' )then
1321
      if( CPU_State = INSTR_DECODE or CPU_State = WAIT_FOR_INT )then
1322
        CPU_Next_State       <= ISR_C1;
1323
      end if;
1324
    end if;
1325
 
1326
  end process;
1327
 
1328
  S_Regs: process( Reset_n, Clock )
1329
  begin
1330
    if( Reset_n = '0' )then
1331
      CPU_State              <= PIPE_FILL_0;
1332
      Opcode                 <= OP_INC;
1333
      SubOp                  <= ACCUM;
1334
      SubOp_p1               <= ACCUM;
1335
      Operand1               <= x"00";
1336
      Operand2               <= x"00";
1337
      Instr_Prefetch         <= '0';
1338
      Prefetch               <= x"00";
1339
 
1340
      Ack_Q                  <= '0';
1341
      Ack_Q1                 <= '0';
1342
      Int_Ack                <= '0';
1343
      Int_RTI                <= '0';
1344
 
1345
    elsif( rising_edge(Clock) )then
1346
      if( Halt = '0' )then
1347
        CPU_State            <= CPU_Next_State;
1348
        case Cache_Ctrl is
1349
          when CACHE_INSTR =>
1350
            Opcode           <= Rd_Data(7 downto 3);
1351
            SubOp            <= Rd_Data(2 downto 0);
1352
            SubOp_p1         <= Rd_Data(2 downto 0) + 1;
1353
            if( Instr_Prefetch = '1' )then
1354
              Opcode         <= Prefetch(7 downto 3);
1355
              SubOp          <= Prefetch(2 downto 0);
1356
              SubOp_p1       <= Prefetch(2 downto 0) + 1;
1357
              Instr_Prefetch <= '0';
1358
            end if;
1359
          when CACHE_OPER1 =>
1360
            Operand1         <= Rd_Data;
1361
          when CACHE_OPER2 =>
1362
            Operand2         <= Rd_Data;
1363
          when CACHE_PREFETCH =>
1364
            Prefetch         <= Rd_Data;
1365
            Instr_Prefetch   <= '1';
1366
          when CACHE_IDLE =>
1367
            null;
1368
        end case;
1369
 
1370
        -- Interrupt signalling registers
1371
        Ack_Q                <= Ack_D;
1372
        Ack_Q1               <= Ack_Q;
1373
        Int_Ack              <= Ack_Q1;
1374
        Int_RTI              <= Int_RTI_D;
1375
      end if;
1376
    end if;
1377
  end process;
1378
 
1379
-------------------------------------------------------------------------------
1380
-- Fixed in-line statements for the interrupt mask, and stack pointer address
1381
-------------------------------------------------------------------------------
1382
 
1383
-- The interrupt control mask is always sourced out of R0
1384
  INT_Ctrl.Mask_Data         <= ALU_Regs(conv_integer(ACCUM));
1385
 
1386
-- The original RSP instruction simply reset the stack pointer to the preset
1387
--  address set at compile time. However, with little extra effort, we can
1388
--  modify the instruction to allow the stack pointer to be moved anywhere in
1389
--  the memory map. Since RSP can't have an sub-opcode, R1:R0 was chosen as
1390
--  a fixed source
1391
 
1392
Prog_Stack_Addr_Move_fn: if( Allow_Stack_Address_Move = '1' )generate
1393
  SP_Ctrl.Addr               <= ALU_Regs(1) & ALU_Regs(0);
1394
end generate;
1395
 
1396
Normal_Stack_Reset_fn: if( Allow_Stack_Address_Move = '0' )generate
1397
  SP_Ctrl.Addr               <= Stack_Start_Addr;
1398
end generate;
1399
 
1400
end block;
1401
 
1402
-------------------------------------------------------------------------------
1403
-- Address Source Mux
1404
-------------------------------------------------------------------------------
1405
 
1406
Open8_AS : block is
1407
begin
1408
 
1409
  Address_Select: process( AS_Ctrl, PC, SP, IMM, ISR )
1410
    variable PC_Mux, SP_Mux  : ADDRESS_TYPE;
1411
    variable IMM_Mux, ISR_Mux: ADDRESS_TYPE;
1412
  begin
1413
    PC_Mux                   := (others => '0');
1414
    SP_Mux                   := (others => '0');
1415
    IMM_Mux                  := (others => '0');
1416
    ISR_Mux                  := (others => '0');
1417
 
1418
    case AS_Ctrl.Src is
1419
      when ADDR_PC =>
1420
        PC_Mux               := PC;
1421
      when ADDR_SP =>
1422
        SP_Mux               := SP;
1423
      when ADDR_IMM =>
1424
        IMM_Mux              := IMM;
1425
      when ADDR_ISR =>
1426
        ISR_Mux              := ISR;
1427
    end case;
1428
 
1429
    for i in 0 to 15 loop
1430
      Address(i)             <= PC_Mux(i) or SP_Mux(i) or IMM_Mux(i) or
1431
                                ISR_Mux(i);
1432
    end loop;
1433
  end process;
1434
 
1435
end block;
1436
 
1437
-------------------------------------------------------------------------------
1438
-- (Write) Data Path
1439
-------------------------------------------------------------------------------
1440
 
1441
Open8_DP : block is
1442
  signal Wr_Data_D           : DATA_TYPE := (others => '0');
1443
  signal Wr_Enable_D         : std_logic := '0';
1444
begin
1445
 
1446
  Data_Select: process( DP_Ctrl, ALU_Regs, ALU_Flags, PC )
1447
    variable Reg_Mux, PC_Mux : DATA_TYPE;
1448
    variable Flag_Mux        : DATA_TYPE;
1449
  begin
1450
    Reg_Mux                  := (others => '0');
1451
    Flag_Mux                 := (others => '0');
1452
    PC_Mux                   := (others => '0');
1453
    Wr_Enable_D              <= '0';
1454
 
1455
    case DP_Ctrl.Src is
1456
      when DATA_IDLE =>
1457
        null;
1458
      when DATA_REG =>
1459
        Reg_Mux              := ALU_Regs(conv_integer(DP_Ctrl.Reg));
1460
        Wr_Enable_D          <= '1';
1461
      when DATA_FLAG =>
1462
        Flag_Mux             := ALU_Flags;
1463
        Wr_Enable_D          <= '1';
1464
      when DATA_PC =>
1465
        Wr_Enable_D          <= '1';
1466
        if( DP_Ctrl.Reg = ACCUM )then
1467
          PC_Mux             := PC(7 downto 0);
1468
        else
1469
          PC_Mux             := PC(15 downto 8);
1470
        end if;
1471
    end case;
1472
 
1473
    for i in 0 to 7 loop
1474
      Wr_Data_D(i)           <= Reg_Mux(i) or Flag_Mux(i) or PC_Mux(i);
1475
    end loop;
1476
  end process;
1477
 
1478
  S_Regs: process( Reset_n, Clock )
1479
  begin
1480
    if( Reset_n = '0' )then
1481
      Wr_Data                <= (others => '0');
1482
      Wr_Enable              <= '0';
1483
      Rd_Enable              <= '1';
1484
    elsif( rising_edge(Clock) )then
1485
      if( Halt = '0' )then
1486
        Wr_Data              <= Wr_Data_D;
1487
        Wr_Enable            <= Wr_Enable_D;
1488
        Rd_Enable            <= not Wr_Enable_D;
1489
      end if;
1490
    end if;
1491
  end process;
1492
 
1493
end block;
1494
 
1495
end rtl;

powered by: WebSVN 2.1.0

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