1 |
2 |
tarookumic |
-- $(lic)
|
2 |
|
|
-- $(help_generic)
|
3 |
|
|
-- $(help_local)
|
4 |
|
|
|
5 |
|
|
library ieee;
|
6 |
|
|
use ieee.std_logic_1164.all;
|
7 |
|
|
use work.memdef.all;
|
8 |
|
|
use work.armdecode.all;
|
9 |
|
|
use work.armcmd.all;
|
10 |
|
|
use work.armpctrl.all;
|
11 |
|
|
use work.armpmodel.all;
|
12 |
|
|
use work.armcmd_comp.all;
|
13 |
|
|
|
14 |
|
|
entity armcmd_sw is
|
15 |
|
|
port (
|
16 |
|
|
rst : in std_logic;
|
17 |
|
|
clk : in std_logic;
|
18 |
|
|
i : in armcmd_sw_typ_in;
|
19 |
|
|
o : out armcmd_sw_typ_out
|
20 |
|
|
);
|
21 |
|
|
end armcmd_sw;
|
22 |
|
|
|
23 |
|
|
architecture rtl of armcmd_sw is
|
24 |
|
|
|
25 |
|
|
type armcmd_sw_tmp_type is record
|
26 |
|
|
o : armcmd_sw_typ_out;
|
27 |
|
|
off : std_logic_vector(23 downto 0);
|
28 |
|
|
ctrlmemo : acm_ctrlmemout;
|
29 |
|
|
end record;
|
30 |
|
|
type armcmd_sw_reg_type is record
|
31 |
|
|
dummy : std_logic;
|
32 |
|
|
end record;
|
33 |
|
|
type armcmd_sw_dbg_type is record
|
34 |
|
|
dummy : std_logic;
|
35 |
|
|
-- pragma translate_off
|
36 |
|
|
dbg : armcmd_sw_tmp_type;
|
37 |
|
|
-- pragma translate_on
|
38 |
|
|
end record;
|
39 |
|
|
signal r, c : armcmd_sw_reg_type;
|
40 |
|
|
signal rdbg, cdbg : armcmd_sw_dbg_type;
|
41 |
|
|
|
42 |
|
|
begin
|
43 |
|
|
|
44 |
|
|
p0: process (clk, rst, r, i )
|
45 |
|
|
variable v : armcmd_sw_reg_type;
|
46 |
|
|
variable t : armcmd_sw_tmp_type;
|
47 |
|
|
variable vdbg : armcmd_sw_dbg_type;
|
48 |
|
|
begin
|
49 |
|
|
|
50 |
|
|
-- $(init(t:armcmd_sw_tmp_type))
|
51 |
|
|
|
52 |
|
|
v := r;
|
53 |
|
|
t.o.ctrlo := i.ctrli.ctrlo;
|
54 |
|
|
t.o.ctrlo.nextinsn := '0';
|
55 |
|
|
t.ctrlmemo := i.ctrlmemo;
|
56 |
|
|
|
57 |
|
|
t.ctrlmemo.meop_param.writedata := '0'; -- MESTG: dcache inputs (wr data)
|
58 |
|
|
t.ctrlmemo.meop_param.addrin := '0'; -- MESTG: dcache inputs (tag cmp)
|
59 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs (readdata)
|
60 |
|
|
t.ctrlmemo.meop_param.signed := '0'; -- MESTG: dcache inputs (readdata)
|
61 |
|
|
t.ctrlmemo.meop_param.lock := '0'; -- MESTG: dcache inputs (atomic)
|
62 |
|
|
t.ctrlmemo.meop_enable := '0'; -- MESTG: dcache inputs
|
63 |
|
|
|
64 |
|
|
-- swpb cmd
|
65 |
|
|
if i.ctrli.insn.insn(ADE_SWPB_C) = '1' then
|
66 |
|
|
t.ctrlmemo.meop_param.size := lmd_byte;
|
67 |
|
|
else
|
68 |
|
|
t.ctrlmemo.meop_param.size := lmd_word;
|
69 |
|
|
end if;
|
70 |
|
|
|
71 |
|
|
-- swp{cond} <rd>,<rm>,[<rn>]
|
72 |
|
|
case i.ctrli.cnt is
|
73 |
|
|
when ACM_CNT_ZERO =>
|
74 |
|
|
|
75 |
|
|
-- [frame: ctrli.cnt = 1] load address calculation (rn)
|
76 |
|
|
--
|
77 |
|
|
-- RRSTG RSSTG EXSTG DMSTG MESTG WRSTG
|
78 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
79 |
|
|
-- <rn> ->+-----------+----------op1 | | |
|
80 |
|
|
-- | | | \->[buf] | | |
|
81 |
|
|
-- | (regread)| (noshift) | +---+ | +(trans) | +>(dcache)+-+>(write)
|
82 |
|
|
-- | | | | | | | | | | |
|
83 |
|
|
-- <rm> ->+-----------+->[buf] | | | | | | | | |
|
84 |
|
|
-- --+-----------+-----------+-----+-----+-+---+-----+-+---------+-+--------+
|
85 |
|
|
-- | | | | |
|
86 |
|
|
-- pctrl.data1 (as address) : +-------+ +-------+ |
|
87 |
|
|
-- pctrl.me.param: o------------------------------+ |
|
88 |
|
|
-- pctrl.wr.rd(<rd>):o------------------------------------------+
|
89 |
|
|
|
90 |
|
|
t.ctrlmemo.r1_src := acm_rrn; -- fetch <rn> (addrbase)
|
91 |
|
|
t.ctrlmemo.r2_src := acm_rrm; -- fetch <rm> (swapreg)
|
92 |
|
|
t.ctrlmemo.data2 := (others => '0'); -- <0>
|
93 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_through; -- route <rn> to exestg op1
|
94 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_through; -- route <offset12> to exestg op2
|
95 |
|
|
t.ctrlmemo.rd_src := acm_rdrrd;
|
96 |
|
|
t.ctrlmemo.rsop_buf2_src := apc_bufsrc_through;
|
97 |
|
|
t.ctrlmemo.exop_buf_src := apc_exbufsrc_op1;
|
98 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_none; -- route <rn> to pctrl.data1 (waddr)
|
99 |
|
|
|
100 |
|
|
t.ctrlmemo.meop_param.read := '1'; -- MESTG: dcache inputs (readdata)
|
101 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
102 |
|
|
t.ctrlmemo.meop_param.lock := '1'; -- MESTG: dcache inputs (atomic)
|
103 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
104 |
|
|
|
105 |
|
|
when ACM_CNT_ONE =>
|
106 |
|
|
|
107 |
|
|
-- [frame: ctrli.cnt = 2] store address calculation (rn) (will not block)
|
108 |
|
|
-- lock barier
|
109 |
|
|
-- >|<
|
110 |
|
|
-- RRSTG | RSSTG EXSTG DMSTG MESTG WRSTG
|
111 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
112 |
|
|
-- | | | | |
|
113 |
|
|
-- | | | | | |
|
114 |
|
|
-- | (regread)| (noshift) | (aluop) | +(trans) | +>(dcache)| (write)
|
115 |
|
|
-- | | | [buf] | | | | | |
|
116 |
|
|
-- | | | | | | | | | |
|
117 |
|
|
-- --+-----------+-----------+-----+-----+-+---+-----+-+---------+----------+
|
118 |
|
|
-- | | | |
|
119 |
|
|
-- pctrl.data1 (as address) : +-------+ +-------+
|
120 |
|
|
-- cyc0:pctrl.me.param: o------------------------------+
|
121 |
|
|
|
122 |
|
|
t.ctrlmemo.r1_src := acm_none; -- fetch <rn> (addrbase)
|
123 |
|
|
t.ctrlmemo.r2_src := acm_none; -- fetch <rn> (addrbase)
|
124 |
|
|
t.ctrlmemo.rd_src := acm_rdnone;
|
125 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_buf; -- route <offset12> to exestg op2
|
126 |
|
|
|
127 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs (readdata)
|
128 |
|
|
t.ctrlmemo.meop_param.addrin := '1'; -- MESTG: dcache inputs (tag cmp)
|
129 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
130 |
|
|
|
131 |
|
|
when others =>
|
132 |
|
|
|
133 |
|
|
-- [ctrli.cnt = 1:] send writedata (will not block )
|
134 |
|
|
--
|
135 |
|
|
-- lock barier
|
136 |
|
|
-- >|<
|
137 |
|
|
-- RRSTG | RSSTG EXSTG DMSTG MESTG WRSTG
|
138 |
|
|
-- --+-----------+-----------+-----------+-----------+-----------+----------+
|
139 |
|
|
-- | + <0>-op1 | | |
|
140 |
|
|
-- | | | \ | | |
|
141 |
|
|
-- | (regread)| (noshift) | +(aluop) | (trans) | +>(dcache)| (write)
|
142 |
|
|
-- | | | / | | | | /\ |
|
143 |
|
|
-- | | [buf]-op2 | | | | | |
|
144 |
|
|
-- --+-----------+-----------+-----+-----+-----------+-+---+-----+----------+
|
145 |
|
|
-- | | |
|
146 |
|
|
-- (as memwritedata) pctrl.data1: +-------------------+ |
|
147 |
|
|
-- cyc1:pctrl.me.param: o----------------------+ |
|
148 |
|
|
-- cyc0:pctrl.data1(addr): o--------------------------+
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
t.ctrlmemo.r1_src := acm_none;
|
152 |
|
|
t.ctrlmemo.r2_src := acm_none;
|
153 |
|
|
t.ctrlmemo.data2 := (others => '0');
|
154 |
|
|
t.ctrlmemo.rsop_op1_src := apc_opsrc_none;
|
155 |
|
|
t.ctrlmemo.rsop_op2_src := apc_opsrc_buf;
|
156 |
|
|
t.ctrlmemo.rd_src := acm_rdnone;
|
157 |
|
|
t.ctrlmemo.exop_data_src := apc_datasrc_aluout; -- route <offset12> to exestg op2
|
158 |
|
|
|
159 |
|
|
t.ctrlmemo.meop_param.read := '0'; -- MESTG: dcache inputs
|
160 |
|
|
t.ctrlmemo.meop_param.writedata := '1'; -- MESTG: dcache inputs (wr data)
|
161 |
|
|
t.ctrlmemo.meop_enable := '1'; -- MESTG: dcache inputs
|
162 |
|
|
|
163 |
|
|
t.o.ctrlo.nextinsn := '1';
|
164 |
|
|
|
165 |
|
|
end case;
|
166 |
|
|
|
167 |
|
|
t.o.ctrlmemo := t.ctrlmemo;
|
168 |
|
|
|
169 |
|
|
-- reset
|
170 |
|
|
if ( rst = '0' ) then
|
171 |
|
|
end if;
|
172 |
|
|
|
173 |
|
|
c <= v;
|
174 |
|
|
|
175 |
|
|
o <= t.o;
|
176 |
|
|
|
177 |
|
|
-- pragma translate_off
|
178 |
|
|
vdbg := rdbg;
|
179 |
|
|
vdbg.dbg := t;
|
180 |
|
|
cdbg <= vdbg;
|
181 |
|
|
-- pragma translate_on
|
182 |
|
|
|
183 |
|
|
end process p0;
|
184 |
|
|
|
185 |
|
|
pregs : process (clk, c)
|
186 |
|
|
begin
|
187 |
|
|
if rising_edge(clk) then
|
188 |
|
|
r <= c;
|
189 |
|
|
-- pragma translate_off
|
190 |
|
|
rdbg <= cdbg;
|
191 |
|
|
-- pragma translate_on
|
192 |
|
|
end if;
|
193 |
|
|
end process;
|
194 |
|
|
|
195 |
|
|
end rtl;
|