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 SPI_BOOT_CLOCKS : boolean := true;
67 LOG_LENGTH : natural := 512;
68 HAS_LITEETH : boolean := false;
69 UART0_IS_16550 : boolean := true;
70 HAS_UART1 : boolean := false
74 system_clk : in std_ulogic;
76 -- "Large" (64-bit) DRAM wishbone
77 wb_dram_in : out wishbone_master_out;
78 wb_dram_out : in wishbone_slave_out := wishbone_slave_out_init;
80 -- "Small" (32-bit) external IO wishbone
81 wb_ext_io_in : out wb_io_master_out;
82 wb_ext_io_out : in wb_io_slave_out := wb_io_slave_out_init;
83 wb_ext_is_dram_csr : out std_ulogic;
84 wb_ext_is_dram_init : out std_ulogic;
85 wb_ext_is_eth : out std_ulogic;
87 -- External interrupts
88 ext_irq_eth : in std_ulogic := '0';
91 uart0_txd : out std_ulogic;
92 uart0_rxd : in std_ulogic := '0';
95 uart1_txd : out std_ulogic;
96 uart1_rxd : in std_ulogic := '0';
99 spi_flash_sck : out std_ulogic;
100 spi_flash_cs_n : out std_ulogic;
101 spi_flash_sdat_o : out std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0);
102 spi_flash_sdat_oe : out std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0);
103 spi_flash_sdat_i : in std_ulogic_vector(SPI_FLASH_DLINES-1 downto 0) := (others => '1');
105 -- DRAM controller signals
106 alt_reset : in std_ulogic := '0'
110 architecture behaviour of soc is
112 -- Wishbone master signals:
113 signal wishbone_dcore_in : wishbone_slave_out;
114 signal wishbone_dcore_out : wishbone_master_out;
115 signal wishbone_icore_in : wishbone_slave_out;
116 signal wishbone_icore_out : wishbone_master_out;
117 signal wishbone_debug_in : wishbone_slave_out;
118 signal wishbone_debug_out : wishbone_master_out;
120 -- Arbiter array (ghdl doesnt' support assigning the array
121 -- elements in the entity instantiation)
122 constant NUM_WB_MASTERS : positive := 3;
123 signal wb_masters_out : wishbone_master_out_vector(0 to NUM_WB_MASTERS-1);
124 signal wb_masters_in : wishbone_slave_out_vector(0 to NUM_WB_MASTERS-1);
126 -- Wishbone master (output of arbiter):
127 signal wb_master_in : wishbone_slave_out;
128 signal wb_master_out : wishbone_master_out;
130 -- Main "IO" bus, from main slave decoder to the latch
131 signal wb_io_in : wishbone_master_out;
132 signal wb_io_out : wishbone_slave_out;
134 -- Secondary (smaller) IO bus after the IO bus latch
135 signal wb_sio_out : wb_io_master_out;
136 signal wb_sio_in : wb_io_slave_out;
139 signal dram_at_0 : std_ulogic;
140 signal do_core_reset : std_ulogic;
141 signal wb_syscon_in : wb_io_master_out;
142 signal wb_syscon_out : wb_io_slave_out;
145 signal wb_uart0_in : wb_io_master_out;
146 signal wb_uart0_out : wb_io_slave_out;
147 signal uart0_dat8 : std_ulogic_vector(7 downto 0);
148 signal uart0_irq : std_ulogic;
151 signal wb_uart1_in : wb_io_master_out;
152 signal wb_uart1_out : wb_io_slave_out;
153 signal uart1_dat8 : std_ulogic_vector(7 downto 0);
154 signal uart1_irq : std_ulogic;
156 -- SPI Flash controller signals:
157 signal wb_spiflash_in : wb_io_master_out;
158 signal wb_spiflash_out : wb_io_slave_out;
159 signal wb_spiflash_is_reg : std_ulogic;
160 signal wb_spiflash_is_map : std_ulogic;
163 signal wb_xics_icp_in : wb_io_master_out;
164 signal wb_xics_icp_out : wb_io_slave_out;
165 signal wb_xics_ics_in : wb_io_master_out;
166 signal wb_xics_ics_out : wb_io_slave_out;
167 signal int_level_in : std_ulogic_vector(15 downto 0);
168 signal ics_to_icp : ics_to_icp_t;
169 signal core_ext_irq : std_ulogic;
171 -- Main memory signals:
172 signal wb_bram_in : wishbone_master_out;
173 signal wb_bram_out : wishbone_slave_out;
175 -- DMI debug bus signals
176 signal dmi_addr : std_ulogic_vector(7 downto 0);
177 signal dmi_din : std_ulogic_vector(63 downto 0);
178 signal dmi_dout : std_ulogic_vector(63 downto 0);
179 signal dmi_req : std_ulogic;
180 signal dmi_wr : std_ulogic;
181 signal dmi_ack : std_ulogic;
183 -- Per slave DMI signals
184 signal dmi_wb_dout : std_ulogic_vector(63 downto 0);
185 signal dmi_wb_req : std_ulogic;
186 signal dmi_wb_ack : std_ulogic;
187 signal dmi_core_dout : std_ulogic_vector(63 downto 0);
188 signal dmi_core_req : std_ulogic;
189 signal dmi_core_ack : std_ulogic;
191 -- Delayed/latched resets and alt_reset
192 signal rst_core : std_ulogic := '1';
193 signal rst_uart : std_ulogic := '1';
194 signal rst_xics : std_ulogic := '1';
195 signal rst_spi : std_ulogic := '1';
196 signal rst_bram : std_ulogic := '1';
197 signal rst_dtm : std_ulogic := '1';
198 signal rst_wbar : std_ulogic := '1';
199 signal rst_wbdb : std_ulogic := '1';
200 signal alt_reset_d : std_ulogic;
203 type slave_io_type is (SLAVE_IO_SYSCON,
208 SLAVE_IO_SPI_FLASH_REG,
209 SLAVE_IO_SPI_FLASH_MAP,
212 signal slave_io_dbg : slave_io_type;
214 -- This is the component exported by the 16550 compatible
215 -- UART from FuseSoC.
217 component uart_top port (
218 wb_clk_i : in std_ulogic;
219 wb_rst_i : in std_ulogic;
220 wb_adr_i : in std_ulogic_vector(2 downto 0);
221 wb_dat_i : in std_ulogic_vector(7 downto 0);
222 wb_dat_o : out std_ulogic_vector(7 downto 0);
223 wb_we_i : in std_ulogic;
224 wb_stb_i : in std_ulogic;
225 wb_cyc_i : in std_ulogic;
226 wb_ack_o : out std_ulogic;
227 int_o : out std_ulogic;
228 stx_pad_o : out std_ulogic;
229 srx_pad_i : in std_ulogic;
230 rts_pad_o : out std_ulogic;
231 cts_pad_i : in std_ulogic;
232 dtr_pad_o : out std_ulogic;
233 dsr_pad_i : in std_ulogic;
234 ri_pad_i : in std_ulogic;
235 dcd_pad_i : in std_ulogic
240 resets: process(system_clk)
242 if rising_edge(system_clk) then
243 rst_core <= rst or do_core_reset;
251 alt_reset_d <= alt_reset;
256 processor: entity work.core
261 DISABLE_FLATTEN => DISABLE_FLATTEN_CORE,
262 ALT_RESET_ADDRESS => (23 downto 0 => '0', others => '1'),
263 LOG_LENGTH => LOG_LENGTH
268 alt_reset => alt_reset_d,
269 wishbone_insn_in => wishbone_icore_in,
270 wishbone_insn_out => wishbone_icore_out,
271 wishbone_data_in => wishbone_dcore_in,
272 wishbone_data_out => wishbone_dcore_out,
273 dmi_addr => dmi_addr(3 downto 0),
274 dmi_dout => dmi_core_dout,
277 dmi_ack => dmi_core_ack,
278 dmi_req => dmi_core_req,
279 ext_irq => core_ext_irq
282 -- Wishbone bus master arbiter & mux
283 wb_masters_out <= (0 => wishbone_dcore_out,
284 1 => wishbone_icore_out,
285 2 => wishbone_debug_out);
286 wishbone_dcore_in <= wb_masters_in(0);
287 wishbone_icore_in <= wb_masters_in(1);
288 wishbone_debug_in <= wb_masters_in(2);
289 wishbone_arbiter_0: entity work.wishbone_arbiter
291 NUM_MASTERS => NUM_WB_MASTERS
296 wb_masters_in => wb_masters_out,
297 wb_masters_out => wb_masters_in,
298 wb_slave_out => wb_master_out,
299 wb_slave_in => wb_master_in
302 -- Top level Wishbone slaves address decoder & mux
304 -- From CPU to BRAM, DRAM, IO, selected on top 3 bits and dram_at_0
311 slave_top_intercon: process(wb_master_out, wb_bram_out, wb_dram_out, wb_io_out, dram_at_0)
312 type slave_top_type is (SLAVE_TOP_BRAM,
315 variable slave_top : slave_top_type;
316 variable top_decode : std_ulogic_vector(3 downto 0);
318 -- Top-level address decoder
319 top_decode := wb_master_out.adr(31 downto 29) & dram_at_0;
320 slave_top := SLAVE_TOP_BRAM;
321 if std_match(top_decode, "0000") then
322 slave_top := SLAVE_TOP_BRAM;
323 elsif std_match(top_decode, "0001") then
324 slave_top := SLAVE_TOP_DRAM;
325 elsif std_match(top_decode, "01--") then
326 slave_top := SLAVE_TOP_DRAM;
327 elsif std_match(top_decode, "10--") then
328 slave_top := SLAVE_TOP_BRAM;
329 elsif std_match(top_decode, "11--") then
330 slave_top := SLAVE_TOP_IO;
333 -- Top level wishbone muxing.
334 wb_bram_in <= wb_master_out;
335 wb_bram_in.cyc <= '0';
336 wb_dram_in <= wb_master_out;
337 wb_dram_in.cyc <= '0';
338 wb_io_in <= wb_master_out;
341 when SLAVE_TOP_BRAM =>
342 wb_bram_in.cyc <= wb_master_out.cyc;
343 wb_master_in <= wb_bram_out;
344 when SLAVE_TOP_DRAM =>
346 wb_dram_in.cyc <= wb_master_out.cyc;
347 wb_master_in <= wb_dram_out;
349 wb_master_in.ack <= wb_master_out.cyc and wb_master_out.stb;
350 wb_master_in.dat <= (others => '1');
351 wb_master_in.stall <= '0';
354 wb_io_in.cyc <= wb_master_out.cyc;
355 wb_master_in <= wb_io_out;
358 end process slave_top_intercon;
360 -- IO wishbone slave 64->32 bits converter
362 -- For timing reasons, this adds a one cycle latch on the way both
363 -- in and out. This relaxes timing and routing pressure on the "main"
364 -- memory bus by moving all simple IOs to a slower 32-bit bus.
366 -- This implementation is rather dumb at the moment, no stash buffer,
367 -- so we stall whenever that latch is busy. This can be improved.
369 slave_io_latch: process(system_clk)
371 type state_t is (IDLE, WAIT_ACK_BOT, WAIT_ACK_TOP);
372 variable state : state_t;
375 variable has_top : boolean;
376 variable has_bot : boolean;
378 if rising_edge(system_clk) then
381 wb_io_out.ack <= '0';
382 wb_io_out.stall <= '0';
383 wb_sio_out.cyc <= '0';
384 wb_sio_out.stb <= '0';
390 -- Clear ACK in case it was set
391 wb_io_out.ack <= '0';
393 -- Do we have a cycle ?
394 if wb_io_in.cyc = '1' and wb_io_in.stb = '1' then
395 -- Stall master until we are done, we are't (yet) pipelining
396 -- this, it's all slow IOs.
397 wb_io_out.stall <= '1';
399 -- Start cycle downstream
400 wb_sio_out.cyc <= '1';
401 wb_sio_out.stb <= '1';
403 -- Copy write enable to IO out, copy address as well
404 wb_sio_out.we <= wb_io_in.we;
405 wb_sio_out.adr <= wb_io_in.adr(wb_sio_out.adr'left downto 3) & "000";
407 -- Do we have a top word and/or a bottom word ?
408 has_top := wb_io_in.sel(7 downto 4) /= "0000";
409 has_bot := wb_io_in.sel(3 downto 0) /= "0000";
411 -- If we have a bottom word, handle it first, otherwise
412 -- send the top word down. XXX Split the actual mux out
413 -- and only generate a control signal.
415 if wb_io_in.we = '1' then
416 wb_sio_out.dat <= wb_io_in.dat(31 downto 0);
418 wb_sio_out.sel <= wb_io_in.sel(3 downto 0);
421 state := WAIT_ACK_BOT;
423 if wb_io_in.we = '1' then
424 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
426 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
429 wb_sio_out.adr(2) <= '1';
432 state := WAIT_ACK_TOP;
436 -- If we aren't stalled by the device, clear stb
437 if wb_sio_in.stall = '0' then
438 wb_sio_out.stb <= '0';
442 if wb_sio_in.ack = '1' then
443 -- If it's a read, latch the data
444 if wb_sio_out.we = '0' then
445 wb_io_out.dat(31 downto 0) <= wb_sio_in.dat;
448 -- Do we have a "top" part as well ?
451 if wb_io_in.we = '1' then
452 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
454 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
456 -- Bump address and set STB
457 wb_sio_out.adr(2) <= '1';
458 wb_sio_out.stb <= '1';
461 state := WAIT_ACK_TOP;
463 -- We are done, ack up, clear cyc downstram
464 wb_sio_out.cyc <= '0';
466 -- And ack & unstall upstream
467 wb_io_out.ack <= '1';
468 wb_io_out.stall <= '0';
475 -- If we aren't stalled by the device, clear stb
476 if wb_sio_in.stall = '0' then
477 wb_sio_out.stb <= '0';
481 if wb_sio_in.ack = '1' then
482 -- If it's a read, latch the data
483 if wb_sio_out.we = '0' then
484 wb_io_out.dat(63 downto 32) <= wb_sio_in.dat;
487 -- We are done, ack up, clear cyc downstram
488 wb_sio_out.cyc <= '0';
490 -- And ack & unstall upstream
491 wb_io_out.ack <= '1';
492 wb_io_out.stall <= '0';
502 -- IO wishbone slave intercon.
504 slave_io_intercon: process(wb_sio_out, wb_syscon_out, wb_uart0_out, wb_uart1_out,
505 wb_ext_io_out, wb_xics_icp_out, wb_xics_ics_out,
507 variable slave_io : slave_io_type;
509 variable match : std_ulogic_vector(31 downto 12);
510 variable ext_valid : boolean;
513 -- Simple address decoder.
514 slave_io := SLAVE_IO_NONE;
515 match := "11" & wb_sio_out.adr(29 downto 12);
516 if std_match(match, x"FF---") and HAS_DRAM then
517 slave_io := SLAVE_IO_EXTERNAL;
518 elsif std_match(match, x"F----") then
519 slave_io := SLAVE_IO_SPI_FLASH_MAP;
520 elsif std_match(match, x"C0000") then
521 slave_io := SLAVE_IO_SYSCON;
522 elsif std_match(match, x"C0002") then
523 slave_io := SLAVE_IO_UART;
524 elsif std_match(match, x"C0003") then
525 slave_io := SLAVE_IO_UART1;
526 elsif std_match(match, x"C8---") then
527 slave_io := SLAVE_IO_EXTERNAL;
528 elsif std_match(match, x"C0004") then
529 slave_io := SLAVE_IO_ICP;
530 elsif std_match(match, x"C0005") then
531 slave_io := SLAVE_IO_ICS;
532 elsif std_match(match, x"C0006") then
533 slave_io := SLAVE_IO_SPI_FLASH_REG;
535 slave_io_dbg <= slave_io;
536 wb_uart0_in <= wb_sio_out;
537 wb_uart0_in.cyc <= '0';
538 wb_uart1_in <= wb_sio_out;
539 wb_uart1_in.cyc <= '0';
540 wb_spiflash_in <= wb_sio_out;
541 wb_spiflash_in.cyc <= '0';
542 wb_spiflash_is_reg <= '0';
543 wb_spiflash_is_map <= '0';
545 -- Only give xics 8 bits of wb addr (for now...)
546 wb_xics_icp_in <= wb_sio_out;
547 wb_xics_icp_in.adr <= (others => '0');
548 wb_xics_icp_in.adr(7 downto 0) <= wb_sio_out.adr(7 downto 0);
549 wb_xics_icp_in.cyc <= '0';
550 wb_xics_ics_in <= wb_sio_out;
551 wb_xics_ics_in.adr <= (others => '0');
552 wb_xics_ics_in.adr(11 downto 0) <= wb_sio_out.adr(11 downto 0);
553 wb_xics_ics_in.cyc <= '0';
555 wb_ext_io_in <= wb_sio_out;
556 wb_ext_io_in.cyc <= '0';
558 wb_syscon_in <= wb_sio_out;
559 wb_syscon_in.cyc <= '0';
561 wb_ext_is_dram_csr <= '0';
562 wb_ext_is_dram_init <= '0';
563 wb_ext_is_eth <= '0';
565 -- Default response, ack & return all 1's
566 wb_sio_in.dat <= (others => '1');
567 wb_sio_in.ack <= wb_sio_out.stb and wb_sio_out.cyc;
568 wb_sio_in.stall <= '0';
571 when SLAVE_IO_EXTERNAL =>
572 -- Ext IO "chip selects"
574 -- DRAM init is special at 0xFF* so we just test the top
575 -- bit. Everything else is at 0xC8* so we test only bits
579 if wb_sio_out.adr(29) = '1' and HAS_DRAM then -- DRAM init is special
580 wb_ext_is_dram_init <= '1';
582 elsif wb_sio_out.adr(23 downto 16) = x"00" and HAS_DRAM then
583 wb_ext_is_dram_csr <= '1';
585 elsif wb_sio_out.adr(23 downto 16) = x"02" and HAS_LITEETH then
586 wb_ext_is_eth <= '1';
588 elsif wb_sio_out.adr(23 downto 16) = x"03" and HAS_LITEETH then
589 wb_ext_is_eth <= '1';
593 wb_ext_io_in.cyc <= wb_sio_out.cyc;
594 wb_sio_in <= wb_ext_io_out;
597 when SLAVE_IO_SYSCON =>
598 wb_syscon_in.cyc <= wb_sio_out.cyc;
599 wb_sio_in <= wb_syscon_out;
600 when SLAVE_IO_UART =>
601 wb_uart0_in.cyc <= wb_sio_out.cyc;
602 wb_sio_in <= wb_uart0_out;
604 wb_xics_icp_in.cyc <= wb_sio_out.cyc;
605 wb_sio_in <= wb_xics_icp_out;
607 wb_xics_ics_in.cyc <= wb_sio_out.cyc;
608 wb_sio_in <= wb_xics_ics_out;
609 when SLAVE_IO_UART1 =>
610 wb_uart1_in.cyc <= wb_sio_out.cyc;
611 wb_sio_in <= wb_uart1_out;
612 when SLAVE_IO_SPI_FLASH_MAP =>
613 -- Clear top bits so they don't make their way to the
615 wb_spiflash_in.adr(29 downto 28) <= "00";
616 wb_spiflash_in.cyc <= wb_sio_out.cyc;
617 wb_sio_in <= wb_spiflash_out;
618 wb_spiflash_is_map <= '1';
619 when SLAVE_IO_SPI_FLASH_REG =>
620 wb_spiflash_in.cyc <= wb_sio_out.cyc;
621 wb_sio_in <= wb_spiflash_out;
622 wb_spiflash_is_reg <= '1';
629 syscon0: entity work.syscon
632 HAS_DRAM => HAS_DRAM,
633 BRAM_SIZE => MEMORY_SIZE,
634 DRAM_SIZE => DRAM_SIZE,
635 DRAM_INIT_SIZE => DRAM_INIT_SIZE,
636 CLK_FREQ => CLK_FREQ,
637 HAS_SPI_FLASH => HAS_SPI_FLASH,
638 SPI_FLASH_OFFSET => SPI_FLASH_OFFSET,
639 HAS_LITEETH => HAS_LITEETH,
640 UART0_IS_16550 => UART0_IS_16550,
641 HAS_UART1 => HAS_UART1
646 wishbone_in => wb_syscon_in,
647 wishbone_out => wb_syscon_out,
648 dram_at_0 => dram_at_0,
649 core_reset => do_core_reset,
650 soc_reset => open -- XXX TODO
656 -- Either potato (legacy) or 16550
658 uart0_pp: if not UART0_IS_16550 generate
659 uart0: entity work.pp_soc_uart
669 wb_adr_in => wb_uart0_in.adr(11 downto 0),
670 wb_dat_in => wb_uart0_in.dat(7 downto 0),
671 wb_dat_out => uart0_dat8,
672 wb_cyc_in => wb_uart0_in.cyc,
673 wb_stb_in => wb_uart0_in.stb,
674 wb_we_in => wb_uart0_in.we,
675 wb_ack_out => wb_uart0_out.ack
679 uart0_16550 : if UART0_IS_16550 generate
680 signal irq_l : std_ulogic;
684 wb_clk_i => system_clk,
685 wb_rst_i => rst_uart,
686 wb_adr_i => wb_uart0_in.adr(4 downto 2),
687 wb_dat_i => wb_uart0_in.dat(7 downto 0),
688 wb_dat_o => uart0_dat8,
689 wb_we_i => wb_uart0_in.we,
690 wb_stb_i => wb_uart0_in.stb,
691 wb_cyc_i => wb_uart0_in.cyc,
692 wb_ack_o => wb_uart0_out.ack,
694 stx_pad_o => uart0_txd,
695 srx_pad_i => uart0_rxd,
704 -- Add a register on the irq out, helps timing
705 uart0_irq_latch: process(system_clk)
707 if rising_edge(system_clk) then
713 wb_uart0_out.dat <= x"000000" & uart0_dat8;
714 wb_uart0_out.stall <= not wb_uart0_out.ack;
719 -- Always 16550 if it exists
721 uart1: if HAS_UART1 generate
722 signal irq_l : std_ulogic;
726 wb_clk_i => system_clk,
727 wb_rst_i => rst_uart,
728 wb_adr_i => wb_uart1_in.adr(4 downto 2),
729 wb_dat_i => wb_uart1_in.dat(7 downto 0),
730 wb_dat_o => uart1_dat8,
731 wb_we_i => wb_uart1_in.we,
732 wb_stb_i => wb_uart1_in.stb,
733 wb_cyc_i => wb_uart1_in.cyc,
734 wb_ack_o => wb_uart1_out.ack,
736 stx_pad_o => uart1_txd,
737 srx_pad_i => uart1_rxd,
745 -- Add a register on the irq out, helps timing
746 uart0_irq_latch: process(system_clk)
748 if rising_edge(system_clk) then
752 wb_uart1_out.dat <= x"000000" & uart1_dat8;
753 wb_uart1_out.stall <= not wb_uart1_out.ack;
756 no_uart1 : if not HAS_UART1 generate
757 wb_uart1_out.dat <= x"00000000";
758 wb_uart1_out.ack <= wb_uart1_in.cyc and wb_uart1_in.stb;
759 wb_uart1_out.stall <= '0';
763 spiflash_gen: if HAS_SPI_FLASH generate
764 spiflash: entity work.spi_flash_ctrl
766 DATA_LINES => SPI_FLASH_DLINES,
767 DEF_CLK_DIV => SPI_FLASH_DEF_CKDV,
768 DEF_QUAD_READ => SPI_FLASH_DEF_QUAD,
769 BOOT_CLOCKS => SPI_BOOT_CLOCKS
774 wb_in => wb_spiflash_in,
775 wb_out => wb_spiflash_out,
776 wb_sel_reg => wb_spiflash_is_reg,
777 wb_sel_map => wb_spiflash_is_map,
778 sck => spi_flash_sck,
779 cs_n => spi_flash_cs_n,
780 sdat_o => spi_flash_sdat_o,
781 sdat_oe => spi_flash_sdat_oe,
782 sdat_i => spi_flash_sdat_i
786 no_spi0_gen: if not HAS_SPI_FLASH generate
787 wb_spiflash_out.dat <= (others => '1');
788 wb_spiflash_out.ack <= wb_spiflash_in.cyc and wb_spiflash_in.stb;
789 wb_spiflash_out.stall <= wb_spiflash_in.cyc and not wb_spiflash_out.ack;
792 xics_icp: entity work.xics_icp
796 wb_in => wb_xics_icp_in,
797 wb_out => wb_xics_icp_out,
798 ics_in => ics_to_icp,
799 core_irq_out => core_ext_irq
802 xics_ics: entity work.xics_ics
810 wb_in => wb_xics_ics_in,
811 wb_out => wb_xics_ics_out,
812 int_level_in => int_level_in,
813 icp_out => ics_to_icp
816 -- Assign external interrupts
817 interrupts: process(all)
819 int_level_in <= (others => '0');
820 int_level_in(0) <= uart0_irq;
821 int_level_in(1) <= ext_irq_eth;
822 int_level_in(2) <= uart1_irq;
826 bram: if MEMORY_SIZE /= 0 generate
827 bram0: entity work.wishbone_bram_wrapper
829 MEMORY_SIZE => MEMORY_SIZE,
830 RAM_INIT_FILE => RAM_INIT_FILE
835 wishbone_in => wb_bram_in,
836 wishbone_out => wb_bram_out
840 no_bram: if MEMORY_SIZE = 0 generate
841 wb_bram_out.ack <= wb_bram_in.cyc and wb_bram_in.stb;
842 wb_bram_out.dat <= x"FFFFFFFFFFFFFFFF";
843 wb_bram_out.stall <= not wb_bram_out.ack;
846 -- DMI(debug bus) <-> JTAG bridge
847 dtm: entity work.dmi_dtm
853 sys_clk => system_clk,
854 sys_reset => rst_dtm,
855 dmi_addr => dmi_addr,
857 dmi_dout => dmi_dout,
864 dmi_intercon: process(dmi_addr, dmi_req,
865 dmi_wb_ack, dmi_wb_dout,
866 dmi_core_ack, dmi_core_dout)
868 -- DMI address map (each address is a full 64-bit register)
870 -- Offset: Size: Slave:
874 type slave_type is (SLAVE_WB,
877 variable slave : slave_type;
879 -- Simple address decoder
881 if std_match(dmi_addr, "000000--") then
883 elsif std_match(dmi_addr, "0001----") then
892 dmi_wb_req <= dmi_req;
893 dmi_ack <= dmi_wb_ack;
894 dmi_din <= dmi_wb_dout;
896 dmi_core_req <= dmi_req;
897 dmi_ack <= dmi_core_ack;
898 dmi_din <= dmi_core_dout;
901 dmi_din <= (others => '1');
905 if SIM and dmi_req = '1' and dmi_addr = "11111111" and dmi_wr = '1' then
910 -- Wishbone debug master (TODO: Add a DMI address decoder)
911 wishbone_debug: entity work.wishbone_debug_master
912 port map(clk => system_clk,
914 dmi_addr => dmi_addr(1 downto 0),
915 dmi_dout => dmi_wb_dout,
918 dmi_ack => dmi_wb_ack,
919 dmi_req => dmi_wb_req,
920 wb_in => wishbone_debug_in,
921 wb_out => wishbone_debug_out);
923 --pragma synthesis_off
924 wb_x_state: process(system_clk)
926 if rising_edge(system_clk) then
929 assert not(is_x(wb_masters_out(0).cyc)) and not(is_x(wb_masters_out(0).stb)) severity failure;
930 assert not(is_x(wb_masters_out(1).cyc)) and not(is_x(wb_masters_out(1).stb)) severity failure;
931 assert not(is_x(wb_masters_out(2).cyc)) and not(is_x(wb_masters_out(2).stb)) severity failure;
932 assert not(is_x(wb_masters_in(0).ack)) severity failure;
933 assert not(is_x(wb_masters_in(1).ack)) severity failure;
934 assert not(is_x(wb_masters_in(2).ack)) severity failure;
936 -- Main memory wishbones
937 assert not(is_x(wb_bram_in.cyc)) and not (is_x(wb_bram_in.stb)) severity failure;
938 assert not(is_x(wb_dram_in.cyc)) and not (is_x(wb_dram_in.stb)) severity failure;
939 assert not(is_x(wb_io_in.cyc)) and not (is_x(wb_io_in.stb)) severity failure;
940 assert not(is_x(wb_bram_out.ack)) severity failure;
941 assert not(is_x(wb_dram_out.ack)) severity failure;
942 assert not(is_x(wb_io_out.ack)) severity failure;
945 assert not(is_x(wb_uart0_in.cyc)) and not(is_x(wb_uart0_in.stb)) severity failure;
946 assert not(is_x(wb_uart1_in.cyc)) and not(is_x(wb_uart1_in.stb)) severity failure;
947 assert not(is_x(wb_spiflash_in.cyc)) and not(is_x(wb_spiflash_in.stb)) severity failure;
948 assert not(is_x(wb_xics_icp_in.cyc)) and not(is_x(wb_xics_icp_in.stb)) severity failure;
949 assert not(is_x(wb_xics_ics_in.cyc)) and not(is_x(wb_xics_ics_in.stb)) severity failure;
950 assert not(is_x(wb_ext_io_in.cyc)) and not(is_x(wb_ext_io_in.stb)) severity failure;
951 assert not(is_x(wb_syscon_in.cyc)) and not(is_x(wb_syscon_in.stb)) severity failure;
952 assert not(is_x(wb_uart0_out.ack)) severity failure;
953 assert not(is_x(wb_uart1_out.ack)) severity failure;
954 assert not(is_x(wb_spiflash_out.ack)) severity failure;
955 assert not(is_x(wb_xics_icp_out.ack)) severity failure;
956 assert not(is_x(wb_xics_ics_out.ack)) severity failure;
957 assert not(is_x(wb_ext_io_out.ack)) severity failure;
958 assert not(is_x(wb_syscon_out.ack)) severity failure;
962 --pragma synthesis_on
964 end architecture behaviour;