From c30e3b9f2e5bb47e55390fbe91e4adc7b0674736 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sun, 9 Jan 2011 14:07:05 +0100 Subject: [PATCH] cyclon: response \o/ howto: gtkterm auf /dev/ttyS0 (@9600) --- 3_test/uartint.s | 12 ++---- cpu/src/extension_uart_b.vhd | 3 +- cpu/src/extension_uart_pkg.vhd | 2 +- cpu/src/fetch_stage_b.vhd | 7 +-- cpu/src/rom_b.vhd | 78 +++++++++++++++++----------------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/3_test/uartint.s b/3_test/uartint.s index f1033f1..8f4975e 100644 --- a/3_test/uartint.s +++ b/3_test/uartint.s @@ -13,6 +13,10 @@ main: br+ start ; stwnv r5, 0(r4) uartrdy: + ldw r7, 0(r2) + xor r10, r10, r10 + ldi r10, 0x41 + stw r10, 0(r1) ;TODO: remove plz, kkthx ; load instructions into ram ldi r8, 0x2034 ; paddr ldi r9, 0x2038 ; pdata @@ -26,7 +30,6 @@ uartrdy: ; call+ main ; ret ;main: - ; ldw r7, 0(r2) ; stw r7, 0(r1) ;halt: ; br+ halt @@ -51,13 +54,6 @@ uartrdy: ldi r11, 0x8 ldih r11, 0xeb00 stw r11, 0(r9) - ;e7390000;ldw r7, 0(r2);; - xor r10, r10, r10 - ldi r10, 3 - stw r10, 0(r8) - ldi r11, 0x0 - ldih r11, 0xeb00 - stw r11, 0(r9) ;e7b88000;stw r7, 0(r1);; xor r10, r10, r10 ldi r10, 4 diff --git a/cpu/src/extension_uart_b.vhd b/cpu/src/extension_uart_b.vhd index fed2914..d00274f 100644 --- a/cpu/src/extension_uart_b.vhd +++ b/cpu/src/extension_uart_b.vhd @@ -70,8 +70,7 @@ begin if (reset = RESET_VALUE) then w1_st_co <= (others=>'0'); w2_uart_config(31 downto 16) <= (others=>'0'); - -- todo mit einer konstante versehen - w2_uart_config(15 downto 0) <= std_logic_vector(unsigned(CLK_PER_BAUD)); -- x"01B2"; + w2_uart_config(15 downto 0) <= std_logic_vector(to_unsigned(CLK_PER_BAUD, 16)); -- x"0822"; -- x"01B2"; w3_uart_send <= (others=>'0'); w4_uart_receive <= (others=>'0'); tx_rdy_int <= '0'; diff --git a/cpu/src/extension_uart_pkg.vhd b/cpu/src/extension_uart_pkg.vhd index 49b46ec..9a2a52f 100644 --- a/cpu/src/extension_uart_pkg.vhd +++ b/cpu/src/extension_uart_pkg.vhd @@ -23,7 +23,7 @@ subtype baud_rate_l is std_logic_vector(BAUD_RATE_WIDTH-1 downto 0); --constant BAUD_RATE : integer := 115200; --constant CLK_PER_BAUD : integer := integer((CLK_FREQ_MHZ * 1000000.0) / real(BAUD_RATE) - 0.5); -- constant CLK_PER_BAUD : integer := 434; -constant CLK_PER_BAUD : integer := 173; -- @uni, bei 20MHz und 115200 Baud +constant CLK_PER_BAUD : integer := 2083; -- @uni, bei 20MHz und 9600 Baud component extension_uart is --some modules won't need all inputs/outputs diff --git a/cpu/src/fetch_stage_b.vhd b/cpu/src/fetch_stage_b.vhd index 6ad9157..fb0e7fd 100644 --- a/cpu/src/fetch_stage_b.vhd +++ b/cpu/src/fetch_stage_b.vhd @@ -64,7 +64,7 @@ end process; asyn: process(reset, instr_r_addr, jump_result, prediction_result, branch_prediction_bit, alu_jump_bit, instr_rd_data, rom_ram, instr_rd_data_rom, int_req) - +variable instr_pc : instruction_addr_t; begin rom_ram_nxt <= rom_ram; @@ -76,9 +76,10 @@ begin when others => instruction <= x"F0000000"; end case; - instr_r_addr_nxt <= std_logic_vector(unsigned(instr_r_addr) + 1); + instr_pc := std_logic_vector(unsigned(instr_r_addr) + 1); + instr_r_addr_nxt <= instr_pc; - if (instr_r_addr(ROM_INSTR_ADDR_WIDTH) = '1' and rom_ram = ROM_USE) then + if (instr_pc = x"0000007f" and rom_ram = ROM_USE) then rom_ram_nxt <= RAM_USE; -- TODO: wenn genau auf adresse 0 im RAM ein br steht kracht es... :/ instr_r_addr_nxt <= x"00000000"; diff --git a/cpu/src/rom_b.vhd b/cpu/src/rom_b.vhd index 5de4d84..7f551ed 100644 --- a/cpu/src/rom_b.vhd +++ b/cpu/src/rom_b.vhd @@ -123,7 +123,7 @@ begin -- when "00000000111" => data_out <= x"e7a00004"; -- when "00000001000" => data_out <= x"e7280004"; -- -- when "00000001001" => data_out <= x"eb7ffb81"; - when "0000000" => data_out <= x"eb000181"; -- br- main + when "0000000" => data_out <= x"eb000183"; -- br+ main when "0000001" => data_out <= x"eb000487"; -- call+ uartrdy when "0000010" => data_out <= x"eb000008"; -- ret when "0000011" => data_out <= x"ed090058"; -- ldi r1, 0x200b @@ -133,45 +133,43 @@ begin when "0000111" => data_out <= x"ed280018"; -- ldi r5, 3 when "0001000" => data_out <= x"e7aa0000"; -- stw r5, 0(r4) when "0001001" => data_out <= x"eb7ffb83"; -- br+ start - when "0001010" => data_out <= x"ed4101a0"; -- ldi r8, 0x2034 - when "0001011" => data_out <= x"ed4901c0"; -- ldi r9, 0x2038 - when "0001100" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0001101" => data_out <= x"e45dd800"; -- xor r11, r11, r11 - when "0001110" => data_out <= x"ed500000"; -- ldi r10, 0 - when "0001111" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0010000" => data_out <= x"ed580c18"; -- ldi r11, 0x0183 - when "0010001" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 - when "0010010" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) - when "0010011" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0010100" => data_out <= x"ed500008"; -- ldi r10, 1 - when "0010101" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0010110" => data_out <= x"ed580838"; -- ldi r11, 0x107 - when "0010111" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 - when "0011000" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) - when "0011001" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0011010" => data_out <= x"ed500010"; -- ldi r10, 2 - when "0011011" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0011100" => data_out <= x"ed580040"; -- ldi r11, 0x8 - when "0011101" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 - when "0011110" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) - when "0011111" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0100000" => data_out <= x"ed500018"; -- ldi r10, 3 - when "0100001" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0100010" => data_out <= x"ed580000"; -- ldi r11, 0x0 - when "0100011" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 - when "0100100" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) - when "0100101" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0100110" => data_out <= x"ed500020"; -- ldi r10, 4 - when "0100111" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0101000" => data_out <= x"ed5c0000"; -- ldi r11, 0x8000 - when "0101001" => data_out <= x"ed5f3dc2"; -- ldih r11, 0xe7b8 - when "0101010" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) - when "0101011" => data_out <= x"e4555000"; -- xor r10, r10, r10 - when "0101100" => data_out <= x"ed500028"; -- ldi r10, 5 - when "0101101" => data_out <= x"e7d40000"; -- stw r10, 0(r8) - when "0101110" => data_out <= x"ed580018"; -- ldi r11, 0x3 - when "0101111" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 - when "0110000" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) + when "0001010" => data_out <= x"e7390000"; -- ldw r7, 0(r2) + when "0001011" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0001100" => data_out <= x"ed500208"; -- ldi r10, 0x41 + when "0001101" => data_out <= x"e7d08000"; -- stw r10, 0(r1) + when "0001110" => data_out <= x"ed4101a0"; -- ldi r8, 0x2034 + when "0001111" => data_out <= x"ed4901c0"; -- ldi r9, 0x2038 + when "0010000" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0010001" => data_out <= x"e45dd800"; -- xor r11, r11, r11 + when "0010010" => data_out <= x"ed500000"; -- ldi r10, 0 + when "0010011" => data_out <= x"e7d40000"; -- stw r10, 0(r8) + when "0010100" => data_out <= x"ed580c18"; -- ldi r11, 0x0183 + when "0010101" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 + when "0010110" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) + when "0010111" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0011000" => data_out <= x"ed500008"; -- ldi r10, 1 + when "0011001" => data_out <= x"e7d40000"; -- stw r10, 0(r8) + when "0011010" => data_out <= x"ed580838"; -- ldi r11, 0x107 + when "0011011" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 + when "0011100" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) + when "0011101" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0011110" => data_out <= x"ed500010"; -- ldi r10, 2 + when "0011111" => data_out <= x"e7d40000"; -- stw r10, 0(r8) + when "0100000" => data_out <= x"ed580040"; -- ldi r11, 0x8 + when "0100001" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 + when "0100010" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) + when "0100011" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0100100" => data_out <= x"ed500020"; -- ldi r10, 4 + when "0100101" => data_out <= x"e7d40000"; -- stw r10, 0(r8) + when "0100110" => data_out <= x"ed5c0000"; -- ldi r11, 0x8000 + when "0100111" => data_out <= x"ed5f3dc2"; -- ldih r11, 0xe7b8 + when "0101000" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) + when "0101001" => data_out <= x"e4555000"; -- xor r10, r10, r10 + when "0101010" => data_out <= x"ed500028"; -- ldi r10, 5 + when "0101011" => data_out <= x"e7d40000"; -- stw r10, 0(r8) + when "0101100" => data_out <= x"ed580018"; -- ldi r11, 0x3 + when "0101101" => data_out <= x"ed5f5802"; -- ldih r11, 0xeb00 + when "0101110" => data_out <= x"e7dc8000"; -- stw r11, 0(r9) -- just nop until rom end! when others => data_out <= x"fd000000"; end case; -- 2.25.1