|
|
@ -2,7 +2,10 @@ library ieee;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
use ieee.math_real.all;
|
|
|
|
use ieee.math_real.all;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use std.textio.all;
|
|
|
|
|
|
|
|
|
|
|
|
library work;
|
|
|
|
library work;
|
|
|
|
|
|
|
|
use work.common.all;
|
|
|
|
use work.wishbone_types.all;
|
|
|
|
use work.wishbone_types.all;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -12,7 +15,8 @@ entity soc is
|
|
|
|
generic (
|
|
|
|
generic (
|
|
|
|
MEMORY_SIZE : positive;
|
|
|
|
MEMORY_SIZE : positive;
|
|
|
|
RAM_INIT_FILE : string;
|
|
|
|
RAM_INIT_FILE : string;
|
|
|
|
RESET_LOW : boolean
|
|
|
|
RESET_LOW : boolean;
|
|
|
|
|
|
|
|
SIM : boolean
|
|
|
|
);
|
|
|
|
);
|
|
|
|
port(
|
|
|
|
port(
|
|
|
|
rst : in std_ulogic;
|
|
|
|
rst : in std_ulogic;
|
|
|
@ -37,30 +41,35 @@ architecture behaviour of soc is
|
|
|
|
signal wb_master_out : wishbone_master_out;
|
|
|
|
signal wb_master_out : wishbone_master_out;
|
|
|
|
|
|
|
|
|
|
|
|
-- UART0 signals:
|
|
|
|
-- UART0 signals:
|
|
|
|
signal uart0_adr_in : std_logic_vector(11 downto 0);
|
|
|
|
signal wb_uart0_in : wishbone_master_out;
|
|
|
|
signal uart0_dat_in : std_logic_vector( 7 downto 0);
|
|
|
|
signal wb_uart0_out : wishbone_slave_out;
|
|
|
|
signal uart0_dat_out : std_logic_vector( 7 downto 0);
|
|
|
|
signal uart_dat8 : std_logic_vector(7 downto 0);
|
|
|
|
signal uart0_cyc_in : std_logic;
|
|
|
|
|
|
|
|
signal uart0_stb_in : std_logic;
|
|
|
|
|
|
|
|
signal uart0_we_in : std_logic;
|
|
|
|
|
|
|
|
signal uart0_ack_out : std_logic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Main memory signals:
|
|
|
|
-- Main memory signals:
|
|
|
|
signal wb_bram_in : wishbone_master_out;
|
|
|
|
signal wb_bram_in : wishbone_master_out;
|
|
|
|
signal wb_bram_out : wishbone_slave_out;
|
|
|
|
signal wb_bram_out : wishbone_slave_out;
|
|
|
|
constant mem_adr_bits : positive := positive(ceil(log2(real(MEMORY_SIZE))));
|
|
|
|
constant mem_adr_bits : positive := positive(ceil(log2(real(MEMORY_SIZE))));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Debug signals (used in SIM only)
|
|
|
|
|
|
|
|
signal registers : regfile;
|
|
|
|
|
|
|
|
signal terminate : std_ulogic;
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
|
|
-- Processor core
|
|
|
|
-- Processor core
|
|
|
|
processor: entity work.core
|
|
|
|
processor: entity work.core
|
|
|
|
|
|
|
|
generic map(
|
|
|
|
|
|
|
|
SIM => SIM
|
|
|
|
|
|
|
|
)
|
|
|
|
port map(
|
|
|
|
port map(
|
|
|
|
clk => system_clk,
|
|
|
|
clk => system_clk,
|
|
|
|
rst => rst,
|
|
|
|
rst => rst,
|
|
|
|
wishbone_insn_in => wishbone_icore_in,
|
|
|
|
wishbone_insn_in => wishbone_icore_in,
|
|
|
|
wishbone_insn_out => wishbone_icore_out,
|
|
|
|
wishbone_insn_out => wishbone_icore_out,
|
|
|
|
wishbone_data_in => wishbone_dcore_in,
|
|
|
|
wishbone_data_in => wishbone_dcore_in,
|
|
|
|
wishbone_data_out => wishbone_dcore_out
|
|
|
|
wishbone_data_out => wishbone_dcore_out,
|
|
|
|
|
|
|
|
registers => registers,
|
|
|
|
|
|
|
|
terminate_out => terminate
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- Wishbone bus master arbiter & mux
|
|
|
|
-- Wishbone bus master arbiter & mux
|
|
|
@ -77,8 +86,7 @@ begin
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- Wishbone slaves address decoder & mux
|
|
|
|
-- Wishbone slaves address decoder & mux
|
|
|
|
slave_intercon: process(wb_master_out, wb_bram_out,
|
|
|
|
slave_intercon: process(wb_master_out, wb_bram_out, wb_uart0_out)
|
|
|
|
uart0_ack_out, uart0_dat_out)
|
|
|
|
|
|
|
|
-- Selected slave
|
|
|
|
-- Selected slave
|
|
|
|
type slave_type is (SLAVE_UART,
|
|
|
|
type slave_type is (SLAVE_UART,
|
|
|
|
SLAVE_MEMORY,
|
|
|
|
SLAVE_MEMORY,
|
|
|
@ -98,22 +106,42 @@ begin
|
|
|
|
-- Wishbone muxing. Defaults:
|
|
|
|
-- Wishbone muxing. Defaults:
|
|
|
|
wb_bram_in <= wb_master_out;
|
|
|
|
wb_bram_in <= wb_master_out;
|
|
|
|
wb_bram_in.cyc <= '0';
|
|
|
|
wb_bram_in.cyc <= '0';
|
|
|
|
uart0_cyc_in <= '0';
|
|
|
|
wb_uart0_in <= wb_master_out;
|
|
|
|
|
|
|
|
wb_uart0_in.cyc <= '0';
|
|
|
|
case slave is
|
|
|
|
case slave is
|
|
|
|
when SLAVE_MEMORY =>
|
|
|
|
when SLAVE_MEMORY =>
|
|
|
|
wb_bram_in.cyc <= wb_master_out.cyc;
|
|
|
|
wb_bram_in.cyc <= wb_master_out.cyc;
|
|
|
|
wb_master_in <= wb_bram_out;
|
|
|
|
wb_master_in <= wb_bram_out;
|
|
|
|
when SLAVE_UART =>
|
|
|
|
when SLAVE_UART =>
|
|
|
|
uart0_cyc_in <= wb_master_out.cyc;
|
|
|
|
wb_uart0_in.cyc <= wb_master_out.cyc;
|
|
|
|
wb_master_in.ack <= uart0_ack_out;
|
|
|
|
wb_master_in <= wb_uart0_out;
|
|
|
|
wb_master_in.dat <= x"00000000000000" & uart0_dat_out;
|
|
|
|
|
|
|
|
when others =>
|
|
|
|
when others =>
|
|
|
|
wb_master_in.dat <= (others => '1');
|
|
|
|
wb_master_in.dat <= (others => '1');
|
|
|
|
wb_master_in.ack <= wb_master_out.stb and wb_master_out.cyc;
|
|
|
|
wb_master_in.ack <= wb_master_out.stb and wb_master_out.cyc;
|
|
|
|
end case;
|
|
|
|
end case;
|
|
|
|
end process slave_intercon;
|
|
|
|
end process slave_intercon;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Simulated memory and UART
|
|
|
|
|
|
|
|
sim_terminate_test: if SIM generate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Dump registers if core terminates
|
|
|
|
|
|
|
|
dump_registers: process(all)
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
if terminate = '1' then
|
|
|
|
|
|
|
|
loop_0: for i in 0 to 31 loop
|
|
|
|
|
|
|
|
report "REG " & to_hstring(registers(i));
|
|
|
|
|
|
|
|
end loop loop_0;
|
|
|
|
|
|
|
|
assert false report "end of test" severity failure;
|
|
|
|
|
|
|
|
end if;
|
|
|
|
|
|
|
|
end process;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end generate;
|
|
|
|
|
|
|
|
|
|
|
|
-- UART0 wishbone slave
|
|
|
|
-- UART0 wishbone slave
|
|
|
|
|
|
|
|
-- XXX FIXME: Need a proper wb64->wb8 adapter that
|
|
|
|
|
|
|
|
-- converts SELs into low address bits and muxes
|
|
|
|
|
|
|
|
-- data accordingly (either that or rejects large
|
|
|
|
|
|
|
|
-- cycles).
|
|
|
|
uart0: entity work.pp_soc_uart
|
|
|
|
uart0: entity work.pp_soc_uart
|
|
|
|
generic map(
|
|
|
|
generic map(
|
|
|
|
FIFO_DEPTH => 32
|
|
|
|
FIFO_DEPTH => 32
|
|
|
@ -123,22 +151,15 @@ begin
|
|
|
|
reset => rst,
|
|
|
|
reset => rst,
|
|
|
|
txd => uart0_txd,
|
|
|
|
txd => uart0_txd,
|
|
|
|
rxd => uart0_rxd,
|
|
|
|
rxd => uart0_rxd,
|
|
|
|
wb_adr_in => uart0_adr_in,
|
|
|
|
wb_adr_in => wb_uart0_in.adr(11 downto 0),
|
|
|
|
wb_dat_in => uart0_dat_in,
|
|
|
|
wb_dat_in => wb_uart0_in.dat(7 downto 0),
|
|
|
|
wb_dat_out => uart0_dat_out,
|
|
|
|
wb_dat_out => uart_dat8,
|
|
|
|
wb_cyc_in => uart0_cyc_in,
|
|
|
|
wb_cyc_in => wb_uart0_in.cyc,
|
|
|
|
wb_stb_in => uart0_stb_in,
|
|
|
|
wb_stb_in => wb_uart0_in.stb,
|
|
|
|
wb_we_in => uart0_we_in,
|
|
|
|
wb_we_in => wb_uart0_in.we,
|
|
|
|
wb_ack_out => uart0_ack_out
|
|
|
|
wb_ack_out => wb_uart0_out.ack
|
|
|
|
);
|
|
|
|
);
|
|
|
|
-- Wire it up: XXX FIXME: Need a proper wb64->wb8 adapter that
|
|
|
|
wb_uart0_out.dat <= x"00000000000000" & uart_dat8;
|
|
|
|
-- converts SELs into low address bits and muxes
|
|
|
|
|
|
|
|
-- data accordingly (either that or rejects large
|
|
|
|
|
|
|
|
-- cycles).
|
|
|
|
|
|
|
|
uart0_adr_in <= wb_master_out.adr(uart0_adr_in'range);
|
|
|
|
|
|
|
|
uart0_dat_in <= wb_master_out.dat(7 downto 0);
|
|
|
|
|
|
|
|
uart0_we_in <= wb_master_out.we;
|
|
|
|
|
|
|
|
uart0_stb_in <= wb_master_out.stb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- BRAM Memory slave
|
|
|
|
-- BRAM Memory slave
|
|
|
|
bram0: entity work.mw_soc_memory
|
|
|
|
bram0: entity work.mw_soc_memory
|