diff --git a/cpu_lattice.vhd b/cpu_lattice.vhd index 09cdfc7..bef48c8 100644 --- a/cpu_lattice.vhd +++ b/cpu_lattice.vhd @@ -5,9 +5,12 @@ use std.textio.all; use work.cpu2j0_pack.all; use work.data_bus_pkg.all; + +library sb_ice40_components_syn; +use sb_ice40_components_syn.components.all; + entity cpu_lattice is port ( - clk : in std_logic; - led : out std_logic_vector(7 downto 0)); + led : inout std_logic_vector(7 downto 0)); end; architecture behaviour of cpu_lattice is @@ -37,7 +40,7 @@ architecture behaviour of cpu_lattice is signal event_i : cpu_event_i_t := NULL_CPU_EVENT_I; signal event_o : cpu_event_o_t; --- signal clk : std_logic := '1'; + signal clk : std_logic := '1'; signal rst : std_logic := '1'; signal dummy : bit; @@ -46,6 +49,9 @@ architecture behaviour of cpu_lattice is signal pio_data_i : cpu_data_i_t := (ack => '0', d => (others => '0')); signal data_select : data_bus_device_t; signal db_we : std_logic_vector(3 downto 0); + + signal le : std_logic_vector(7 downto 0); + signal vh : std_logic; begin rst <= '1', '0' after 10 ns; @@ -57,6 +63,11 @@ begin -- wait for 10 ns; -- end process; + vh <= '1'; + + ck: SB_HFOSC generic map (clkhf_div => "0b10") + port map (clkhfen => vh, clkhf => clk, clkhfpu => vh); + process (data_master_o) variable dev : data_bus_device_t; begin @@ -120,6 +131,22 @@ begin db_o => data_slaves_i(DEV_SRAM)); -- intercept and print PIO and UART writes + + led(7 downto 3) <= le(7 downto 3); + + rgb: SB_RGBA_DRV generic map ( CURRENT_MODE => "0b1", + RGB0_CURRENT => "0b000001", + RGB1_CURRENT => "0b000001", + RGB2_CURRENT => "0b000001") + port map ( curren => '1', + rgbleden => '1', + rgb0pwm => le(0), + rgb1pwm => le(1), + rgb2pwm => le(2), + rgb0 => led(0), + rgb1 => led(1), + rgb2 => led(2)); + l0: process(clk) variable uart_line : line; variable l : line; @@ -130,7 +157,7 @@ begin -- write(l, string'("LED: Write ")); -- write(l, " at " & time'image(now)); -- writeline(output, l); - led <= pio_data_o.d(7 downto 0); + le <= pio_data_o.d(7 downto 0); end if; if data_slaves_o(DEV_UART0).wr = '1' and data_slaves_o(DEV_UART0).a = x"ABCD0104" then -- c := character'val(to_integer(unsigned(data_slaves_o(DEV_UART0).d(7 downto 0)))); diff --git a/ram.img b/ram.img index cd9d707..3f8d9d4 100755 Binary files a/ram.img and b/ram.img differ diff --git a/ram_init.vhd b/ram_init.vhd index 1a11391..7b01bbd 100644 --- a/ram_init.vhd +++ b/ram_init.vhd @@ -7,9 +7,9 @@ package bootrom is type rom_t is array (0 to 2047) of std_logic_vector(31 downto 0); constant rom : rom_t := ( x"0000010c", - x"000022f8", + x"00001ffc", x"0000010c", - x"000022f8", + x"00001ffc", x"00000d1a", x"00000cfa", x"00000d1a", @@ -102,12 +102,12 @@ package bootrom is x"410b6483", x"60834f26", x"000b68f6", - x"000010e4", + x"000010dc", x"d0034f22", x"400b0009", x"4f26000b", x"00090009", - x"000010fc", + x"000010f4", x"000b0009", x"d101412b", x"00090009", @@ -186,7 +186,7 @@ package bootrom is x"6bf66af6", x"69f6000b", x"68f60009", - x"0000119c", + x"00001194", x"2f86e800", x"2f966953", x"2fa66a53", @@ -232,7 +232,7 @@ package bootrom is x"68f60009", x"0000016c", x"000002d4", - x"0000119c", + x"00001194", x"00000184", x"2f862f96", x"2fa62fb6", @@ -334,8 +334,8 @@ package bootrom is x"68f60009", x"0000016c", x"000002d4", - x"00001148", - x"0000119c", + x"00001140", + x"00001194", x"2f862f96", x"2fa62fb6", x"2fc62fd6", @@ -526,15 +526,15 @@ package bootrom is x"00000184", x"0000016c", x"00000310", - x"00001154", + x"0000114c", x"00000d7c", x"000001e0", x"00000390", x"00000ed0", x"00000224", x"000002d4", - x"0000114c", - x"0000119c", + x"00001144", + x"00001194", x"00000fac", x"00000f40", x"00000d7c", @@ -631,12 +631,12 @@ package bootrom is x"00000390", x"00000f40", x"00000310", - x"00001158", - x"000011f4", + x"00001150", + x"000011ec", x"000001e0", x"00000d88", x"00001024", - x"00001154", + x"0000114c", x"2f862448", x"2f962fa6", x"2fb62fc6", @@ -706,12 +706,12 @@ package bootrom is x"68f60009", x"0000016c", x"000002d4", - x"000011c4", - x"000011b0", + x"000011bc", + x"000011a8", x"00000224", - x"0000116c", - x"00001170", - x"0000119c", + x"00001164", + x"00001168", + x"00001194", x"00000528", x"2f866043", x"2f964009", @@ -797,7 +797,7 @@ package bootrom is x"6af669f6", x"000b68f6", x"0000016c", - x"0000119c", + x"00001194", x"00000ed0", x"00000184", x"00000528", @@ -820,7 +820,7 @@ package bootrom is x"d00164f2", x"400b0009", x"00000b0c", - x"000012a4", + x"0000129c", x"2f062f16", x"e0f0400e", x"e0052f06", @@ -868,7 +868,7 @@ package bootrom is x"70c05101", x"6002002b", x"00090009", - x"0000124c", + x"00001244", x"ef046ff2", x"e0006002", x"402b0009", @@ -941,18 +941,18 @@ package bootrom is x"f80007ff", x"402b400b", x"c3200009", - x"0000128c", + x"00001284", x"0000fb00", x"00008900", x"00008b00", x"0000f000", x"0000a000", x"0000f0ff", - x"0000124c", + x"00001244", x"0000b000", x"0000ff00", x"0000c300", - x"000012a8", + x"000012a0", x"00000d3a", x"e1163416", x"8d2de000", @@ -980,8 +980,8 @@ package bootrom is x"5116e004", x"2512000b", x"00090009", - x"0000124c", - x"0000128c", + x"00001244", + x"00001284", x"e1163416", x"8d2ce000", x"6243c702", @@ -1007,13 +1007,13 @@ package bootrom is x"1154d103", x"1156e004", x"000b0009", - x"0000124c", - x"0000128c", + x"00001244", + x"00001284", x"24488901", x"d1021145", x"d102412b", x"00090009", - x"0000128c", + x"00001284", x"00000d3a", x"d1056211", x"22288904", @@ -1021,8 +1021,8 @@ package bootrom is x"2321e200", x"2121000b", x"00090009", - x"000012a8", - x"0000128c", + x"000012a0", + x"00001284", x"d001402b", x"00090009", x"000009dc", @@ -1036,8 +1036,8 @@ package bootrom is x"91032212", x"2312000b", x"00090088", - x"000011f8", - x"00001248", + x"000011f0", + x"00001240", x"abcd0000", x"000b0009", x"2f866843", @@ -1052,41 +1052,39 @@ package bootrom is x"60804f26", x"6af669f6", x"000b68f6", - x"000010e4", + x"000010dc", x"d1012142", x"000b0009", x"abcd0000", x"2f86e440", - x"2f962fa6", - x"ea00d817", + x"2f96d815", x"4f22480b", - x"7ffcd016", - x"d916400b", + x"7ffcd014", + x"d914400b", x"0009480b", - x"e442d415", + x"e442d413", x"490b0009", - x"d414490b", - x"0009e450", - x"480be900", - x"2fa2e209", - x"61f23127", - x"890461f2", - x"71012f12", - x"aff80009", + x"d412490b", + x"0009d912", + x"480be450", + x"e1002f12", + x"61f23197", + x"890261f2", + x"aff97101", x"480be455", - x"2f92e209", - x"61f23127", - x"890461f2", - x"71012f12", - x"aff80009", + x"e1002f12", + x"61f23197", + x"890261f2", + x"aff97101", x"9403480b", - x"0009afe5", - x"000900aa", + x"0009afea", + x"e10000aa", x"0000105c", - x"00001144", + x"0000113c", x"00001028", - x"000011d8", - x"000011fc", + x"000011d0", + x"000011f4", + x"0001869f", x"d104644c", x"5012c808", x"8bfcd102", @@ -1105,8 +1103,8 @@ package bootrom is x"64036083", x"4f26000b", x"68f60009", - x"000010fc", - x"000010e4", + x"000010f4", + x"000010dc", x"d102e202", x"1123000b", x"00090009", @@ -1143,11 +1141,11 @@ package bootrom is x"00000006", x"00000007", x"00000007", + x"0000116c", x"00001174", x"0000117c", x"00001184", x"0000118c", - x"00001194", x"47444220", x"53747562", x"20666f72", @@ -1162,17 +1160,17 @@ package bootrom is x"3a206368", x"616e6765", x"7365743a", - x"20202035", - x"3a353464", - x"33376335", - x"61373762", - x"300a6275", + x"20202036", + x"3a653964", + x"66303262", + x"33313236", + x"640a6275", x"696c643a", - x"204d6f6e", + x"20547565", x"204d6172", - x"20203420", - x"30313a31", - x"303a3438", + x"20203520", + x"30303a33", + x"373a3435", x"20455354", x"20323031", x"390a0000", diff --git a/testrom/main.c b/testrom/main.c index d3c4905..ad25394 100644 --- a/testrom/main.c +++ b/testrom/main.c @@ -104,9 +104,9 @@ main_sh (void) led(0x50); for (;;) { - for (i=0; i<10; i++) {} + for (i=0; i<100000; i++) {} led(0x55); - for (i=0; i<10; i++) {} + for (i=0; i<100000; i++) {} led(0xaa); } } diff --git a/testrom/startup/sh32.x b/testrom/startup/sh32.x index 4c6ba18..beb7253 100644 --- a/testrom/startup/sh32.x +++ b/testrom/startup/sh32.x @@ -7,8 +7,8 @@ OUTPUT_ARCH(sh) MEMORY { - ram : o = 0x00000000, l = 0x1c00 - stack : o = 0x00001ffc, l = 0x03fc + ram : o = 0x00000000, l = 0x1d00 + stack : o = 0x00001d00, l = 0x0300 } SECTIONS