2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4 use ieee.math_real.all;
10 use work.wishbone_types.all;
13 -- Memory map. *** Keep include/microwatt_soc.h updated on changes ***
16 -- 0x00000000: Block RAM (MEMORY_SIZE) or DRAM depending on syscon
17 -- 0x40000000: DRAM (when present)
18 -- 0x80000000: Block RAM (aliased & repeated)
23 -- 0xc0003000: UART1 (if any)
24 -- 0xc0004000: XICS ICP
25 -- 0xc0005000: XICS ICS
26 -- 0xc0006000: SPI Flash controller
27 -- 0xc8nnnnnn: External IO bus
28 -- 0xf0000000: Flash "ROM" mapping
29 -- 0xff000000: DRAM init code (if any) or flash ROM (**)
32 -- 0xc8000000: LiteDRAM control (CSRs)
33 -- 0xc8020000: LiteEth CSRs (*)
34 -- 0xc8030000: LiteEth MMIO (*)
36 -- (*) LiteEth must be a single aligned 32KB block as the CSRs and MMIOs
37 -- are actually decoded as a single wishbone which LiteEth will
38 -- internally split based on bit 16.
40 -- (**) DRAM init code is currently special and goes to the external
41 -- IO bus, this will be fixed when it's moved out of litedram and
42 -- into the main SoC once we have a common "firmware".
51 MEMORY_SIZE : natural;
52 RAM_INIT_FILE : string;
55 HAS_FPU : boolean := true;
56 HAS_BTC : boolean := true;
57 DISABLE_FLATTEN_CORE : boolean := false;
58 HAS_DRAM : boolean := false;
59 DRAM_SIZE : integer := 0;
60 DRAM_INIT_SIZE : integer := 0;
61 HAS_SPI_FLASH : boolean := false;
62 SPI_FLASH_DLINES : positive := 1;
63 SPI_FLASH_OFFSET : integer := 0;
64 SPI_FLASH_DEF_CKDV : natural := 2;
65 SPI_FLASH_DEF_QUAD : boolean := false;
66 LOG_LENGTH : natural := 512;
67 HAS_LITEETH : boolean := false;
68 UART0_IS_16550 : boolean := true;
69 HAS_UART1 : boolean := false
73 system_clk : in std_ulogic;
75 -- "Large" (64-bit) DRAM wishbone
76 wb_dram_in : out wishbone_master_out;
77 wb_dram_out : in wishbone_slave_out := wishbone_slave_out_init;
79 -- "Small" (32-bit) external IO wishbone
80 wb_ext_io_in : out wb_io_master_out;
81 wb_ext_io_out : in wb_io_slave_out := wb_io_slave_out_init;
82 wb_ext_is_dram_csr : out std_ulogic;
83 wb_ext_is_dram_init : out std_ulogic;
84 wb_ext_is_eth : out std_ulogic;
86 -- External interrupts
87 ext_irq_eth : in std_ulogic := '0';
90 uart0_txd : out std_ulogic;
91 uart0_rxd : in std_ulogic := '0';
94 uart1_txd : out std_ulogic;
95 uart1_rxd : in std_ulogic := '0';
98 spi_flash_sck : out std_ulogic;
99 spi_flash_cs_n : out std_ulogic;
100 spi_flash_sdat_o : out std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0);
101 spi_flash_sdat_oe : out std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0);
102 spi_flash_sdat_i : in std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0) := (others => '1');
104 -- DRAM controller signals
105 alt_reset : in std_ulogic := '0'
109 architecture behaviour of soc is
111 -- Wishbone master signals:
112 signal wishbone_dcore_in : wishbone_slave_out;
113 signal wishbone_dcore_out : wishbone_master_out;
114 signal wishbone_icore_in : wishbone_slave_out;
115 signal wishbone_icore_out : wishbone_master_out;
116 signal wishbone_debug_in : wishbone_slave_out;
117 signal wishbone_debug_out : wishbone_master_out;
119 -- Arbiter array (ghdl doesnt' support assigning the array
120 -- elements in the entity instantiation)
121 constant NUM_WB_MASTERS : positive := 3;
122 signal wb_masters_out : wishbone_master_out_vector(0 to NUM_WB_MASTERS-1);
123 signal wb_masters_in : wishbone_slave_out_vector(0 to NUM_WB_MASTERS-1);
125 -- Wishbone master (output of arbiter):
126 signal wb_master_in : wishbone_slave_out;
127 signal wb_master_out : wishbone_master_out;
129 -- Main "IO" bus, from main slave decoder to the latch
130 signal wb_io_in : wishbone_master_out;
131 signal wb_io_out : wishbone_slave_out;
133 -- Secondary (smaller) IO bus after the IO bus latch
134 signal wb_sio_out : wb_io_master_out;
135 signal wb_sio_in : wb_io_slave_out;
138 signal dram_at_0 : std_ulogic;
139 signal do_core_reset : std_ulogic;
140 signal wb_syscon_in : wb_io_master_out;
141 signal wb_syscon_out : wb_io_slave_out;
144 signal wb_uart0_in : wb_io_master_out;
145 signal wb_uart0_out : wb_io_slave_out;
146 signal uart0_dat8 : std_ulogic_vector(7 downto 0);
147 signal uart0_irq : std_ulogic;
150 signal wb_uart1_in : wb_io_master_out;
151 signal wb_uart1_out : wb_io_slave_out;
152 signal uart1_dat8 : std_ulogic_vector(7 downto 0);
153 signal uart1_irq : std_ulogic;
155 -- SPI Flash controller signals:
156 signal wb_spiflash_in : wb_io_master_out;
157 signal wb_spiflash_out : wb_io_slave_out;
158 signal wb_spiflash_is_reg : std_ulogic;
159 signal wb_spiflash_is_map : std_ulogic;
162 signal wb_xics_icp_in : wb_io_master_out;
163 signal wb_xics_icp_out : wb_io_slave_out;
164 signal wb_xics_ics_in : wb_io_master_out;
165 signal wb_xics_ics_out : wb_io_slave_out;
166 signal int_level_in : std_ulogic_vector(15 downto 0);
167 signal ics_to_icp : ics_to_icp_t;
168 signal core_ext_irq : std_ulogic;
170 -- Main memory signals:
171 signal wb_bram_in : wishbone_master_out;
172 signal wb_bram_out : wishbone_slave_out;
174 -- DMI debug bus signals
175 signal dmi_addr : std_ulogic_vector(7 downto 0);
176 signal dmi_din : std_ulogic_vector(63 downto 0);
177 signal dmi_dout : std_ulogic_vector(63 downto 0);
178 signal dmi_req : std_ulogic;
179 signal dmi_wr : std_ulogic;
180 signal dmi_ack : std_ulogic;
182 -- Per slave DMI signals
183 signal dmi_wb_dout : std_ulogic_vector(63 downto 0);
184 signal dmi_wb_req : std_ulogic;
185 signal dmi_wb_ack : std_ulogic;
186 signal dmi_core_dout : std_ulogic_vector(63 downto 0);
187 signal dmi_core_req : std_ulogic;
188 signal dmi_core_ack : std_ulogic;
190 -- Delayed/latched resets and alt_reset
191 signal rst_core : std_ulogic := '1';
192 signal rst_uart : std_ulogic := '1';
193 signal rst_xics : std_ulogic := '1';
194 signal rst_spi : std_ulogic := '1';
195 signal rst_bram : std_ulogic := '1';
196 signal rst_dtm : std_ulogic := '1';
197 signal rst_wbar : std_ulogic := '1';
198 signal rst_wbdb : std_ulogic := '1';
199 signal alt_reset_d : std_ulogic;
202 type slave_io_type is (SLAVE_IO_SYSCON,
207 SLAVE_IO_SPI_FLASH_REG,
208 SLAVE_IO_SPI_FLASH_MAP,
211 signal slave_io_dbg : slave_io_type;
213 -- This is the component exported by the 16550 compatible
214 -- UART from FuseSoC.
216 component uart_top port (
217 wb_clk_i : in std_ulogic;
218 wb_rst_i : in std_ulogic;
219 wb_adr_i : in std_ulogic_vector(2 downto 0);
220 wb_dat_i : in std_ulogic_vector(7 downto 0);
221 wb_dat_o : out std_ulogic_vector(7 downto 0);
222 wb_we_i : in std_ulogic;
223 wb_stb_i : in std_ulogic;
224 wb_cyc_i : in std_ulogic;
225 wb_ack_o : out std_ulogic;
226 int_o : out std_ulogic;
227 stx_pad_o : out std_ulogic;
228 srx_pad_i : in std_ulogic;
229 rts_pad_o : out std_ulogic;
230 cts_pad_i : in std_ulogic;
231 dtr_pad_o : out std_ulogic;
232 dsr_pad_i : in std_ulogic;
233 ri_pad_i : in std_ulogic;
234 dcd_pad_i : in std_ulogic
239 resets: process(system_clk)
241 if rising_edge(system_clk) then
242 rst_core <= rst or do_core_reset;
250 alt_reset_d <= alt_reset;
255 processor: entity work.core
260 DISABLE_FLATTEN => DISABLE_FLATTEN_CORE,
261 ALT_RESET_ADDRESS => (23 downto 0 => '0', others => '1'),
262 LOG_LENGTH => LOG_LENGTH
267 alt_reset => alt_reset_d,
268 wishbone_insn_in => wishbone_icore_in,
269 wishbone_insn_out => wishbone_icore_out,
270 wishbone_data_in => wishbone_dcore_in,
271 wishbone_data_out => wishbone_dcore_out,
272 dmi_addr => dmi_addr(3 downto 0),
273 dmi_dout => dmi_core_dout,
276 dmi_ack => dmi_core_ack,
277 dmi_req => dmi_core_req,
278 ext_irq => core_ext_irq
281 -- Wishbone bus master arbiter & mux
282 wb_masters_out <= (0 => wishbone_dcore_out,
283 1 => wishbone_icore_out,
284 2 => wishbone_debug_out);
285 wishbone_dcore_in <= wb_masters_in(0);
286 wishbone_icore_in <= wb_masters_in(1);
287 wishbone_debug_in <= wb_masters_in(2);
288 wishbone_arbiter_0: entity work.wishbone_arbiter
290 NUM_MASTERS => NUM_WB_MASTERS
295 wb_masters_in => wb_masters_out,
296 wb_masters_out => wb_masters_in,
297 wb_slave_out => wb_master_out,
298 wb_slave_in => wb_master_in
301 -- Top level Wishbone slaves address decoder & mux
303 -- From CPU to BRAM, DRAM, IO, selected on top 3 bits and dram_at_0
310 slave_top_intercon: process(wb_master_out, wb_bram_out, wb_dram_out, wb_io_out, dram_at_0)
311 type slave_top_type is (SLAVE_TOP_BRAM,
314 variable slave_top : slave_top_type;
315 variable top_decode : std_ulogic_vector(3 downto 0);
317 -- Top-level address decoder
318 top_decode := wb_master_out.adr(31 downto 29) & dram_at_0;
319 slave_top := SLAVE_TOP_BRAM;
320 if std_match(top_decode, "0000") then
321 slave_top := SLAVE_TOP_BRAM;
322 elsif std_match(top_decode, "0001") then
323 slave_top := SLAVE_TOP_DRAM;
324 elsif std_match(top_decode, "01--") then
325 slave_top := SLAVE_TOP_DRAM;
326 elsif std_match(top_decode, "10--") then
327 slave_top := SLAVE_TOP_BRAM;
328 elsif std_match(top_decode, "11--") then
329 slave_top := SLAVE_TOP_IO;
332 -- Top level wishbone muxing.
333 wb_bram_in <= wb_master_out;
334 wb_bram_in.cyc <= '0';
335 wb_dram_in <= wb_master_out;
336 wb_dram_in.cyc <= '0';
337 wb_io_in <= wb_master_out;
340 when SLAVE_TOP_BRAM =>
341 wb_bram_in.cyc <= wb_master_out.cyc;
342 wb_master_in <= wb_bram_out;
343 when SLAVE_TOP_DRAM =>
345 wb_dram_in.cyc <= wb_master_out.cyc;
346 wb_master_in <= wb_dram_out;
348 wb_master_in.ack <= wb_master_out.cyc and wb_master_out.stb;
349 wb_master_in.dat <= (others => '1');
350 wb_master_in.stall <= '0';
353 wb_io_in.cyc <= wb_master_out.cyc;
354 wb_master_in <= wb_io_out;
357 end process slave_top_intercon;
359 -- IO wishbone slave 64->32 bits converter
361 -- For timing reasons, this adds a one cycle latch on the way both
362 -- in and out. This relaxes timing and routing pressure on the "main"
363 -- memory bus by moving all simple IOs to a slower 32-bit bus.
365 -- This implementation is rather dumb at the moment, no stash buffer,
366 -- so we stall whenever that latch is busy. This can be improved.
368 slave_io_latch: process(system_clk)
370 type state_t is (IDLE, WAIT_ACK_BOT, WAIT_ACK_TOP);
371 variable state : state_t;
374 variable has_top : boolean;
375 variable has_bot : boolean;
377 if rising_edge(system_clk) then
380 wb_io_out.ack <= '0';
381 wb_io_out.stall <= '0';
382 wb_sio_out.cyc <= '0';
383 wb_sio_out.stb <= '0';
389 -- Clear ACK in case it was set
390 wb_io_out.ack <= '0';
392 -- Do we have a cycle ?
393 if wb_io_in.cyc = '1' and wb_io_in.stb = '1' then
394 -- Stall master until we are done, we are't (yet) pipelining
395 -- this, it's all slow IOs.
396 wb_io_out.stall <= '1';
398 -- Start cycle downstream
399 wb_sio_out.cyc <= '1';
400 wb_sio_out.stb <= '1';
402 -- Copy write enable to IO out, copy address as well
403 wb_sio_out.we <= wb_io_in.we;
404 wb_sio_out.adr <= wb_io_in.adr(wb_sio_out.adr'left downto 3) & "000";
406 -- Do we have a top word and/or a bottom word ?
407 has_top := wb_io_in.sel(7 downto 4) /= "0000";
408 has_bot := wb_io_in.sel(3 downto 0) /= "0000";
410 -- If we have a bottom word, handle it first, otherwise
411 -- send the top word down. XXX Split the actual mux out
412 -- and only generate a control signal.
414 if wb_io_in.we = '1' then
415 wb_sio_out.dat <= wb_io_in.dat(31 downto 0);
417 wb_sio_out.sel <= wb_io_in.sel(3 downto 0);
420 state := WAIT_ACK_BOT;
422 if wb_io_in.we = '1' then
423 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
425 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
428 wb_sio_out.adr(2) <= '1';
431 state := WAIT_ACK_TOP;
435 -- If we aren't stalled by the device, clear stb
436 if wb_sio_in.stall = '0' then
437 wb_sio_out.stb <= '0';
441 if wb_sio_in.ack = '1' then
442 -- If it's a read, latch the data
443 if wb_sio_out.we = '0' then
444 wb_io_out.dat(31 downto 0) <= wb_sio_in.dat;
447 -- Do we have a "top" part as well ?
450 if wb_io_in.we = '1' then
451 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
453 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
455 -- Bump address and set STB
456 wb_sio_out.adr(2) <= '1';
457 wb_sio_out.stb <= '1';
460 state := WAIT_ACK_TOP;
462 -- We are done, ack up, clear cyc downstram
463 wb_sio_out.cyc <= '0';
465 -- And ack & unstall upstream
466 wb_io_out.ack <= '1';
467 wb_io_out.stall <= '0';
474 -- If we aren't stalled by the device, clear stb
475 if wb_sio_in.stall = '0' then
476 wb_sio_out.stb <= '0';
480 if wb_sio_in.ack = '1' then
481 -- If it's a read, latch the data
482 if wb_sio_out.we = '0' then
483 wb_io_out.dat(63 downto 32) <= wb_sio_in.dat;
486 -- We are done, ack up, clear cyc downstram
487 wb_sio_out.cyc <= '0';
489 -- And ack & unstall upstream
490 wb_io_out.ack <= '1';
491 wb_io_out.stall <= '0';
501 -- IO wishbone slave intercon.
503 slave_io_intercon: process(wb_sio_out, wb_syscon_out, wb_uart0_out, wb_uart1_out,
504 wb_ext_io_out, wb_xics_icp_out, wb_xics_ics_out,
506 variable slave_io : slave_io_type;
508 variable match : std_ulogic_vector(31 downto 12);
509 variable ext_valid : boolean;
512 -- Simple address decoder.
513 slave_io := SLAVE_IO_NONE;
514 match := "11" & wb_sio_out.adr(29 downto 12);
515 if std_match(match, x"FF---") and HAS_DRAM then
516 slave_io := SLAVE_IO_EXTERNAL;
517 elsif std_match(match, x"F----") then
518 slave_io := SLAVE_IO_SPI_FLASH_MAP;
519 elsif std_match(match, x"C0000") then
520 slave_io := SLAVE_IO_SYSCON;
521 elsif std_match(match, x"C0002") then
522 slave_io := SLAVE_IO_UART;
523 elsif std_match(match, x"C0003") then
524 slave_io := SLAVE_IO_UART1;
525 elsif std_match(match, x"C8---") then
526 slave_io := SLAVE_IO_EXTERNAL;
527 elsif std_match(match, x"C0004") then
528 slave_io := SLAVE_IO_ICP;
529 elsif std_match(match, x"C0005") then
530 slave_io := SLAVE_IO_ICS;
531 elsif std_match(match, x"C0006") then
532 slave_io := SLAVE_IO_SPI_FLASH_REG;
534 slave_io_dbg <= slave_io;
535 wb_uart0_in <= wb_sio_out;
536 wb_uart0_in.cyc <= '0';
537 wb_uart1_in <= wb_sio_out;
538 wb_uart1_in.cyc <= '0';
539 wb_spiflash_in <= wb_sio_out;
540 wb_spiflash_in.cyc <= '0';
541 wb_spiflash_is_reg <= '0';
542 wb_spiflash_is_map <= '0';
544 -- Only give xics 8 bits of wb addr (for now...)
545 wb_xics_icp_in <= wb_sio_out;
546 wb_xics_icp_in.adr <= (others => '0');
547 wb_xics_icp_in.adr(7 downto 0) <= wb_sio_out.adr(7 downto 0);
548 wb_xics_icp_in.cyc <= '0';
549 wb_xics_ics_in <= wb_sio_out;
550 wb_xics_ics_in.adr <= (others => '0');
551 wb_xics_ics_in.adr(11 downto 0) <= wb_sio_out.adr(11 downto 0);
552 wb_xics_ics_in.cyc <= '0';
554 wb_ext_io_in <= wb_sio_out;
555 wb_ext_io_in.cyc <= '0';
557 wb_syscon_in <= wb_sio_out;
558 wb_syscon_in.cyc <= '0';
560 wb_ext_is_dram_csr <= '0';
561 wb_ext_is_dram_init <= '0';
562 wb_ext_is_eth <= '0';
564 -- Default response, ack & return all 1's
565 wb_sio_in.dat <= (others => '1');
566 wb_sio_in.ack <= wb_sio_out.stb and wb_sio_out.cyc;
567 wb_sio_in.stall <= '0';
570 when SLAVE_IO_EXTERNAL =>
571 -- Ext IO "chip selects"
573 -- DRAM init is special at 0xFF* so we just test the top
574 -- bit. Everything else is at 0xC8* so we test only bits
578 if wb_sio_out.adr(29) = '1' and HAS_DRAM then -- DRAM init is special
579 wb_ext_is_dram_init <= '1';
581 elsif wb_sio_out.adr(23 downto 16) = x"00" and HAS_DRAM then
582 wb_ext_is_dram_csr <= '1';
584 elsif wb_sio_out.adr(23 downto 16) = x"02" and HAS_LITEETH then
585 wb_ext_is_eth <= '1';
587 elsif wb_sio_out.adr(23 downto 16) = x"03" and HAS_LITEETH then
588 wb_ext_is_eth <= '1';
592 wb_ext_io_in.cyc <= wb_sio_out.cyc;
593 wb_sio_in <= wb_ext_io_out;
596 when SLAVE_IO_SYSCON =>
597 wb_syscon_in.cyc <= wb_sio_out.cyc;
598 wb_sio_in <= wb_syscon_out;
599 when SLAVE_IO_UART =>
600 wb_uart0_in.cyc <= wb_sio_out.cyc;
601 wb_sio_in <= wb_uart0_out;
603 wb_xics_icp_in.cyc <= wb_sio_out.cyc;
604 wb_sio_in <= wb_xics_icp_out;
606 wb_xics_ics_in.cyc <= wb_sio_out.cyc;
607 wb_sio_in <= wb_xics_ics_out;
608 when SLAVE_IO_UART1 =>
609 wb_uart1_in.cyc <= wb_sio_out.cyc;
610 wb_sio_in <= wb_uart1_out;
611 when SLAVE_IO_SPI_FLASH_MAP =>
612 -- Clear top bits so they don't make their way to the
614 wb_spiflash_in.adr(29 downto 28) <= "00";
615 wb_spiflash_in.cyc <= wb_sio_out.cyc;
616 wb_sio_in <= wb_spiflash_out;
617 wb_spiflash_is_map <= '1';
618 when SLAVE_IO_SPI_FLASH_REG =>
619 wb_spiflash_in.cyc <= wb_sio_out.cyc;
620 wb_sio_in <= wb_spiflash_out;
621 wb_spiflash_is_reg <= '1';
628 syscon0: entity work.syscon
631 HAS_DRAM => HAS_DRAM,
632 BRAM_SIZE => MEMORY_SIZE,
633 DRAM_SIZE => DRAM_SIZE,
634 DRAM_INIT_SIZE => DRAM_INIT_SIZE,
635 CLK_FREQ => CLK_FREQ,
636 HAS_SPI_FLASH => HAS_SPI_FLASH,
637 SPI_FLASH_OFFSET => SPI_FLASH_OFFSET,
638 HAS_LITEETH => HAS_LITEETH,
639 UART0_IS_16550 => UART0_IS_16550,
640 HAS_UART1 => HAS_UART1
645 wishbone_in => wb_syscon_in,
646 wishbone_out => wb_syscon_out,
647 dram_at_0 => dram_at_0,
648 core_reset => do_core_reset,
649 soc_reset => open -- XXX TODO
655 -- Either potato (legacy) or 16550
657 uart0_pp: if not UART0_IS_16550 generate
658 uart0: entity work.pp_soc_uart
668 wb_adr_in => wb_uart0_in.adr(11 downto 0),
669 wb_dat_in => wb_uart0_in.dat(7 downto 0),
670 wb_dat_out => uart0_dat8,
671 wb_cyc_in => wb_uart0_in.cyc,
672 wb_stb_in => wb_uart0_in.stb,
673 wb_we_in => wb_uart0_in.we,
674 wb_ack_out => wb_uart0_out.ack
678 uart0_16550 : if UART0_IS_16550 generate
679 signal irq_l : std_ulogic;
683 wb_clk_i => system_clk,
684 wb_rst_i => rst_uart,
685 wb_adr_i => wb_uart0_in.adr(4 downto 2),
686 wb_dat_i => wb_uart0_in.dat(7 downto 0),
687 wb_dat_o => uart0_dat8,
688 wb_we_i => wb_uart0_in.we,
689 wb_stb_i => wb_uart0_in.stb,
690 wb_cyc_i => wb_uart0_in.cyc,
691 wb_ack_o => wb_uart0_out.ack,
693 stx_pad_o => uart0_txd,
694 srx_pad_i => uart0_rxd,
703 -- Add a register on the irq out, helps timing
704 uart0_irq_latch: process(system_clk)
706 if rising_edge(system_clk) then
712 wb_uart0_out.dat <= x"000000" & uart0_dat8;
713 wb_uart0_out.stall <= not wb_uart0_out.ack;
718 -- Always 16550 if it exists
720 uart1: if HAS_UART1 generate
721 signal irq_l : std_ulogic;
725 wb_clk_i => system_clk,
726 wb_rst_i => rst_uart,
727 wb_adr_i => wb_uart1_in.adr(4 downto 2),
728 wb_dat_i => wb_uart1_in.dat(7 downto 0),
729 wb_dat_o => uart1_dat8,
730 wb_we_i => wb_uart1_in.we,
731 wb_stb_i => wb_uart1_in.stb,
732 wb_cyc_i => wb_uart1_in.cyc,
733 wb_ack_o => wb_uart1_out.ack,
735 stx_pad_o => uart1_txd,
736 srx_pad_i => uart1_rxd,
744 -- Add a register on the irq out, helps timing
745 uart0_irq_latch: process(system_clk)
747 if rising_edge(system_clk) then
751 wb_uart1_out.dat <= x"000000" & uart1_dat8;
752 wb_uart1_out.stall <= not wb_uart1_out.ack;
755 no_uart1 : if not HAS_UART1 generate
756 wb_uart1_out.dat <= x"00000000";
757 wb_uart1_out.ack <= wb_uart1_in.cyc and wb_uart1_in.stb;
758 wb_uart1_out.stall <= '0';
762 spiflash_gen: if HAS_SPI_FLASH generate
763 spiflash: entity work.spi_flash_ctrl
765 DATA_LINES => SPI_FLASH_DLINES,
766 DEF_CLK_DIV => SPI_FLASH_DEF_CKDV,
767 DEF_QUAD_READ => SPI_FLASH_DEF_QUAD
772 wb_in => wb_spiflash_in,
773 wb_out => wb_spiflash_out,
774 wb_sel_reg => wb_spiflash_is_reg,
775 wb_sel_map => wb_spiflash_is_map,
776 sck => spi_flash_sck,
777 cs_n => spi_flash_cs_n,
778 sdat_o => spi_flash_sdat_o,
779 sdat_oe => spi_flash_sdat_oe,
780 sdat_i => spi_flash_sdat_i
784 no_spi0_gen: if not HAS_SPI_FLASH generate
785 wb_spiflash_out.dat <= (others => '1');
786 wb_spiflash_out.ack <= wb_spiflash_in.cyc and wb_spiflash_in.stb;
787 wb_spiflash_out.stall <= wb_spiflash_in.cyc and not wb_spiflash_out.ack;
790 xics_icp: entity work.xics_icp
794 wb_in => wb_xics_icp_in,
795 wb_out => wb_xics_icp_out,
796 ics_in => ics_to_icp,
797 core_irq_out => core_ext_irq
800 xics_ics: entity work.xics_ics
808 wb_in => wb_xics_ics_in,
809 wb_out => wb_xics_ics_out,
810 int_level_in => int_level_in,
811 icp_out => ics_to_icp
814 -- Assign external interrupts
815 interrupts: process(all)
817 int_level_in <= (others => '0');
818 int_level_in(0) <= uart0_irq;
819 int_level_in(1) <= ext_irq_eth;
820 int_level_in(2) <= uart1_irq;
824 bram: if MEMORY_SIZE /= 0 generate
825 bram0: entity work.wishbone_bram_wrapper
827 MEMORY_SIZE => MEMORY_SIZE,
828 RAM_INIT_FILE => RAM_INIT_FILE
833 wishbone_in => wb_bram_in,
834 wishbone_out => wb_bram_out
838 no_bram: if MEMORY_SIZE = 0 generate
839 wb_bram_out.ack <= wb_bram_in.cyc and wb_bram_in.stb;
840 wb_bram_out.dat <= x"FFFFFFFFFFFFFFFF";
841 wb_bram_out.stall <= not wb_bram_out.ack;
844 -- DMI(debug bus) <-> JTAG bridge
845 dtm: entity work.dmi_dtm
851 sys_clk => system_clk,
852 sys_reset => rst_dtm,
853 dmi_addr => dmi_addr,
855 dmi_dout => dmi_dout,
862 dmi_intercon: process(dmi_addr, dmi_req,
863 dmi_wb_ack, dmi_wb_dout,
864 dmi_core_ack, dmi_core_dout)
866 -- DMI address map (each address is a full 64-bit register)
868 -- Offset: Size: Slave:
872 type slave_type is (SLAVE_WB,
875 variable slave : slave_type;
877 -- Simple address decoder
879 if std_match(dmi_addr, "000000--") then
881 elsif std_match(dmi_addr, "0001----") then
890 dmi_wb_req <= dmi_req;
891 dmi_ack <= dmi_wb_ack;
892 dmi_din <= dmi_wb_dout;
894 dmi_core_req <= dmi_req;
895 dmi_ack <= dmi_core_ack;
896 dmi_din <= dmi_core_dout;
899 dmi_din <= (others => '1');
903 if SIM and dmi_req = '1' and dmi_addr = "11111111" and dmi_wr = '1' then
908 -- Wishbone debug master (TODO: Add a DMI address decoder)
909 wishbone_debug: entity work.wishbone_debug_master
910 port map(clk => system_clk,
912 dmi_addr => dmi_addr(1 downto 0),
913 dmi_dout => dmi_wb_dout,
916 dmi_ack => dmi_wb_ack,
917 dmi_req => dmi_wb_req,
918 wb_in => wishbone_debug_in,
919 wb_out => wishbone_debug_out);
922 end architecture behaviour;