1 |
2 |
tarookumic |
-- $(lic)
|
2 |
|
|
-- $(help_generic)
|
3 |
|
|
-- $(help_local)
|
4 |
|
|
|
5 |
|
|
library ieee;
|
6 |
|
|
use ieee.std_logic_1164.all;
|
7 |
|
|
use work.armpctrl.all;
|
8 |
|
|
use work.armpmodel.all;
|
9 |
|
|
use work.armcmd.all;
|
10 |
|
|
use work.armldst.all;
|
11 |
|
|
use work.armdecode.all;
|
12 |
|
|
use work.arm_comp.all;
|
13 |
|
|
use work.armcmd_comp.all;
|
14 |
|
|
|
15 |
|
|
entity armcmd_sm is
|
16 |
|
|
port (
|
17 |
|
|
rst : in std_logic;
|
18 |
|
|
clk : in std_logic;
|
19 |
|
|
i : in armcmd_sm_typ_in;
|
20 |
|
|
o : out armcmd_sm_typ_out
|
21 |
|
|
);
|
22 |
|
|
end armcmd_sm;
|
23 |
|
|
|
24 |
|
|
architecture rtl of armcmd_sm is
|
25 |
|
|
|
26 |
|
|
type armcmd_sm_tmp_type is record
|
27 |
|
|
o : armcmd_sm_typ_out;
|
28 |
|
|
ctrlmemo : acm_ctrlmemout;
|
29 |
|
|
end record;
|
30 |
|
|
type armcmd_sm_reg_type is record
|
31 |
|
|
cnt : std_logic_vector(ACM_CNT_SZ-1 downto 0);
|
32 |
|
|
end record;
|
33 |
|
|
type armcmd_sm_dbg_type is record
|
34 |
|
|
dummy : std_logic;
|
35 |
|
|
-- pragma translate_off
|
36 |
|
|
dbg : armcmd_sm_tmp_type;
|
37 |
|
|
-- pragma translate_on
|
38 |
|
|
end record;
|
39 |
|
|
signal r, c : armcmd_sm_reg_type;
|
40 |
|
|
signal rdbg, cdbg : armcmd_sm_dbg_type;
|
41 |
|
|
|
42 |
|
|
begin
|
43 |
|
|
|
44 |
|
|
p0: process (clk, rst, r, i )
|
45 |
|
|
variable v : armcmd_sm_reg_type;
|
46 |
|
|
variable t : armcmd_sm_tmp_type;
|
47 |
|
|
variable vdbg : armcmd_sm_dbg_type;
|
48 |
|
|
begin
|
49 |
|
|
|
50 |
|
|
-- $(init(t:armcmd_sm_tmp_type))
|
51 |
|
|
|
52 |
|
|
v := r;
|
53 |
|
|
t.o.ctrlo := i.ctrli.ctrlo;
|
54 |
|
|
t.o.ctrlo.nextinsn := '0';
|
55 |
|
|
|
56 |
|
|
t.ctrlmemo := i.ctrlmulti.ctrlmemo;
|
57 |
|
|
t.ctrlmemo.rd_src := acm_rdnone;
|
58 |
|
|
|
59 |
|
|
--t.o.ctrlo.usermode_nc := t.usermode_nc;
|
60 |
|
|
|
61 |
|
|
-- LRM/STM: Increment after (regorder [0-15],start:+0,end(onwb):+4) :ldmia|stmia <rn>,{<reglist>}
|
62 |
|
|
-- LRM/STM: Increment before (regorder [0-15],start:+4,end(onwb):+0) :ldmib|stmib <rn>,{<reglist>}
|
63 |
|
|
-- LRM/STM: Decrement after (regorder [15-0],start:-0,end(onwb):-4) :ldmda|stmda <rn>,{<reglist>}
|
64 |
|
|
-- LRM/STM: Decrement before (regorder [15-0],start:-4,end(onwb):-0) :ldmdb|stmdb <rn>,{<reglist>}
|
65 |
|
|
case i.ctrli.cnt is
|
66 |
|
|
when ACM_CNT_ZERO =>
|
67 |
|
|
|
68 |
|
|
-- [frame:] start address calc, buffer <rn>
|
69 |
|
|
--
|
70 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
71 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
72 |
|
|
-- <rn>->+-----------+-+--------op1 | | |
|
73 |
|
|
-- | | +>[buf1] | \ | | |
|
74 |
|
|
-- | (regread) | | +(aluop) | +(trans) | +>(dcache)| (write)
|
75 |
|
|
-- | | | / | | | | | | |
|
76 |
|
|
-- | |startoff--op2 | | | | | | |
|
77 |
|
|
-- --+-----------+-----------+-----+-----+--+---+----+-+---------+----------+
|
78 |
|
|
-- | | | |
|
79 |
|
|
-- pctrl.data1 (as address) : +--------+ +------+
|
80 |
|
|
-- cyceven:pctrl.me.param: o-----------------------------+
|
81 |
|
|
|
82 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_through; -- route <rn> to exestg op1
|
83 |
|
|
t.ctrlmemo.r1_src := acm_rrn; -- fetch <rn> (address base)
|
84 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_none; -- route 0|(-)4 to exestg op2
|
85 |
|
|
t.ctrlmemo.data2 := i.ctrlmulti.soff; -- dep. LDSTM amode: 0|(-)4
|
86 |
|
|
t.ctrlmemo.rsop_buf1_src := apc_bufsrc_through; -- save <rn> for writeback on dabort
|
87 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- save aluresult (address in(de)cerement) as MESTG_address
|
88 |
|
|
|
89 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs
|
90 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
91 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
92 |
|
|
|
93 |
|
|
if i.ctrlmulti.mem = '1' then
|
94 |
|
|
t.o.ctrlo.hold := '1'; -- wait for all mem cmd to finish first
|
95 |
|
|
end if;
|
96 |
|
|
|
97 |
|
|
when others =>
|
98 |
|
|
|
99 |
|
|
if i.ctrli.cnt(0) = '1' then
|
100 |
|
|
|
101 |
|
|
-- [frame: ctrli.cnt=odd] writedata issue
|
102 |
|
|
--
|
103 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
104 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+-----------
|
105 |
|
|
-- <nxtreg>-+ | | | | | |
|
106 |
|
|
-- | | | | | | |
|
107 |
|
|
-- | |(regread)| | (aluop) | (trans) +-+->(dcache) | (write)
|
108 |
|
|
-- | | |(alulast) | | | | /\ |
|
109 |
|
|
-- | | | +->[buf2] | | | | | |
|
110 |
|
|
-- --+-+---------+-----------+-----------+---------+-+-----+-----+-----------
|
111 |
|
|
-- | | |
|
112 |
|
|
-- +->pctrl.data2 (as memwritedata):-----------+ |
|
113 |
|
|
-- cycodd:pctrl.me.param: o----------------------+ |
|
114 |
|
|
-- cyceven:pctrl.me.param: o------------------------------+
|
115 |
|
|
|
116 |
|
|
-- todo: reading of pc:
|
117 |
|
|
|
118 |
|
|
t.ctrlmemo.r2_src := acm_local; -- fetch write data (nextreg of reglist)
|
119 |
|
|
t.ctrlmemo.rsop_buf2_src := apc_bufsrc_alures; -- save last address
|
120 |
|
|
|
121 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs
|
122 |
|
|
t.ctrlmemo.meop_param.writedata := '1'; -- MESTG: dcache inputs (wr data)
|
123 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
124 |
|
|
|
125 |
|
|
else
|
126 |
|
|
|
127 |
|
|
-- [frame: ctrli.cnt=even] address issue
|
128 |
|
|
--
|
129 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
130 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
131 |
|
|
-- | | in/Decr-op1 | | |
|
132 |
|
|
-- | | | \ | | |
|
133 |
|
|
-- | (regread) | | +(aluop) | +(trans) | +>(dcache)| (write)
|
134 |
|
|
-- | | | / | | | | | | |
|
135 |
|
|
-- | | [buf2]-op2 | | | | | | |
|
136 |
|
|
-- --+-----------+-----------+-----+-----+--+---+----+-+---------+----------+
|
137 |
|
|
-- | | | |
|
138 |
|
|
-- pctrl.data1 (as address): +--------+ +------+
|
139 |
|
|
-- cyceven:pctrl.me.param: o-----------------------------+
|
140 |
|
|
|
141 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_none; -- route ival to exestg op1
|
142 |
|
|
t.ctrlmemo.data1 := i.ctrlmulti.ival; -- dep. LDSTM amode: 0|(-)4
|
143 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_buf; -- route <alures> to exestg op2 (saved in last odd cycle)
|
144 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- save aluresult (address in(de)cerement) as MESTG_address
|
145 |
|
|
|
146 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs
|
147 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
148 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
149 |
|
|
|
150 |
|
|
end if;
|
151 |
|
|
|
152 |
|
|
end case;
|
153 |
|
|
|
154 |
|
|
-- finish - update <rn>
|
155 |
|
|
if i.ctrlmulti.reglist = ALS_REGLIST_ZERO then
|
156 |
|
|
|
157 |
|
|
t.ctrlmemo.meop_enable := '0'; -- MESTG: dcache inputs
|
158 |
|
|
|
159 |
|
|
if v.cnt(0) = i.ctrli.cnt(0) then
|
160 |
|
|
|
161 |
|
|
if i.ctrlmulti.mem = '1' then
|
162 |
|
|
t.o.ctrlo.hold := '1'; -- wait for all mem cmd to finish
|
163 |
|
|
else
|
164 |
|
|
t.o.ctrlo.nextinsn := '1';
|
165 |
|
|
end if;
|
166 |
|
|
|
167 |
|
|
else
|
168 |
|
|
|
169 |
|
|
-- [frame:] update <rn>
|
170 |
|
|
--
|
171 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
172 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
173 |
|
|
-- | | in/Decr -op1 | | |
|
174 |
|
|
-- | | | \ | | |
|
175 |
|
|
-- | (regread) | | +(aluop) | (trans) | (dcache) | +->(write)
|
176 |
|
|
-- | | | / | | | | |
|
177 |
|
|
-- | | [buf2]-op2 | | | | |
|
178 |
|
|
-- --+-----------+-----------+-----+-----+-----------+-----------+-+--------+
|
179 |
|
|
-- | |
|
180 |
|
|
-- pctrl.data1 (as wrdata): +-------------------------------+
|
181 |
|
|
|
182 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_none; -- route 0|(-)4 to exestg op1
|
183 |
|
|
t.ctrlmemo.data1 := i.ctrlmulti.eoff; -- dep. LDSTM amode: 0|(-)4
|
184 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_buf; -- route <alures> to exestg op2 (saved in last odd cycle)
|
185 |
|
|
if i.ctrli.insn.insn(ADE_WB_C) = '1' then
|
186 |
|
|
t.ctrlmemo.rd_src := acm_rdrrn;
|
187 |
|
|
end if;
|
188 |
|
|
|
189 |
|
|
end if;
|
190 |
|
|
else
|
191 |
|
|
v.cnt := i.ctrli.cnt;
|
192 |
|
|
end if;
|
193 |
|
|
|
194 |
|
|
-- dabort
|
195 |
|
|
if not (i.ctrli.cnt = ACM_CNT_ZERO) then
|
196 |
|
|
if i.ctrlmulti.dabort = '1' then
|
197 |
|
|
|
198 |
|
|
t.o.ctrlo.nextinsn := '1';
|
199 |
|
|
|
200 |
|
|
-- dabort frame, writeback <rn>
|
201 |
|
|
--
|
202 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
203 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
204 |
|
|
-- | | [buf1] -op1 | | |
|
205 |
|
|
-- | | | \ | | |
|
206 |
|
|
-- | (regread) | | +(aluop) | (trans) | (dcache) | +->(write)
|
207 |
|
|
-- | | | / | | | | |
|
208 |
|
|
-- | | 0 -op2 | | | | |
|
209 |
|
|
-- --+-----------+-----------+-----+-----+-----------+-----------+-+--------+
|
210 |
|
|
-- | |
|
211 |
|
|
-- pctrl.data1 (as wrdata): +-------------------------------+
|
212 |
|
|
|
213 |
|
|
t.ctrlmemo.rd_src := acm_rdrrn;
|
214 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_buf; -- route old <rn> to exestg op1 (saved in cycle zero)
|
215 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_none; -- route 0 to exestg op2
|
216 |
|
|
t.ctrlmemo.data2 := (others => '0');
|
217 |
|
|
|
218 |
|
|
t.ctrlmemo.meop_enable := '0'; -- MESTG: dcache inputs
|
219 |
|
|
end if;
|
220 |
|
|
end if;
|
221 |
|
|
|
222 |
|
|
-- reset
|
223 |
|
|
if ( rst = '0' ) then
|
224 |
|
|
end if;
|
225 |
|
|
|
226 |
|
|
t.o.ctrlmemo := t.ctrlmemo;
|
227 |
|
|
|
228 |
|
|
c <= v;
|
229 |
|
|
|
230 |
|
|
o <= t.o;
|
231 |
|
|
|
232 |
|
|
-- pragma translate_off
|
233 |
|
|
vdbg := rdbg;
|
234 |
|
|
vdbg.dbg := t;
|
235 |
|
|
cdbg <= vdbg;
|
236 |
|
|
-- pragma translate_on
|
237 |
|
|
|
238 |
|
|
end process p0;
|
239 |
|
|
|
240 |
|
|
pregs : process (clk, c)
|
241 |
|
|
begin
|
242 |
|
|
if rising_edge(clk) then
|
243 |
|
|
r <= c;
|
244 |
|
|
-- pragma translate_off
|
245 |
|
|
rdbg <= cdbg;
|
246 |
|
|
-- pragma translate_on
|
247 |
|
|
end if;
|
248 |
|
|
end process;
|
249 |
|
|
|
250 |
|
|
end rtl;
|