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 HAS_TERCEL : boolean := false;
70 UART0_IS_16550 : boolean := true;
71 HAS_UART1 : boolean := false;
72 ICACHE_NUM_LINES : natural := 64;
73 ICACHE_NUM_WAYS : natural := 2;
74 ICACHE_TLB_SIZE : natural := 64;
75 DCACHE_NUM_LINES : natural := 64;
76 DCACHE_NUM_WAYS : natural := 2;
77 DCACHE_TLB_SET_SIZE : natural := 64;
78 DCACHE_TLB_NUM_WAYS : natural := 2
82 system_clk : in std_ulogic;
84 -- "Large" (64-bit) DRAM wishbone
85 wb_dram_in : out wishbone_master_out;
86 wb_dram_out : in wishbone_slave_out := wishbone_slave_out_init;
88 -- "Small" (32-bit) external IO wishbone
89 wb_ext_io_in : out wb_io_master_out;
90 wb_ext_io_out : in wb_io_slave_out := wb_io_slave_out_init;
91 wb_ext_is_dram_csr : out std_ulogic;
92 wb_ext_is_dram_init : out std_ulogic;
93 wb_ext_is_eth : out std_ulogic;
94 wb_ext_is_tercel : out std_ulogic;
96 -- External interrupts
97 ext_irq_eth : in std_ulogic := '0';
100 uart0_txd : out std_ulogic;
101 uart0_rxd : in std_ulogic := '0';
104 uart1_txd : out std_ulogic;
105 uart1_rxd : in std_ulogic := '0';
107 -- SPI Flash controller signals:
108 wb_spiflash_in : out wb_io_master_out;
109 wb_spiflash_out : in wb_io_slave_out := wb_io_slave_out_init;
111 -- DRAM controller signals
112 alt_reset : in std_ulogic := '0'
116 architecture behaviour of soc is
118 -- Wishbone master signals:
119 signal wishbone_dcore_in : wishbone_slave_out;
120 signal wishbone_dcore_out : wishbone_master_out;
121 signal wishbone_icore_in : wishbone_slave_out;
122 signal wishbone_icore_out : wishbone_master_out;
123 signal wishbone_debug_in : wishbone_slave_out;
124 signal wishbone_debug_out : wishbone_master_out;
126 -- Arbiter array (ghdl doesnt' support assigning the array
127 -- elements in the entity instantiation)
128 constant NUM_WB_MASTERS : positive := 3;
129 signal wb_masters_out : wishbone_master_out_vector(0 to NUM_WB_MASTERS-1);
130 signal wb_masters_in : wishbone_slave_out_vector(0 to NUM_WB_MASTERS-1);
132 -- Wishbone master (output of arbiter):
133 signal wb_master_in : wishbone_slave_out;
134 signal wb_master_out : wishbone_master_out;
136 -- Main "IO" bus, from main slave decoder to the latch
137 signal wb_io_in : wishbone_master_out;
138 signal wb_io_out : wishbone_slave_out;
140 -- Secondary (smaller) IO bus after the IO bus latch
141 signal wb_sio_out : wb_io_master_out;
142 signal wb_sio_in : wb_io_slave_out;
145 signal dram_at_0 : std_ulogic;
146 signal do_core_reset : std_ulogic;
147 signal wb_syscon_in : wb_io_master_out;
148 signal wb_syscon_out : wb_io_slave_out;
151 signal wb_uart0_in : wb_io_master_out;
152 signal wb_uart0_out : wb_io_slave_out;
153 signal uart0_dat8 : std_ulogic_vector(7 downto 0);
154 signal uart0_irq : std_ulogic;
157 signal wb_uart1_in : wb_io_master_out;
158 signal wb_uart1_out : wb_io_slave_out;
159 signal uart1_dat8 : std_ulogic_vector(7 downto 0);
160 signal uart1_irq : 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_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,
263 ICACHE_NUM_LINES => ICACHE_NUM_LINES,
264 ICACHE_NUM_WAYS => ICACHE_NUM_WAYS,
265 ICACHE_TLB_SIZE => ICACHE_TLB_SIZE,
266 DCACHE_NUM_LINES => DCACHE_NUM_LINES,
267 DCACHE_NUM_WAYS => DCACHE_NUM_WAYS,
268 DCACHE_TLB_SET_SIZE => DCACHE_TLB_SET_SIZE,
269 DCACHE_TLB_NUM_WAYS => DCACHE_TLB_NUM_WAYS
274 alt_reset => alt_reset_d,
275 wishbone_insn_in => wishbone_icore_in,
276 wishbone_insn_out => wishbone_icore_out,
277 wishbone_data_in => wishbone_dcore_in,
278 wishbone_data_out => wishbone_dcore_out,
279 dmi_addr => dmi_addr(3 downto 0),
280 dmi_dout => dmi_core_dout,
283 dmi_ack => dmi_core_ack,
284 dmi_req => dmi_core_req,
285 ext_irq => core_ext_irq
288 -- Wishbone bus master arbiter & mux
289 wb_masters_out <= (0 => wishbone_dcore_out,
290 1 => wishbone_icore_out,
291 2 => wishbone_debug_out);
292 wishbone_dcore_in <= wb_masters_in(0);
293 wishbone_icore_in <= wb_masters_in(1);
294 wishbone_debug_in <= wb_masters_in(2);
295 wishbone_arbiter_0: entity work.wishbone_arbiter
297 NUM_MASTERS => NUM_WB_MASTERS
302 wb_masters_in => wb_masters_out,
303 wb_masters_out => wb_masters_in,
304 wb_slave_out => wb_master_out,
305 wb_slave_in => wb_master_in
308 -- Top level Wishbone slaves address decoder & mux
310 -- From CPU to BRAM, DRAM, IO, selected on top 3 bits and dram_at_0
317 slave_top_intercon: process(wb_master_out, wb_bram_out, wb_dram_out, wb_io_out, dram_at_0)
318 type slave_top_type is (SLAVE_TOP_BRAM,
321 variable slave_top : slave_top_type;
322 variable top_decode : std_ulogic_vector(3 downto 0);
324 -- Top-level address decoder
325 top_decode := wb_master_out.adr(31 downto 29) & dram_at_0;
326 slave_top := SLAVE_TOP_BRAM;
327 if std_match(top_decode, "0000") then
328 slave_top := SLAVE_TOP_BRAM;
329 elsif std_match(top_decode, "0001") then
330 slave_top := SLAVE_TOP_DRAM;
331 elsif std_match(top_decode, "01--") then
332 slave_top := SLAVE_TOP_DRAM;
333 elsif std_match(top_decode, "10--") then
334 slave_top := SLAVE_TOP_BRAM;
335 elsif std_match(top_decode, "11--") then
336 slave_top := SLAVE_TOP_IO;
339 -- Top level wishbone muxing.
340 wb_bram_in <= wb_master_out;
341 wb_bram_in.cyc <= '0';
342 wb_dram_in <= wb_master_out;
343 wb_dram_in.cyc <= '0';
344 wb_io_in <= wb_master_out;
347 when SLAVE_TOP_BRAM =>
348 wb_bram_in.cyc <= wb_master_out.cyc;
349 wb_master_in <= wb_bram_out;
350 when SLAVE_TOP_DRAM =>
352 wb_dram_in.cyc <= wb_master_out.cyc;
353 wb_master_in <= wb_dram_out;
355 wb_master_in.ack <= wb_master_out.cyc and wb_master_out.stb;
356 wb_master_in.dat <= (others => '1');
357 wb_master_in.stall <= '0';
360 wb_io_in.cyc <= wb_master_out.cyc;
361 wb_master_in <= wb_io_out;
364 end process slave_top_intercon;
366 -- IO wishbone slave 64->32 bits converter
368 -- For timing reasons, this adds a one cycle latch on the way both
369 -- in and out. This relaxes timing and routing pressure on the "main"
370 -- memory bus by moving all simple IOs to a slower 32-bit bus.
372 -- This implementation is rather dumb at the moment, no stash buffer,
373 -- so we stall whenever that latch is busy. This can be improved.
375 slave_io_latch: process(system_clk)
377 type state_t is (IDLE, WAIT_ACK_BOT, WAIT_ACK_TOP);
378 variable state : state_t;
381 variable has_top : boolean;
382 variable has_bot : boolean;
384 if rising_edge(system_clk) then
387 wb_io_out.ack <= '0';
388 wb_io_out.stall <= '0';
389 wb_sio_out.cyc <= '0';
390 wb_sio_out.stb <= '0';
396 -- Clear ACK in case it was set
397 wb_io_out.ack <= '0';
399 -- Do we have a cycle ?
400 if wb_io_in.cyc = '1' and wb_io_in.stb = '1' then
401 -- Stall master until we are done, we are't (yet) pipelining
402 -- this, it's all slow IOs.
403 wb_io_out.stall <= '1';
405 -- Start cycle downstream
406 wb_sio_out.cyc <= '1';
407 wb_sio_out.stb <= '1';
409 -- Copy write enable to IO out, copy address as well
410 wb_sio_out.we <= wb_io_in.we;
411 wb_sio_out.adr <= wb_io_in.adr(wb_sio_out.adr'left downto 3) & "000";
413 -- Do we have a top word and/or a bottom word ?
414 has_top := wb_io_in.sel(7 downto 4) /= "0000";
415 has_bot := wb_io_in.sel(3 downto 0) /= "0000";
417 -- If we have a bottom word, handle it first, otherwise
418 -- send the top word down. XXX Split the actual mux out
419 -- and only generate a control signal.
421 if wb_io_in.we = '1' then
422 wb_sio_out.dat <= wb_io_in.dat(31 downto 0);
424 wb_sio_out.sel <= wb_io_in.sel(3 downto 0);
427 state := WAIT_ACK_BOT;
429 if wb_io_in.we = '1' then
430 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
432 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
435 wb_sio_out.adr(2) <= '1';
438 state := WAIT_ACK_TOP;
442 -- If we aren't stalled by the device, clear stb
443 if wb_sio_in.stall = '0' then
444 wb_sio_out.stb <= '0';
448 if wb_sio_in.ack = '1' then
449 -- If it's a read, latch the data
450 if wb_sio_out.we = '0' then
451 wb_io_out.dat(31 downto 0) <= wb_sio_in.dat;
454 -- Do we have a "top" part as well ?
457 if wb_io_in.we = '1' then
458 wb_sio_out.dat <= wb_io_in.dat(63 downto 32);
460 wb_sio_out.sel <= wb_io_in.sel(7 downto 4);
462 -- Bump address and set STB
463 wb_sio_out.adr(2) <= '1';
464 wb_sio_out.stb <= '1';
467 state := WAIT_ACK_TOP;
469 -- We are done, ack up, clear cyc downstram
470 wb_sio_out.cyc <= '0';
472 -- And ack & unstall upstream
473 wb_io_out.ack <= '1';
474 wb_io_out.stall <= '0';
481 -- If we aren't stalled by the device, clear stb
482 if wb_sio_in.stall = '0' then
483 wb_sio_out.stb <= '0';
487 if wb_sio_in.ack = '1' then
488 -- If it's a read, latch the data
489 if wb_sio_out.we = '0' then
490 wb_io_out.dat(63 downto 32) <= wb_sio_in.dat;
493 -- We are done, ack up, clear cyc downstram
494 wb_sio_out.cyc <= '0';
496 -- And ack & unstall upstream
497 wb_io_out.ack <= '1';
498 wb_io_out.stall <= '0';
508 -- IO wishbone slave intercon.
510 slave_io_intercon: process(wb_sio_out, wb_syscon_out, wb_uart0_out, wb_uart1_out,
511 wb_ext_io_out, wb_xics_icp_out, wb_xics_ics_out,
513 variable slave_io : slave_io_type;
515 variable match : std_ulogic_vector(31 downto 12);
516 variable ext_valid : boolean;
519 -- Simple address decoder.
520 slave_io := SLAVE_IO_NONE;
521 match := "11" & wb_sio_out.adr(29 downto 12);
522 if std_match(match, x"FF---") and HAS_DRAM then
523 slave_io := SLAVE_IO_EXTERNAL;
524 elsif std_match(match, x"F----") then
525 slave_io := SLAVE_IO_SPI_FLASH_MAP;
526 elsif std_match(match, x"C0000") then
527 slave_io := SLAVE_IO_SYSCON;
528 elsif std_match(match, x"C0002") then
529 slave_io := SLAVE_IO_UART;
530 elsif std_match(match, x"C0003") then
531 slave_io := SLAVE_IO_UART1;
532 elsif std_match(match, x"C8---") then
533 slave_io := SLAVE_IO_EXTERNAL;
534 elsif std_match(match, x"C0004") then
535 slave_io := SLAVE_IO_ICP;
536 elsif std_match(match, x"C0005") then
537 slave_io := SLAVE_IO_ICS;
539 slave_io_dbg <= slave_io;
540 wb_uart0_in <= wb_sio_out;
541 wb_uart0_in.cyc <= '0';
542 wb_uart1_in <= wb_sio_out;
543 wb_uart1_in.cyc <= '0';
544 wb_spiflash_in <= wb_sio_out;
545 wb_spiflash_in.cyc <= '0';
547 -- Only give xics 8 bits of wb addr (for now...)
548 wb_xics_icp_in <= wb_sio_out;
549 wb_xics_icp_in.adr <= (others => '0');
550 wb_xics_icp_in.adr(7 downto 0) <= wb_sio_out.adr(7 downto 0);
551 wb_xics_icp_in.cyc <= '0';
552 wb_xics_ics_in <= wb_sio_out;
553 wb_xics_ics_in.adr <= (others => '0');
554 wb_xics_ics_in.adr(11 downto 0) <= wb_sio_out.adr(11 downto 0);
555 wb_xics_ics_in.cyc <= '0';
557 wb_ext_io_in <= wb_sio_out;
558 wb_ext_io_in.cyc <= '0';
560 wb_syscon_in <= wb_sio_out;
561 wb_syscon_in.cyc <= '0';
563 wb_ext_is_dram_csr <= '0';
564 wb_ext_is_dram_init <= '0';
565 wb_ext_is_eth <= '0';
567 -- Default response, ack & return all 1's
568 wb_sio_in.dat <= (others => '1');
569 wb_sio_in.ack <= wb_sio_out.stb and wb_sio_out.cyc;
570 wb_sio_in.stall <= '0';
573 when SLAVE_IO_EXTERNAL =>
574 -- Ext IO "chip selects"
576 -- DRAM init is special at 0xFF* so we just test the top
577 -- bit. Everything else is at 0xC8* so we test only bits
581 if wb_sio_out.adr(29) = '1' and HAS_DRAM then -- DRAM init is special
582 wb_ext_is_dram_init <= '1';
584 elsif wb_sio_out.adr(23 downto 16) = x"00" and HAS_DRAM then
585 wb_ext_is_dram_csr <= '1';
587 elsif wb_sio_out.adr(23 downto 16) = x"02" and HAS_LITEETH then
588 wb_ext_is_eth <= '1';
590 elsif wb_sio_out.adr(23 downto 16) = x"03" and HAS_LITEETH then
591 wb_ext_is_eth <= '1';
593 elsif wb_sio_out.adr(21 downto 14) = x"05" and HAS_TERCEL then
594 wb_ext_is_tercel <= '1';
598 wb_ext_io_in.cyc <= wb_sio_out.cyc;
599 wb_sio_in <= wb_ext_io_out;
602 when SLAVE_IO_SYSCON =>
603 wb_syscon_in.cyc <= wb_sio_out.cyc;
604 wb_sio_in <= wb_syscon_out;
605 when SLAVE_IO_UART =>
606 wb_uart0_in.cyc <= wb_sio_out.cyc;
607 wb_sio_in <= wb_uart0_out;
609 wb_xics_icp_in.cyc <= wb_sio_out.cyc;
610 wb_sio_in <= wb_xics_icp_out;
612 wb_xics_ics_in.cyc <= wb_sio_out.cyc;
613 wb_sio_in <= wb_xics_ics_out;
614 when SLAVE_IO_UART1 =>
615 wb_uart1_in.cyc <= wb_sio_out.cyc;
616 wb_sio_in <= wb_uart1_out;
617 when SLAVE_IO_SPI_FLASH_MAP =>
618 -- Clear top bits so they don't make their way to the
620 wb_spiflash_in.adr(29 downto 28) <= "00";
621 wb_spiflash_in.cyc <= wb_sio_out.cyc;
622 wb_sio_in <= wb_spiflash_out;
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 xics_icp: entity work.xics_icp
767 wb_in => wb_xics_icp_in,
768 wb_out => wb_xics_icp_out,
769 ics_in => ics_to_icp,
770 core_irq_out => core_ext_irq
773 xics_ics: entity work.xics_ics
781 wb_in => wb_xics_ics_in,
782 wb_out => wb_xics_ics_out,
783 int_level_in => int_level_in,
784 icp_out => ics_to_icp
787 -- Assign external interrupts
788 interrupts: process(all)
790 int_level_in <= (others => '0');
791 int_level_in(0) <= uart0_irq;
792 int_level_in(1) <= ext_irq_eth;
793 int_level_in(2) <= uart1_irq;
797 bram: if MEMORY_SIZE /= 0 generate
798 bram0: entity work.wishbone_bram_wrapper
800 MEMORY_SIZE => MEMORY_SIZE,
801 RAM_INIT_FILE => RAM_INIT_FILE
806 wishbone_in => wb_bram_in,
807 wishbone_out => wb_bram_out
811 no_bram: if MEMORY_SIZE = 0 generate
812 wb_bram_out.ack <= wb_bram_in.cyc and wb_bram_in.stb;
813 wb_bram_out.dat <= x"FFFFFFFFFFFFFFFF";
814 wb_bram_out.stall <= not wb_bram_out.ack;
817 -- DMI(debug bus) <-> JTAG bridge
818 dtm: entity work.dmi_dtm
824 sys_clk => system_clk,
825 sys_reset => rst_dtm,
826 dmi_addr => dmi_addr,
828 dmi_dout => dmi_dout,
835 dmi_intercon: process(dmi_addr, dmi_req,
836 dmi_wb_ack, dmi_wb_dout,
837 dmi_core_ack, dmi_core_dout)
839 -- DMI address map (each address is a full 64-bit register)
841 -- Offset: Size: Slave:
845 type slave_type is (SLAVE_WB,
848 variable slave : slave_type;
850 -- Simple address decoder
852 if std_match(dmi_addr, "000000--") then
854 elsif std_match(dmi_addr, "0001----") then
863 dmi_wb_req <= dmi_req;
864 dmi_ack <= dmi_wb_ack;
865 dmi_din <= dmi_wb_dout;
867 dmi_core_req <= dmi_req;
868 dmi_ack <= dmi_core_ack;
869 dmi_din <= dmi_core_dout;
872 dmi_din <= (others => '1');
876 if SIM and dmi_req = '1' and dmi_addr = "11111111" and dmi_wr = '1' then
881 -- Wishbone debug master (TODO: Add a DMI address decoder)
882 wishbone_debug: entity work.wishbone_debug_master
883 port map(clk => system_clk,
885 dmi_addr => dmi_addr(1 downto 0),
886 dmi_dout => dmi_wb_dout,
889 dmi_ack => dmi_wb_ack,
890 dmi_req => dmi_wb_req,
891 wb_in => wishbone_debug_in,
892 wb_out => wishbone_debug_out);
894 --pragma synthesis_off
895 wb_x_state: process(system_clk)
897 if rising_edge(system_clk) then
900 assert not(is_x(wb_masters_out(0).cyc)) and not(is_x(wb_masters_out(0).stb)) severity failure;
901 assert not(is_x(wb_masters_out(1).cyc)) and not(is_x(wb_masters_out(1).stb)) severity failure;
902 assert not(is_x(wb_masters_out(2).cyc)) and not(is_x(wb_masters_out(2).stb)) severity failure;
903 assert not(is_x(wb_masters_in(0).ack)) severity failure;
904 assert not(is_x(wb_masters_in(1).ack)) severity failure;
905 assert not(is_x(wb_masters_in(2).ack)) severity failure;
907 -- Main memory wishbones
908 assert not(is_x(wb_bram_in.cyc)) and not (is_x(wb_bram_in.stb)) severity failure;
909 assert not(is_x(wb_dram_in.cyc)) and not (is_x(wb_dram_in.stb)) severity failure;
910 assert not(is_x(wb_io_in.cyc)) and not (is_x(wb_io_in.stb)) severity failure;
911 assert not(is_x(wb_bram_out.ack)) severity failure;
912 assert not(is_x(wb_dram_out.ack)) severity failure;
913 assert not(is_x(wb_io_out.ack)) severity failure;
916 assert not(is_x(wb_uart0_in.cyc)) and not(is_x(wb_uart0_in.stb)) severity failure;
917 assert not(is_x(wb_uart1_in.cyc)) and not(is_x(wb_uart1_in.stb)) severity failure;
918 assert not(is_x(wb_spiflash_in.cyc)) and not(is_x(wb_spiflash_in.stb)) severity failure;
919 assert not(is_x(wb_xics_icp_in.cyc)) and not(is_x(wb_xics_icp_in.stb)) severity failure;
920 assert not(is_x(wb_xics_ics_in.cyc)) and not(is_x(wb_xics_ics_in.stb)) severity failure;
921 assert not(is_x(wb_ext_io_in.cyc)) and not(is_x(wb_ext_io_in.stb)) severity failure;
922 assert not(is_x(wb_syscon_in.cyc)) and not(is_x(wb_syscon_in.stb)) severity failure;
923 assert not(is_x(wb_uart0_out.ack)) severity failure;
924 assert not(is_x(wb_uart1_out.ack)) severity failure;
925 assert not(is_x(wb_spiflash_out.ack)) severity failure;
926 assert not(is_x(wb_xics_icp_out.ack)) severity failure;
927 assert not(is_x(wb_xics_ics_out.ack)) severity failure;
928 assert not(is_x(wb_ext_io_out.ack)) severity failure;
929 assert not(is_x(wb_syscon_out.ack)) severity failure;
933 --pragma synthesis_on
935 end architecture behaviour;