1 |
2 |
tarookumic |
-- $(lic)
|
2 |
|
|
-- $(help_generic)
|
3 |
|
|
-- $(help_local)
|
4 |
|
|
|
5 |
|
|
library ieee;
|
6 |
|
|
use ieee.std_logic_1164.all;
|
7 |
|
|
use work.int.all;
|
8 |
|
|
use work.memdef.all;
|
9 |
|
|
use work.armdecode.all;
|
10 |
|
|
use work.armpctrl.all;
|
11 |
|
|
use work.armpmodel.all;
|
12 |
|
|
use work.armcmd.all;
|
13 |
|
|
use work.armcmd_comp.all;
|
14 |
|
|
|
15 |
|
|
entity armcmd_cl is
|
16 |
|
|
port (
|
17 |
|
|
rst : in std_logic;
|
18 |
|
|
clk : in std_logic;
|
19 |
|
|
i : in armcmd_cl_typ_in;
|
20 |
|
|
o : out armcmd_cl_typ_out
|
21 |
|
|
);
|
22 |
|
|
end armcmd_cl;
|
23 |
|
|
|
24 |
|
|
architecture rtl of armcmd_cl is
|
25 |
|
|
|
26 |
|
|
type armcmd_cl_state is (armcmd_cl_process,armcmd_cl_finish);
|
27 |
|
|
type armcmd_cl_tmp_type is record
|
28 |
|
|
o : armcmd_cl_typ_out;
|
29 |
|
|
off : std_logic_vector(23 downto 0);
|
30 |
|
|
ctrlmemo : acm_ctrlmemout;
|
31 |
|
|
end record;
|
32 |
|
|
type armcmd_cl_reg_type is record
|
33 |
|
|
state : armcmd_cl_state;
|
34 |
|
|
end record;
|
35 |
|
|
type armcmd_cl_dbg_type is record
|
36 |
|
|
dummy : std_logic;
|
37 |
|
|
-- pragma translate_off
|
38 |
|
|
dbg : armcmd_cl_tmp_type;
|
39 |
|
|
-- pragma translate_on
|
40 |
|
|
end record;
|
41 |
|
|
signal r, c : armcmd_cl_reg_type;
|
42 |
|
|
signal rdbg, cdbg : armcmd_cl_dbg_type;
|
43 |
|
|
|
44 |
|
|
begin
|
45 |
|
|
|
46 |
|
|
p0: process (clk, rst, r, i )
|
47 |
|
|
variable v : armcmd_cl_reg_type;
|
48 |
|
|
variable t : armcmd_cl_tmp_type;
|
49 |
|
|
variable vdbg : armcmd_cl_dbg_type;
|
50 |
|
|
begin
|
51 |
|
|
|
52 |
|
|
-- $(init(t:armcmd_cl_tmp_type))
|
53 |
|
|
|
54 |
|
|
v := r;
|
55 |
|
|
t.o.ctrlo := i.ctrli.ctrlo;
|
56 |
|
|
t.o.ctrlo.nextinsn := '0';
|
57 |
|
|
|
58 |
|
|
case i.ctrli.cnt is
|
59 |
|
|
|
60 |
|
|
when ACM_CNT_ZERO =>
|
61 |
|
|
|
62 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout;
|
63 |
|
|
if i.ctrli.insn.insn(ADE_LDC_STC_P_C) = '0' then
|
64 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout;
|
65 |
|
|
else
|
66 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_none;
|
67 |
|
|
end if;
|
68 |
|
|
|
69 |
|
|
-- [frame: ctrli.cnt=0] start address issue
|
70 |
|
|
--
|
71 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
72 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+---------+
|
73 |
|
|
-- <rn>->+-----------+----------op1 | | |
|
74 |
|
|
-- | | | \ | | |
|
75 |
|
|
-- | (regread) | | +(aluop)+ | +(trans) | +>(dcache-+-++ (write)
|
76 |
|
|
-- | | | / | | | | | | | ||
|
77 |
|
|
-- | | startoff-op2 | | | | | | | |+->[copro]
|
78 |
|
|
-- --+-----------+-----------+-----+-----+--+---+----+-+---------+-+-------+
|
79 |
|
|
-- | | | | |
|
80 |
|
|
-- pctrl.data1 (as address): +--------+ +------+ |
|
81 |
|
|
-- cyceven:pctrl.me.param: o-------------------------------+ |
|
82 |
|
|
-- pctrl.wr.rd(<nxtreg>):o-------------------------------------+
|
83 |
|
|
|
84 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_through; -- route <rn> to exestg op1
|
85 |
|
|
t.ctrlmemo.r1_src := acm_rrn; -- fetch <rn> (address base)
|
86 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_none; -- route 0 to exestg op2
|
87 |
|
|
t.ctrlmemo.data2 := (others => '0'); -- 0
|
88 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- save aluresult (address in(de)cerement) as MESTG_address
|
89 |
|
|
t.ctrlmemo.rd_src := acm_rdnone;
|
90 |
|
|
|
91 |
|
|
t.ctrlmemo.meop_param.read := '1'; -- MESTG: dcache inputs (readdata)
|
92 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
93 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
94 |
|
|
|
95 |
|
|
if i.fromCP_busy = '1' then
|
96 |
|
|
t.o.ctrlo.hold := '1';
|
97 |
|
|
else
|
98 |
|
|
if i.fromCP_last = '0' then
|
99 |
|
|
v.state := armcmd_cl_process;
|
100 |
|
|
else
|
101 |
|
|
if i.ctrli.insn.insn(ADE_LDC_STC_WB_C) = '0' then
|
102 |
|
|
t.o.ctrlo.nextinsn := '1';
|
103 |
|
|
else
|
104 |
|
|
v.state := armcmd_cl_finish;
|
105 |
|
|
end if;
|
106 |
|
|
end if;
|
107 |
|
|
end if;
|
108 |
|
|
|
109 |
|
|
when others =>
|
110 |
|
|
|
111 |
|
|
if i.ctrli.cnt = ACM_CNT_ONE then
|
112 |
|
|
t.ctrlmemo.rsop_buf1_src := apc_bufsrc_alures; -- save <addr> for writeback
|
113 |
|
|
end if;
|
114 |
|
|
|
115 |
|
|
case r.state is
|
116 |
|
|
when armcmd_cl_process =>
|
117 |
|
|
|
118 |
|
|
-- [frame: ctrli.cnt!=0] address inc
|
119 |
|
|
--
|
120 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
121 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
122 |
|
|
-- | | (lastalu)op1 | | |
|
123 |
|
|
-- | |(alu)>[buf]| \ | | |
|
124 |
|
|
-- | (regread) | | +(aluop) | +(trans) | +>(dcache)+-++ (write)
|
125 |
|
|
-- | | | / | | | | | | | ||
|
126 |
|
|
-- | | inc--op2 | | | | | | | |+->[copro]
|
127 |
|
|
-- --+-----------+-----------+-----+-----+--+---+----+-+---------+-+--------+
|
128 |
|
|
-- | | | | |
|
129 |
|
|
-- pctrl.data1 (as address) : +--------+ +------+ |
|
130 |
|
|
-- cyceven:pctrl.me.param: o-------------------------------+ |
|
131 |
|
|
-- pctrl.wr.rd(<nxtreg>):o-------------------------------------+
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_alures; -- route <lastalu> to exestg op1
|
135 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_none; -- route 4 to exestg op2
|
136 |
|
|
t.ctrlmemo.data2 := LIN_FOUR; -- 4
|
137 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- save aluresult (address in(de)cerement) as MESTG_address
|
138 |
|
|
t.ctrlmemo.rd_src := acm_rdlocal; -- write to rnext (MESTG result)
|
139 |
|
|
|
140 |
|
|
t.ctrlmemo.meop_param.read := '1'; -- MESTG: dcache inputs (readdata)
|
141 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
142 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
143 |
|
|
|
144 |
|
|
if i.fromCP_last = '1' then
|
145 |
|
|
if i.ctrli.insn.insn(ADE_LDC_STC_WB_C) = '0' then
|
146 |
|
|
t.o.ctrlo.nextinsn := '1';
|
147 |
|
|
else
|
148 |
|
|
v.state := armcmd_cl_finish;
|
149 |
|
|
end if;
|
150 |
|
|
end if;
|
151 |
|
|
|
152 |
|
|
when armcmd_cl_finish =>
|
153 |
|
|
|
154 |
|
|
t.o.ctrlo.nextinsn := '1';
|
155 |
|
|
|
156 |
|
|
-- [frame:] update baseregister
|
157 |
|
|
--
|
158 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
159 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+-----------
|
160 |
|
|
-- | | (lastalu)-+ | | |
|
161 |
|
|
-- | | | \ | | |
|
162 |
|
|
-- | | | +(aluop) | | (dcache) | +>(write)
|
163 |
|
|
-- | | | / | | | | |
|
164 |
|
|
-- | | (0) -+ | | | | |
|
165 |
|
|
-- --+-----------+-----------+-----+-----+-----------+-----------+-+---------
|
166 |
|
|
-- | |
|
167 |
|
|
-- pctrl.data1 (as rddata): +-------------------------------+
|
168 |
|
|
-- pctrl.wr.rd (<rn>): o----------------------------------------+
|
169 |
|
|
|
170 |
|
|
if i.ctrli.cnt = ACM_CNT_ONE then
|
171 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_alures; -- route <lastalu> to exestg op1
|
172 |
|
|
else
|
173 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_buf; -- route <lastalu> to exestg op1
|
174 |
|
|
end if;
|
175 |
|
|
|
176 |
|
|
t.ctrlmemo.data2 := (others => '0'); -- imm 0
|
177 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_none; -- route 0 to exestg op2
|
178 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- save aluresult as WRSTG_data
|
179 |
|
|
t.ctrlmemo.rd_src := acm_rdrrn; -- <rn>
|
180 |
|
|
|
181 |
|
|
when others =>
|
182 |
|
|
end case;
|
183 |
|
|
|
184 |
|
|
end case;
|
185 |
|
|
|
186 |
|
|
-- reset
|
187 |
|
|
if ( rst = '0' ) then
|
188 |
|
|
end if;
|
189 |
|
|
|
190 |
|
|
o <= t.o;
|
191 |
|
|
|
192 |
|
|
-- pragma translate_off
|
193 |
|
|
vdbg := rdbg;
|
194 |
|
|
vdbg.dbg := t;
|
195 |
|
|
cdbg <= vdbg;
|
196 |
|
|
-- pragma translate_on
|
197 |
|
|
|
198 |
|
|
end process p0;
|
199 |
|
|
|
200 |
|
|
pregs : process (clk, c)
|
201 |
|
|
begin
|
202 |
|
|
if rising_edge(clk) then
|
203 |
|
|
r <= c;
|
204 |
|
|
-- pragma translate_off
|
205 |
|
|
rdbg <= cdbg;
|
206 |
|
|
-- pragma translate_on
|
207 |
|
|
end if;
|
208 |
|
|
end process;
|
209 |
|
|
|
210 |
|
|
end rtl;
|