1 |
2 |
steckol |
library ieee;
|
2 |
|
|
use ieee.std_logic_1164.all;
|
3 |
|
|
use ieee.std_logic_arith.all;
|
4 |
|
|
|
5 |
|
|
entity vliwProc_loadStore is
|
6 |
|
|
port (
|
7 |
|
|
addr : out std_logic_vector(7 downto 0);
|
8 |
|
|
dataOut : out std_logic_vector(7 downto 0);
|
9 |
|
|
|
10 |
|
|
ioWr_n : out std_logic;
|
11 |
|
|
ioEn_n : out std_logic;
|
12 |
|
|
dataWr_n : out std_logic;
|
13 |
|
|
dataEn_n : out std_logic;
|
14 |
|
|
|
15 |
|
|
dataIn : in std_logic_vector(7 downto 0);
|
16 |
|
|
ioIn : in std_logic_vector(7 downto 0);
|
17 |
|
|
|
18 |
|
|
opCode : in std_logic;
|
19 |
|
|
as : in std_logic_vector(1 downto 0);
|
20 |
|
|
dstReg : in std_logic_vector(2 downto 0);
|
21 |
|
|
src : in std_logic_vector(7 downto 0);
|
22 |
|
|
cs_n : in std_logic;
|
23 |
|
|
|
24 |
|
|
state : in std_logic_vector(3 downto 0);
|
25 |
|
|
|
26 |
|
|
regOut : out std_logic_vector(7 downto 0);
|
27 |
|
|
|
28 |
|
|
reg0 : in std_logic_vector(7 downto 0);
|
29 |
|
|
reg1 : in std_logic_vector(7 downto 0);
|
30 |
|
|
reg2 : in std_logic_vector(7 downto 0);
|
31 |
|
|
reg3 : in std_logic_vector(7 downto 0);
|
32 |
|
|
reg4 : in std_logic_vector(7 downto 0);
|
33 |
|
|
reg5 : in std_logic_vector(7 downto 0);
|
34 |
|
|
reg6 : in std_logic_vector(7 downto 0);
|
35 |
|
|
reg7 : in std_logic_vector(7 downto 0);
|
36 |
|
|
|
37 |
|
|
regSel : out std_logic_vector(2 downto 0);
|
38 |
|
|
regEn_n : out std_logic;
|
39 |
|
|
|
40 |
|
|
rst_n : in std_logic
|
41 |
|
|
);
|
42 |
|
|
end vliwProc_loadStore;
|
43 |
|
|
|
44 |
|
|
architecture behavior of vliwProc_loadStore is
|
45 |
|
|
|
46 |
|
|
signal cntClk_s : std_logic;
|
47 |
|
|
|
48 |
|
|
signal state23_s : std_logic;
|
49 |
|
|
|
50 |
|
|
signal as_s : std_logic_vector(1 downto 0);
|
51 |
|
|
signal opcode_s : std_logic;
|
52 |
|
|
signal dstReg_s : std_logic_vector(2 downto 0);
|
53 |
|
|
signal src_s : std_logic_vector(7 downto 0);
|
54 |
|
|
|
55 |
|
|
signal enable_s : std_logic;
|
56 |
|
|
signal enable_evt_s : std_logic;
|
57 |
|
|
|
58 |
|
|
begin
|
59 |
|
|
|
60 |
|
|
reg_update: process(rst_n, cs_n)
|
61 |
|
|
begin
|
62 |
|
|
if (rst_n = '0') then
|
63 |
|
|
as_s <= (others => '0');
|
64 |
|
|
opcode_s <= '0';
|
65 |
|
|
dstReg_s <= (others => '0');
|
66 |
|
|
src_s <= (others => '0');
|
67 |
|
|
else
|
68 |
|
|
if (cs_n'event and cs_n = '0') then
|
69 |
|
|
as_s <= as;
|
70 |
|
|
opcode_s <= opcode;
|
71 |
|
|
dstReg_s <= dstReg;
|
72 |
|
|
src_s <= src;
|
73 |
|
|
end if;
|
74 |
|
|
end if;
|
75 |
|
|
end process;
|
76 |
|
|
|
77 |
|
|
addr <= src_s when enable_s = '1' and as_s(0) = '0' else
|
78 |
|
|
reg0 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "000" else
|
79 |
|
|
reg1 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "001" else
|
80 |
|
|
reg2 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "010" else
|
81 |
|
|
reg3 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "011" else
|
82 |
|
|
reg4 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "100" else
|
83 |
|
|
reg5 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "101" else
|
84 |
|
|
reg6 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "110" else
|
85 |
|
|
reg7 when enable_s = '1' and as_s(0) = '1' and src_s(2 downto 0) = "111" else
|
86 |
|
|
(others => '0');
|
87 |
|
|
|
88 |
|
|
dataOut <= reg0 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "000" else
|
89 |
|
|
reg1 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "001" else
|
90 |
|
|
reg2 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "010" else
|
91 |
|
|
reg3 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "011" else
|
92 |
|
|
reg4 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "100" else
|
93 |
|
|
reg5 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "101" else
|
94 |
|
|
reg6 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "110" else
|
95 |
|
|
reg7 when enable_s = '1' and opCode_s = '1' and dstReg_s(2 downto 0) = "111" else
|
96 |
|
|
(others => '0');
|
97 |
|
|
|
98 |
|
|
cntClk_s <= '1' when state(0) = '1' or state(2) = '1' else
|
99 |
|
|
'0';
|
100 |
|
|
|
101 |
|
|
stateGen_proc : process(rst_n, cntClk_s)
|
102 |
|
|
begin
|
103 |
|
|
if (rst_n = '0') then
|
104 |
|
|
state23_s <= '1';
|
105 |
|
|
else
|
106 |
|
|
if (cntClk_s'event and cntClk_s = '1') then
|
107 |
|
|
state23_s <= not(state23_s);
|
108 |
|
|
end if;
|
109 |
|
|
end if;
|
110 |
|
|
end process;
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
-- enable_evt_s <= state(2) and not(stalled_n_s);
|
114 |
|
|
enable_evt_s <= state(2);
|
115 |
|
|
|
116 |
|
|
enable_proc : process(rst_n, enable_evt_s)
|
117 |
|
|
begin
|
118 |
|
|
if (rst_n = '0') then
|
119 |
|
|
enable_s <= '0';
|
120 |
|
|
else
|
121 |
|
|
if (enable_evt_s'event and enable_evt_s = '1') then
|
122 |
|
|
if (cs_n = '0') then
|
123 |
|
|
enable_s <= '1';
|
124 |
|
|
else
|
125 |
|
|
enable_s <= '0';
|
126 |
|
|
end if;
|
127 |
|
|
end if;
|
128 |
|
|
end if;
|
129 |
|
|
end process;
|
130 |
|
|
|
131 |
|
|
-- store operation
|
132 |
|
|
ioEn_n <= '0' when enable_s = '1' and as_s(1) = '1' and state23_s = '1' else
|
133 |
|
|
'1';
|
134 |
|
|
|
135 |
|
|
dataEn_n <= '0' when enable_s = '1' and as_s(1) = '0' and state23_s = '1' else
|
136 |
|
|
'1';
|
137 |
|
|
|
138 |
|
|
ioWr_n <= '0' when enable_s = '1' and opCode_s = '1' and as_s(1) = '1' else
|
139 |
|
|
'1';
|
140 |
|
|
dataWr_n <= '0' when enable_s = '1' and opCode_s = '1' and as_s(1) = '0' else
|
141 |
|
|
'1';
|
142 |
|
|
|
143 |
|
|
regSel <= dstReg_s when enable_s = '1' and opCode_s = '0' else
|
144 |
|
|
(others => '0');
|
145 |
|
|
regOut <= ioIn when enable_s = '1' and opCode_s = '0' and as_s(1) = '1' else
|
146 |
|
|
dataIn when enable_s = '1' and opCode_s = '0' and as_s(1) = '0' else
|
147 |
|
|
(others => '0');
|
148 |
|
|
regEn_n <= '0' when enable_s = '1' and opCode_s = '0' else
|
149 |
|
|
'1';
|
150 |
|
|
|
151 |
|
|
end behavior;
|