1 -- `Deep Thought', a softcore CPU implemented on a FPGA
3 -- Copyright (C) 2010 Markus Hofstaetter <markus.manrow@gmx.at>
4 -- Copyright (C) 2010 Martin Perner <e0725782@student.tuwien.ac.at>
5 -- Copyright (C) 2010 Stefan Rebernig <stefan.rebernig@gmail.com>
6 -- Copyright (C) 2010 Manfred Schwarz <e0725898@student.tuwien.ac.at>
7 -- Copyright (C) 2010 Bernhard Urban <lewurm@gmail.com>
9 -- This program is free software: you can redistribute it and/or modify
10 -- it under the terms of the GNU General Public License as published by
11 -- the Free Software Foundation, either version 3 of the License, or
12 -- (at your option) any later version.
14 -- This program is distributed in the hope that it will be useful,
15 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 -- GNU General Public License for more details.
19 -- You should have received a copy of the GNU General Public License
20 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
24 use IEEE.std_logic_1164.all;
25 use IEEE.numeric_std.all;
29 architecture behaviour of rom is
31 signal vsim_bug : std_logic_vector(31 downto 0);
36 if rising_edge(clk) then
37 -- data_out <= ram(to_integer(UNSIGNED(rd_addr)));
40 --case rrrr_addr(10 downto 0) is
41 case vsim_bug(6 downto 0) is
43 -- when "00000000000" => data_out <= "11101101000000000000000000000000"; --
44 -- when "00000000001" => data_out <= "11101101001000000000000000000000"; --
45 -- when "00000000010" => data_out <= "11100111101000000000000000000000"; --
47 -- when "00000000011" => data_out <= "11100001000000000000000000100001"; --
48 -- when "00000000100" => data_out <= "11101100100000000000001100000000"; --
49 -- when "00000000101" => data_out <= "00001011011111111111111010000011"; --
51 -- when "00000000110" => data_out <= "11101101000000000000000000001000"; --
52 -- when "00000000111" => data_out <= "11100111100000000000000000001111"; --
53 -- when "00000001000" => data_out <= "11100111100000000000000000010011"; -- --
56 -- when "00000001001" => data_out <= x"ed080048"; --x"ed080048"; --
57 -- when "00000001010" => data_out <= x"ed500080"; --
58 -- when "00000001011" => data_out <= x"fd500002"; --
59 -- when "00000001100" => data_out <= x"eb000107";
60 -- when "00000001101" => data_out <= "11101011000000000000011010000010"; --"11101011000000000000000000000010";
62 -- when "00000001110" => data_out <= x"e5088800";
63 -- when "00000001111" => data_out <= x"e0150800";
64 -- when "00000010000" => data_out <= x"e7010000";
65 -- when "00000010001" => data_out <= x"ec800000";
66 -- when "00000010010" => data_out <= x"0b000008";
67 -- when "00000010011" => data_out <= x"e1910020";
68 -- when "00000010100" => data_out <= x"eb7ffe07";
69 -- when "00000010101" => data_out <= x"e7197ffc";
70 -- when "00000010110" => data_out <= x"e0018000";
72 -- when "00000010111" => data_out <= x"e1110020";
73 -- when "00000011000" => data_out <= x"e7810000";
74 -- when "00000011001" => data_out <= x"eb00000a";
77 -- when "00000011010" => data_out <= x"ed290080";
78 -- when "00000011011" => data_out <= x"e1080000";
80 -- when "00000011100" => data_out <= x"e78a8000";
82 -- when "00000011101" => data_out <= x"ed510058";
83 -- when "00000011110" => data_out <= x"e7850000";
87 --1;00000000;ed010058;ldi r0, 0x200B;;
88 --1;00000004;ed090060;ldi r1, 0x200C;;
89 --1;00000008;ed110080;ldi r2, 0x2010;;
90 --1;0000000c;e7188000;ldw r3, 0(r1);;
91 --1;00000010;ec1a0000;cmp r3, r4;;
92 --1;00000014;1b7ffd81;breq 0;;
93 --1;00000018;e7980000;stw r3, 0(r0);;
94 --1;0000001c;e7990000;stw r3, 0(r2);;
95 --1;00000020;e1218000;addi r4, r3, 0;;
96 --1;00000024;eb7ffb81;br 0;;
98 -- when "0000000" => data_out <= x"ed010058";
99 -- when "0000001" => data_out <= x"ed090060";
100 -- when "0000010" => data_out <= x"ed110080"; --x"e7188000"; f
101 -- when "0000011" => data_out <= x"e7188000"; --x"ec1a0000";
102 -- when "0000100" => data_out <= x"ec1a0000";
103 -- when "0000101" => data_out <= x"1b7ffe01";
104 -- when "0000110" => data_out <= x"e7990000"; -- f
105 -- when "0000111" => data_out <= x"e7980000";
106 -- when "0001000" => data_out <= x"e1218000";
107 -- when "0001001" => data_out <= x"eb7ffb81";
109 --1;00000000;ed010058;ldi r0, 0x200B;;;
110 --1;00000004;ed090060;ldi r1, 0x200C;;;
111 --1;00000008;ed110080;ldi r2, 0x2010;;;
112 --1;0000000c;ed390078;ldi r7, 0x200F;;;
113 --1;00000010;ed480012;ldih r9, 0x0002;;;
114 --1;00000014;e7438000;ldw r8, 0(r7);;;
115 --1;00000018;e254c000;and r10, r9, r8;;;
116 --1;0000001c;07188000;ldwnz r3, 0(r1);;;
117 --1;00000020;07980000;stwnz r3, 0(r0);;;
118 --1;00000024;07990000;stwnz r3, 0(r2);;;
119 --1;00000028;eb7ffb01;br 0;;;
123 -- when "0000000" => data_out <= x"ed010058";
124 -- when "0000001" => data_out <= x"ed090060";
125 -- when "0000010" => data_out <= x"ed110080"; --x"e7188000"; f
126 -- when "0000011" => data_out <= x"ed390000"; --x"ec1a0000";
127 -- when "0000100" => data_out <= x"ed480012";
128 -- when "0000101" => data_out <= x"e7438000";
129 -- when "0000110" => data_out <= x"e254c000"; -- f
130 -- when "0000111" => data_out <= x"07188000";
131 -- when "0001000" => data_out <= x"07980000";
132 -- when "0001001" => data_out <= x"07990000";
133 -- when "0001010" => data_out <= x"eb7ffb81";
135 -------------------------------------------
137 -- when "00000000000" => data_out <= x"ed000000";
138 -- when "00000000001" => data_out <= x"ed080008";
139 -- when "00000000010" => data_out <= x"e9880000"; --x"e7188000"; f
140 -- when "00000000011" => data_out <= x"e5088400"; --x"ec1a0000";
141 -- when "00000000100" => data_out <= x"e9880001";
142 -- when "00000000101" => data_out <= x"e7180000";
143 -- when "00000000110" => data_out <= x"e9200001"; -- f
144 -- when "00000000111" => data_out <= x"e7a00004";
145 -- when "00000001000" => data_out <= x"e7280004";
146 -- -- when "00000001001" => data_out <= x"eb7ffb81";
147 when "0000000" => data_out <= x"eb000183"; -- br+ main
148 when "0000001" => data_out <= x"eb000103"; -- br+ main
149 when "0000010" => data_out <= x"eb000008"; -- ret
150 when "0000011" => data_out <= x"ed510000"; -- ldi r10, UART_BASE@lo
151 when "0000100" => data_out <= x"ed500002"; -- ldih r10, UART_BASE@hi
152 when "0000101" => data_out <= x"ed590180"; -- ldi r11, PBASE@lo
153 when "0000110" => data_out <= x"ed580002"; -- ldih r11, PBASE@hi
154 when "0000111" => data_out <= x"eb000985"; -- call recv_byte
155 when "0001000" => data_out <= x"e4088800"; -- xor r1, r1, r1
156 when "0001001" => data_out <= x"ec800240"; -- cmpi r0, 0x48
157 when "0001010" => data_out <= x"1b001703"; -- breq+ bt_H
158 when "0001011" => data_out <= x"eb7ffe01"; -- br poll
159 when "0001100" => data_out <= x"e71d0000"; -- ldw r3, UART_STATUS(r10)
160 when "0001101" => data_out <= x"e2980008"; -- andx r3, UART_TRANS_EMPTY
161 when "0001110" => data_out <= x"0b7fff03"; -- brnz+ send_byte
162 when "0001111" => data_out <= x"e78d0008"; -- stw r1, UART_TRANS(r10)
163 when "0010000" => data_out <= x"eb000008"; -- ret
164 when "0010001" => data_out <= x"e5008008"; -- lrs r0, r1, 0
165 when "0010010" => data_out <= x"eb7ffd05"; -- call send_byte
166 when "0010011" => data_out <= x"e500a008"; -- lrs r0, r1, 8
167 when "0010100" => data_out <= x"eb7ffc05"; -- call send_byte
168 when "0010101" => data_out <= x"e500c008"; -- lrs r0, r1, 16
169 when "0010110" => data_out <= x"eb7ffb05"; -- call send_byte
170 when "0010111" => data_out <= x"e500e008"; -- lrs r0, r1, 24
171 when "0011000" => data_out <= x"eb7ffa05"; -- call send_byte
172 when "0011001" => data_out <= x"eb000008"; -- ret
173 when "0011010" => data_out <= x"e71d0000"; -- ldw r3, UART_STATUS(r10)
174 when "0011011" => data_out <= x"e2980010"; -- andx r3, UART_RECV_NEW
175 when "0011100" => data_out <= x"1b7fff03"; -- brzs+ recv_byte
176 when "0011101" => data_out <= x"e4000000"; -- xor r0, r0, r0
177 when "0011110" => data_out <= x"e705000c"; -- ldw r0, UART_RECV(r10)
178 when "0011111" => data_out <= x"eb000008"; -- ret
179 when "0100000" => data_out <= x"e4088800"; -- xor r1, r1, r1
180 when "0100001" => data_out <= x"eb7ffc85"; -- call recv_byte
181 when "0100010" => data_out <= x"e3080800"; -- or r1, r0, r1
182 when "0100011" => data_out <= x"eb7ffb85"; -- call recv_byte
183 when "0100100" => data_out <= x"e508a000"; -- lls r1, r1, 8
184 when "0100101" => data_out <= x"e3080800"; -- or r1, r0, r1
185 when "0100110" => data_out <= x"eb7ffa05"; -- call recv_byte
186 when "0100111" => data_out <= x"e508a000"; -- lls r1, r1, 8
187 when "0101000" => data_out <= x"e3080800"; -- or r1, r0, r1
188 when "0101001" => data_out <= x"eb7ff885"; -- call recv_byte
189 when "0101010" => data_out <= x"e508a000"; -- lls r1, r1, 8
190 when "0101011" => data_out <= x"e3000800"; -- or r0, r0, r1
191 when "0101100" => data_out <= x"e4088800"; -- xor r1, r1, r1
192 when "0101101" => data_out <= x"eb000008"; -- ret
193 when "0101110" => data_out <= x"eb7ff605"; -- call recv_byte
194 when "0101111" => data_out <= x"e4088800"; -- xor r1, r1, r1
195 when "0110000" => data_out <= x"ec8002b8"; -- cmpi r0, 0x57
196 when "0110001" => data_out <= x"1b000501"; -- breq- bt_W
197 when "0110010" => data_out <= x"ec800288"; -- cmpi r0, 0x51
198 when "0110011" => data_out <= x"1b000881"; -- breq- bt_Q
199 when "0110100" => data_out <= x"ec8002a0"; -- cmpi r0, 0x54
200 when "0110101" => data_out <= x"1b000c01"; -- breq- bt_T
201 when "0110110" => data_out <= x"ec800250"; -- cmpi r0, 0x4a
202 when "0110111" => data_out <= x"1b000e81"; -- breq- bt_J
203 when "0111000" => data_out <= x"ed080278"; -- ldi r1, 0x4f
204 when "0111001" => data_out <= x"eb7fe985"; -- call send_byte
205 when "0111010" => data_out <= x"eb7ffa01"; -- br bootrom
206 when "0111011" => data_out <= x"ed0802b8"; -- ldi r1, 0x57
207 when "0111100" => data_out <= x"eb7fe805"; -- call send_byte
208 when "0111101" => data_out <= x"eb7ff185"; -- call recv_word
209 when "0111110" => data_out <= x"e7858004"; -- stw r0, PADDR(r11)
210 when "0111111" => data_out <= x"eb7ff085"; -- call recv_word
211 when "1000000" => data_out <= x"e7858008"; -- stw r0, PDATA(r11)
212 when "1000001" => data_out <= x"ed080220"; -- ldi r1, 0x44
213 when "1000010" => data_out <= x"eb7fe505"; -- call send_byte
214 when "1000011" => data_out <= x"eb7ff581"; -- br bootrom
215 when "1000100" => data_out <= x"ed080288"; -- ldi r1, 0x51
216 when "1000101" => data_out <= x"eb7fe385"; -- call send_byte
217 when "1000110" => data_out <= x"eb7fed05"; -- call recv_word
218 when "1000111" => data_out <= x"e1300000"; -- addi r6, r0, 0
219 when "1001000" => data_out <= x"eb7fec05"; -- call recv_word
220 when "1001001" => data_out <= x"e7830000"; -- stw r0, 0(r6)
221 when "1001010" => data_out <= x"ed080208"; -- ldi r1, 0x41
222 when "1001011" => data_out <= x"eb7fe085"; -- call send_byte
223 when "1001100" => data_out <= x"eb7ff101"; -- br bootrom
224 when "1001101" => data_out <= x"eb7fe985"; -- call recv_word
225 when "1001110" => data_out <= x"e1100000"; -- mov r2, r0
226 when "1001111" => data_out <= x"ed080238"; -- ldi r1, 0x47
227 when "1010000" => data_out <= x"eb7fde05"; -- call send_byte
228 when "1010001" => data_out <= x"e7090000"; -- ldw r1, 0(r2)
229 when "1010010" => data_out <= x"eb7fdf85"; -- call send_word
230 when "1010011" => data_out <= x"eb7fed81"; -- br bootrom
231 -- just nop until rom end!
232 when others => data_out <= x"fd000000";
237 vsim_bug(6 downto 0) <= rd_addr;
238 vsim_bug(31 downto 7) <= (others => '0');
239 end architecture behaviour;