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

Subversion Repositories rise

[/] [rise/] [trunk/] [vhdl/] [if_stage.vhd] - Blame information for rev 107

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

Line No. Rev Author Line
1 86 cwalter
 
2 2 jlechner
-- File: if_stage.vhd
3
-- Author: Jakob Lechner, Urban Stadler, Harald Trinkl, Christian Walter
4
-- Created: 2006-11-29
5
-- Last updated: 2006-11-29
6
 
7
-- Description:
8
-- Instruction fetch stage
9
-------------------------------------------------------------------------------
10
 
11
library IEEE;
12
use IEEE.STD_LOGIC_1164.all;
13 29 cwalter
use IEEE.NUMERIC_STD.all;
14 2 jlechner
use WORK.RISE_PACK.all;
15 107 cwalter
use WORK.RISE_PACK_SPECIFIC.all;
16 2 jlechner
 
17
entity if_stage is
18
 
19
  port (
20 29 cwalter
    clk   : in std_logic;
21
    reset : in std_logic;
22 2 jlechner
 
23
    if_id_register : out IF_ID_REGISTER_T;
24
 
25 29 cwalter
    branch        : in std_logic;
26
    branch_target : in PC_REGISTER_T;
27
    clear_in      : in std_logic;
28
    stall_in      : in std_logic;
29 2 jlechner
 
30 29 cwalter
    pc      : in  PC_REGISTER_T;
31
    pc_next : out PC_REGISTER_T;
32 2 jlechner
 
33 29 cwalter
    imem_addr : out MEM_ADDR_T;
34
    imem_data : in  MEM_DATA_T);
35 2 jlechner
 
36
end if_stage;
37 86 cwalter
 
38 29 cwalter
--architecture if_stage_rtl of if_stage is
39
--  signal if_id_register_int     : IF_ID_REGISTER_T;
40
--  signal if_id_register_next    : IF_ID_REGISTER_T;
41
--  
42
--begin  -- if_stage_rtl
43
--
44
----  if_id_register        <= if_id_register_int;
45
--  
46
----  process (clk, reset)
47
----  begin  -- process
48
----    if reset = '0' then                 -- asynchronous reset (active low)
49
----      if_id_register_int        <= (others => (others => '0'));
50
----      if_id_register_next       <= (others => (others => '0'));
51
----    elsif clk'event and clk = '1' then  -- rising clock edge
52
----      if_id_register_int        <= if_id_register_next;
53
----    end if;
54
----  end process;
55
--
56
--end if_stage_rtl;
57 2 jlechner
 
58 29 cwalter
-- This is a simple hardcoded IF unit for the  RISE processor. It does not
59 93 jlechner
-- use the memory and contains a hardcoded program.
60 29 cwalter
architecture if_state_behavioral of if_stage is
61 93 jlechner
 
62
  signal if_id_register_int  : IF_ID_REGISTER_T := ( others => ( others => '0' ) );
63
  signal if_id_register_next : IF_ID_REGISTER_T := ( others => ( others => '0' ) );
64
  signal cur_pc : PC_REGISTER_T;
65
 
66 29 cwalter
begin
67
  if_id_register <= if_id_register_int;
68 93 jlechner
  cur_pc <= pc when branch = '0' else branch_target;
69 2 jlechner
 
70 33 cwalter
  process (clk, reset, clear_in)
71 29 cwalter
  begin
72 93 jlechner
    if reset = '0' then
73 29 cwalter
      if_id_register_int.pc <= PC_RESET_VECTOR;
74
      if_id_register_int.ir <= (others => '0');
75
    elsif clk'event and clk = '1' then
76
      if stall_in = '0' then
77
        if_id_register_int <= if_id_register_next;
78
      end if;
79
    end if;
80
  end process;
81
 
82 93 jlechner
  process (reset, branch, branch_target, cur_pc, stall_in)
83 29 cwalter
  begin
84 85 jlechner
    if reset = '0' then
85 29 cwalter
      if_id_register_next.pc <= PC_RESET_VECTOR;
86 86 cwalter
      pc_next                <= PC_RESET_VECTOR;
87 29 cwalter
    else
88 93 jlechner
      if_id_register_next.pc <= cur_pc;
89
 
90 50 cwalter
      if stall_in = '0' then
91 93 jlechner
        pc_next <= std_logic_vector(unsigned(cur_pc) + 2);
92 29 cwalter
      else
93 93 jlechner
        pc_next <= cur_pc;
94 29 cwalter
      end if;
95
    end if;
96
  end process;
97
 
98 50 cwalter
  -- 00000000 <reset>:
99
  -- 0:   81 03           ld R1,#0x3
100
  -- 2:   91 01           ldhb R1,#0x1
101
  -- 4:   82 30           ld R2,#0x30
102
  -- 6:   82 33           ld R2,#0x33
103
  -- 8:   10 12           add R1,R2
104
  -- a:   88 00           ld R8,#0x0
105
  -- c:   98 00           ldhb R8,#0x0
106
  -- e:   70 08           jmp R8
107 93 jlechner
  -- 10:  10 12           add R1,R2
108
  -- 12:  81 04           ld R1,#0x3
109 86 cwalter
 
110 93 jlechner
--   process (cur_pc)
111
--   begin
112
--     case cur_pc is
113
--       when x"0000" => if_id_register_next.ir <= x"8103";  -- ld R1,#0x3
114
--       when x"0002" => if_id_register_next.ir <= x"9101";  -- ldhb R1,#0x1
115
--       when x"0004" => if_id_register_next.ir <= x"8230";  -- ld R2,#0x30
116
--       when x"0006" => if_id_register_next.ir <= x"8233";  -- ld R2,#0x33
117
--       when x"0008" => if_id_register_next.ir <= x"1012";  -- add R1,R2
118
--       when x"000A" => if_id_register_next.ir <= x"8800";  -- ld R8,#0x0
119
--       when x"000C" => if_id_register_next.ir <= x"9800";  -- ldhb R8,#0x0
120
--       when x"000E" => if_id_register_next.ir <= x"7008";  -- jmp R8
121
--       when x"0010" => if_id_register_next.ir <= x"1012";  -- add R1,R2
122
--       when x"0012" => if_id_register_next.ir <= x"8104";  -- ld R1,#0x3
123
--       when others => if_id_register_next.ir <= x"0000"; -- nop
124
--     end case;
125
--   end process;
126
 
127
 
128 86 cwalter
--Disassembly of section .text:
129
--
130
 
131
  --00000000 <reset>:
132
  --   0:   83 0c           ld R3,#0xc
133
  --   2:   93 00           ldhb R3,#0x0
134
  --   4:   84 10           ld R4,#0x10
135
  --   6:   94 00           ldhb R4,#0x0
136
  --   8:   85 18           ld R5,#0x18
137
  --   a:   95 00           ldhb R5,#0x0
138
  --
139
  --0000000c <loop_start>:
140
  --   c:   08 10           ld R1,R0
141
  --   e:   81 05           ld R1,#0x5
142
  --
143
  --00000010 <loop_middle>:
144
  --  10:   78 10           tst R1
145
  --  12:   72 50           jmpz R5
146
  --  14:   28 11           sub R1,#0x1
147
  --  16:   70 40           jmp R4
148
  --
149
  --00000018 <loop_end>:
150
  --  18:   70 30           jmp R3
151 107 cwalter
--  
152
--  process (cur_pc)
153
--  begin
154
--    case cur_pc is
155
--      when x"0000" => if_id_register_next.ir <= x"830c";  -- ld R3,#0xc
156
--      when x"0002" => if_id_register_next.ir <= x"9300";  -- ldhb R3,#0x0
157
--      when x"0004" => if_id_register_next.ir <= x"8410";  -- ld R4,#0x10
158
--      when x"0006" => if_id_register_next.ir <= x"9400";  -- dhb R4,#0x0
159
--      when x"0008" => if_id_register_next.ir <= x"8518";  -- ld R5,#0x18
160
--      when x"000A" => if_id_register_next.ir <= x"9500";  -- ldhb R5,#0x0
161
--
162
--      when x"000C" => if_id_register_next.ir <= x"0810";  -- ld R1,R0
163
--      when x"000E" => if_id_register_next.ir <= x"8105";  -- ld R1,#0x5
164
--
165
--      when x"0010" => if_id_register_next.ir <= x"7810";  -- tst R1
166
--      when x"0012" => if_id_register_next.ir <= x"7250";  -- jmpz R5
167
--      when x"0014" => if_id_register_next.ir <= x"2811";  -- sub R1,#0x1
168
--      when x"0016" => if_id_register_next.ir <= x"7040";  -- jmp R4
169
--      when x"0018" => if_id_register_next.ir <= x"7030";  -- jmp R3
170
--      when others  => if_id_register_next.ir <= x"0000";  -- nop
171
--    end case;
172
--  end process;
173 93 jlechner
 
174 107 cwalter
  --Disassembly of section .text:
175
  --
176
  --00000000 <reset>:
177
  --   0:   81 00           ld R1,#0x0
178
  --   2:   91 10           ldhb R1,#0x10
179
  --   4:   e0 01           st R0,[R1]
180
  --   6:   82 0a           ld R2,#0xa
181
  --   8:   92 00           ldhb R2,#0x0
182
  --
183
  --0000000a <loop>:
184
  --   a:   a0 31           ld R3,[R1]
185
  --   c:   18 31           add R3,#0x1
186
  --   e:   e0 31           st R3,[R1]
187
  --  10:   70 20           jmp R2  
188
 
189 93 jlechner
  process (cur_pc)
190 29 cwalter
  begin
191 93 jlechner
    case cur_pc is
192 107 cwalter
      when x"0000" => if_id_register_next.ir <= x"8100";  -- ld R1,#0x0
193
      when x"0002" => if_id_register_next.ir <= x"9110";  -- ldhb R1,#0x10
194
      when x"0004" => if_id_register_next.ir <= x"e001";  -- st R0,[R1]
195
      when x"0006" => if_id_register_next.ir <= x"820a";  -- ld R2,#0xa
196
      when x"0008" => if_id_register_next.ir <= x"9200";  -- ldhb R2,#0x0
197 86 cwalter
 
198 107 cwalter
      when x"000A" => if_id_register_next.ir <= x"a031";  -- ld R3,[R1]
199
      when x"000C" => if_id_register_next.ir <= x"1831";  -- add R3,#0x1
200
      when x"000E" => if_id_register_next.ir <= x"e031";  -- st R3,[R1]
201
      when x"0010" => if_id_register_next.ir <= x"7020";  -- jmp R2  
202 86 cwalter
      when others  => if_id_register_next.ir <= x"0000";  -- nop
203 29 cwalter
    end case;
204 107 cwalter
  end process;
205 29 cwalter
end if_state_behavioral;
206 2 jlechner
 
207 29 cwalter
 

powered by: WebSVN 2.1.0

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