OpenCores
URL https://opencores.org/ocsvn/neo430/neo430/trunk

Subversion Repositories neo430

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /neo430/trunk
    from Rev 137 to Rev 138
    Reverse comparison

Rev 137 → Rev 138

/rtl/cfu_templates/multiplier/cfu_mac16.h File deleted \ No newline at end of file
/LICENSE File deleted
/doc/wbspec_b4.pdf File deleted
/doc/NEO430.pdf Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
doc/NEO430.pdf Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: doc/figures/neo430_arch.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: doc/figures/neo430_arch.png =================================================================== --- doc/figures/neo430_arch.png (revision 137) +++ doc/figures/neo430_arch.png (nonexistent)
doc/figures/neo430_arch.png Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: doc/figures/test_setup.jpg =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: doc/figures/test_setup.jpg =================================================================== --- doc/figures/test_setup.jpg (revision 137) +++ doc/figures/test_setup.jpg (nonexistent)
doc/figures/test_setup.jpg Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: doc/figures/mem_layout.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: doc/figures/mem_layout.png =================================================================== --- doc/figures/mem_layout.png (revision 137) +++ doc/figures/mem_layout.png (nonexistent)
doc/figures/mem_layout.png Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: doc/figures/oshw_logo.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: doc/figures/oshw_logo.png =================================================================== --- doc/figures/oshw_logo.png (revision 137) +++ doc/figures/oshw_logo.png (nonexistent)
doc/figures/oshw_logo.png Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: sim/modelsim/wave.do =================================================================== --- sim/modelsim/wave.do (revision 137) +++ sim/modelsim/wave.do (nonexistent) @@ -1,132 +0,0 @@ -onerror {resume} -quietly WaveActivateNextPane {} 0 - -add wave -noupdate -divider Global -add wave -noupdate /neo430_tb/neo430_top_inst/clk_i -add wave -noupdate /neo430_tb/neo430_top_inst/clk_gen -add wave -noupdate /neo430_tb/neo430_top_inst/rst_i -add wave -noupdate /neo430_tb/neo430_top_inst/rst_gen -add wave -noupdate /neo430_tb/neo430_top_inst/rst_gen_sync -add wave -noupdate /neo430_tb/neo430_top_inst/ext_rst -add wave -noupdate /neo430_tb/neo430_top_inst/sys_rst - -add wave -noupdate -divider CPUControl -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/ir -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_buf -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_ack -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_start -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_run -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/irq_ret -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/am -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/state -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_control_inst/ctrl_o - -add wave -noupdate -divider CPU_Regfile -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_reg_file_inst/sreg -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_reg_file_inst/reg_file - -add wave -noupdate -divider CPU_ALU -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_alu_inst/op_a_ff -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_alu_inst/op_b_ff -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_alu_inst/alu_res -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_addr_gen_inst/mem_addr_reg -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_addr_gen_inst/mem_addr_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_addr_gen_inst/irq_sel_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/neo430_addr_gen_inst/imm_i - -add wave -noupdate -divider Bus_Interface -add wave -noupdate /neo430_tb/neo430_top_inst/io_acc -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/mem_rd_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/mem_wr_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/mem_addr_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/mem_data_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_cpu_inst/mem_data_i - -add wave -noupdate -divider Main_Memory -add wave -noupdate /neo430_tb/neo430_top_inst/imem_up_en -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_imem_inst/imem_init_file -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_imem_inst/imem_file_h -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_imem_inst/imem_file_l -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_dmem_inst/dmem_file - -add wave -noupdate -divider Bootloader_ROM -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_boot_rom_inst_true/neo430_boot_rom_inst/boot_img - -add wave -noupdate -divider IO_USART -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/baud -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/ctrl -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_busy -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_sclk_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_mosi_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_miso_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_cs_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/spi_rtx_sreg -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_tx_sreg -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_tx_busy -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_txd_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_rx_busy -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_rx_reg -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_rx_avail -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/uart_rxd_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_usart_inst_true/neo430_usart_inst/usart_irq_o - -add wave -noupdate -divider IO_Timer -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_timer_inst_true/neo430_timer_inst/tctrl -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_timer_inst_true/neo430_timer_inst/thres -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_timer_inst_true/neo430_timer_inst/tcnt -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_timer_inst_true/neo430_timer_inst/irq_o - -add wave -noupdate -divider IO_GPIO -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_gpio_inst_true/neo430_gpio_inst/trigger -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_gpio_inst_true/neo430_gpio_inst/gpio_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_gpio_inst_true/neo430_gpio_inst/gpio_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_gpio_inst_true/neo430_gpio_inst/irq_o - -add wave -noupdate IO_Watchdog -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/wren -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/enable -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/clk_sel -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/cnt -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/rst_gen -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/rst_sync -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/rst_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wdt_inst_true/neo430_wdt_inst/source - -add wave -noupdate -divider IO_Wishbone -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/enable -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/pending -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/pipelined -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/terr -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_adr_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_dat_i -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_dat_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_we_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_sel_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_stb_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_cyc_o -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_wb32_if_inst_true/neo430_wb32_inst/wb_ack_i - -add wave -noupdate -divider IO_Sysconfig -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_sysconfig_inst/sysinfo_mem -add wave -noupdate /neo430_tb/neo430_top_inst/neo430_sysconfig_inst/sysconfig_mem - - -TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {92 ps} 0} -quietly wave cursor active 1 -configure wave -namecolwidth 150 -configure wave -valuecolwidth 100 -configure wave -justifyvalue left -configure wave -signalnamewidth 1 -configure wave -snapdistance 10 -configure wave -datasetprefix 0 -configure wave -rowmargin 4 -configure wave -childrowmargin 2 -configure wave -gridoffset 0 -configure wave -gridperiod 1 -configure wave -griddelta 40 -configure wave -timeline 0 -configure wave -timelineunits ps -update -WaveRestoreZoom {0 ps} {1 ns} Index: sim/modelsim/simulate.do =================================================================== --- sim/modelsim/simulate.do (revision 137) +++ sim/modelsim/simulate.do (nonexistent) @@ -1,38 +0,0 @@ -puts {NEO430 Modelsim Simulation Script} - --- set up sources -- -set sim_src ".." -set rtl_src "../../rtl/core" - -quit -sim - --- compile sources -- -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_package.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_application_image.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_bootloader_image.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_addr_gen.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_alu.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_boot_rom.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_control.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_cpu.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_dmem.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_imem.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_gpio.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_reg_file.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_sysconfig.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_timer.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_top.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_usart.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_wb_interface.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${rtl_src}/neo430_wdt.vhd -vcom -work work -2002 -explicit -nocasestaticerror ${sim_src}/neo430_tb.vhd - --- start simulation -- -vsim -t 1ps work.neo430_tb - --- waveform configuration -- -do ${sim_src}/modelsim/wave.do - --- run -- -run 200 us - Index: sim/neo430_tb.vhd =================================================================== --- sim/neo430_tb.vhd (revision 137) +++ sim/neo430_tb.vhd (nonexistent) @@ -1,191 +0,0 @@ --- ################################################################################################# --- # << NEO430 - Simple testbench >> # --- # ********************************************************************************************* # --- # This simple testbench instantiates the top entity of the NEO430 processors, generates clock # --- # and reset signals and outputs data send via the processor's UART to the simulator console. # --- # ********************************************************************************************* # --- # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # --- # Copyright by Stephan Nolting: stnolting@gmail.com # --- # # --- # This source file may be used and distributed without restriction provided that this copyright # --- # statement is not removed from the file and that any derivative work contains the original # --- # copyright notice and the associated disclaimer. # --- # # --- # This source file is free software; you can redistribute it and/or modify it under the terms # --- # of the GNU Lesser General Public License as published by the Free Software Foundation, # --- # either version 3 of the License, or (at your option) any later version. # --- # # --- # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # --- # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # --- # See the GNU Lesser General Public License for more details. # --- # # --- # You should have received a copy of the GNU Lesser General Public License along with this # --- # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # --- # ********************************************************************************************* # --- # Stephan Nolting, Hanover, Germany 21.07.2017 # --- ################################################################################################# - -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; -use ieee.math_real.all; - -library work; -use work.neo430_package.all; -use std.textio.all; - -entity neo430_tb is -end neo430_tb; - -architecture neo430_tb_rtl of neo430_tb is - - -- User Configuration --------------------------------------------------------------------- - -- ------------------------------------------------------------------------------------------- - constant t_clock_c : time := 10 ns; -- main clock period - constant f_clock_c : real := 100000000.0; -- main clock in Hz - constant baud_rate_c : real := 19200.0; -- standard UART baudrate - -- ------------------------------------------------------------------------------------------- - - -- internal configuration -- - constant baud_val_c : real := f_clock_c / baud_rate_c; - constant f_clk_c : natural := natural(f_clock_c); - - -- reduced ASCII table -- - type ascii_t is array (0 to 94) of character; - constant ascii_lut : ascii_t := (' ', '!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', - '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', - 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', - 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', - 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'); - - -- generators -- - signal clk_gen, rst_gen : std_ulogic := '0'; - - -- local signals -- - signal uart_txd : std_ulogic; - signal spi_data : std_ulogic; - - -- simulation uart receiver -- - signal uart_rx_sync : std_ulogic_vector(04 downto 0) := (others => '1'); - signal uart_rx_busy : std_ulogic := '0'; - signal uart_rx_sreg : std_ulogic_vector(08 downto 0) := (others => '0'); - signal uart_rx_baud_cnt : real; - signal uart_rx_bitcnt : natural; - -begin - - -- Clock/Reset Generator ---------------------------------------------------- - -- ----------------------------------------------------------------------------- - clk_gen <= not clk_gen after (t_clock_c/2); - rst_gen <= '0', '1' after 60*(t_clock_c/2); - - - -- CPU Core ----------------------------------------------------------------- - -- ----------------------------------------------------------------------------- - neo430_top_inst: neo430_top - generic map ( - -- general configuration -- - CLOCK_SPEED => f_clk_c, -- main clock in Hz - IMEM_SIZE => 4*1024, -- internal IMEM size in bytes, max 32kB (default=4kB) - DMEM_SIZE => 2*1024, -- internal DMEM size in bytes, max 28kB (default=2kB) - -- additional configuration -- - USER_CODE => x"4788", -- custom user code - -- module configuration -- - DADD_USE => true, -- implement DADD instruction? (default=true) - CFU_USE => true, -- implementcustom function unit? (default=false) - WB32_USE => true, -- implement WB32 unit? (default=true) - WDT_USE => true, -- implement WBT? (default=true) - GPIO_USE => true, -- implement GPIO unit? (default=true) - TIMER_USE => true, -- implement timer? (default=true) - USART_USE => true, -- implement USART? (default=true) - -- boot configuration -- - BOOTLD_USE => true, -- implement and use bootloader? (default=true) - IMEM_AS_ROM => false -- implement IMEM as read-only memory? (default=false) - ) - port map ( - -- global control -- - clk_i => clk_gen, -- global clock, rising edge - rst_i => rst_gen, -- global reset, async, low-active - -- gpio -- - gpio_o => open, -- parallel output - gpio_i => x"0000", -- parallel input - -- serial com -- - uart_txd_o => uart_txd, -- UART send data - uart_rxd_i => '0', -- UART receive data - spi_sclk_o => open, -- serial clock line - spi_mosi_o => spi_data, -- serial data line out - spi_miso_i => spi_data, -- serial data line in - spi_cs_o => open, -- SPI CS 0..5 - -- 32-bit wishbone interface -- - wb_adr_o => open, -- address - wb_dat_i => x"00000000", -- read data - wb_dat_o => open, -- write data - wb_we_o => open, -- read/write - wb_sel_o => open, -- byte enable - wb_stb_o => open, -- strobe - wb_cyc_o => open, -- valid cycle - wb_ack_i => '0', -- transfer acknowledge - -- external interrupt -- - irq_i => '0', -- external interrupt request line - irq_ack_o => open -- external interrupt request acknowledge - ); - - - -- Dummy UART Receiver ------------------------------------------------------ - -- ----------------------------------------------------------------------------- - uart_rx_unit: process(clk_gen) - variable i, j : integer; - file uart_rx_file : text open write_mode is "uart_rx_dump.txt"; - variable line_tmp : line; - begin - if rising_edge(clk_gen) then - -- synchronizer -- - uart_rx_sync <= uart_rx_sync(3 downto 0) & uart_txd; - -- arbiter -- - if (uart_rx_busy = '0') then -- idle - uart_rx_busy <= '0'; - uart_rx_baud_cnt <= round(0.5 * baud_val_c); - uart_rx_bitcnt <= 9; - if (uart_rx_sync(4 downto 1) = "1100") then -- start bit? (falling edge) - uart_rx_busy <= '1'; - end if; - else - if (uart_rx_baud_cnt = 0.0) then - -- adapt to the inter-frame pause - which is not implemented in the neo430 uart ;) - if (uart_rx_bitcnt = 1) then - uart_rx_baud_cnt <= round(0.5 * baud_val_c); - else - uart_rx_baud_cnt <= round(baud_val_c); - end if; - if (uart_rx_bitcnt = 0) then - uart_rx_busy <= '0'; -- done - i := to_integer(unsigned(uart_rx_sreg(8 downto 1))); - j := i - 32; - if (j < 0) or (j > 95) then - j := 0; -- undefined = SPACE - end if; - - if (i < 32) or (j > 32+95) then - report "UART TX: (" & integer'image(i) & ")"; -- print code - else - report "UART TX: " & ascii_lut(j); -- print ASCII - end if; - - if (i = 10) then -- Linux line break - writeline(uart_rx_file, line_tmp); - elsif (i /= 13) then -- Remove additional carriage return - write(line_tmp, ascii_lut(j)); - end if; - else - uart_rx_sreg <= uart_rx_sync(4) & uart_rx_sreg(8 downto 1); - uart_rx_bitcnt <= uart_rx_bitcnt - 1; - end if; - else - uart_rx_baud_cnt <= uart_rx_baud_cnt - 1.0; - end if; - end if; - end if; - end process uart_rx_unit; - - -end neo430_tb_rtl; Index: sim/ISIM/neo430_tb.wcfg =================================================================== --- sim/ISIM/neo430_tb.wcfg (revision 137) +++ sim/ISIM/neo430_tb.wcfg (nonexistent) @@ -1,453 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Global - label - - - clk_i - clk_i - - - clk_gen[7:0] - clk_gen[7:0] - - - rst_i - rst_i - - - rst_gen[3:0] - rst_gen[3:0] - BINARYRADIX - - - rst_gen_sync[1:0] - rst_gen_sync[1:0] - BINARYRADIX - - - ext_rst - ext_rst - - - sys_rst - sys_rst - - - CPU - Control - label - - - irq_i[3:0] - irq_i[3:0] - - - irq_buf[3:0] - irq_buf[3:0] - - - irq_ack - irq_ack - - - irq_start - irq_start - - - irq_run - irq_run - - - irq_ret - irq_ret - - - am[3:0] - am[3:0] - BINARYRADIX - - - ir[15:0] - ir[15:0] - - - state - state - - - ctrl_o[28:0] - ctrl_o[28:0] - - - CPU - RF - label - - - sreg[15:0] - sreg[15:0] - - - reg_file[15:0][15:0] - reg_file[15:0][15:0] - - - CPU - ALU - label - - - op_a_ff[15:0] - op_a_ff[15:0] - HEXRADIX - - - op_b_ff[15:0] - op_b_ff[15:0] - HEXRADIX - - - alu_res[15:0] - alu_res[15:0] - HEXRADIX - - - CPU - Address Generator - label - - - mem_addr_reg[15:0] - mem_addr_reg[15:0] - - - mem_addr_o[15:0] - mem_addr_o[15:0] - - - irq_sel_i[1:0] - irq_sel_i[1:0] - - - imm_i[15:0] - imm_i[15:0] - - - CPU - BUS Interface - label - - - io_acc - io_acc - - - mem_rd_o - mem_rd_o - - - mem_wr_o[1:0] - mem_wr_o[1:0] - - - mem_addr_o[15:0] - mem_addr_o[15:0] - HEXRADIX - - - mem_data_o[15:0] - mem_data_o[15:0] - - - mem_data_i[15:0] - mem_data_i[15:0] - - - Main Memory - label - - - imem_up_en - imem_up_en - - - imem_init_file[0:2047][15:0] - imem_init_file[0:2047][15:0] - - - imem_file_h[0:2047][7:0] - imem_file_h[0:2047][7:0] - - - imem_file_l[0:2047][7:0] - imem_file_l[0:2047][7:0] - - - dmem_file[0:1023][15:0] - dmem_file[0:1023][15:0] - - - Bootloader ROM - label - - - IO: USART - label - - - baud[7:0] - baud[7:0] - UNSIGNEDDECRADIX - - - ctrl[15:0] - ctrl[15:0] - HEXRADIX - - - spi_busy - spi_busy - - - spi_sclk_o - spi_sclk_o - - - spi_mosi_o - spi_mosi_o - - - spi_miso_i - spi_miso_i - - - spi_cs_o[5:0] - spi_cs_o[5:0] - - - spi_rtx_sreg[7:0] - spi_rtx_sreg[7:0] - - - uart_tx_sreg[9:0] - uart_tx_sreg[9:0] - - - uart_tx_busy - uart_tx_busy - - - uart_txd_o - uart_txd_o - - - uart_rx_busy - uart_rx_busy - - - uart_rx_reg[7:0] - uart_rx_reg[7:0] - ASCIIRADIX - - - uart_rx_avail - uart_rx_avail - - - uart_rxd_i - uart_rxd_i - - - usart_irq_o - usart_irq_o - - - IO: Timer - label - - - tctrl[5:0] - tctrl[5:0] - - - thres[15:0] - thres[15:0] - HEXRADIX - - - tcnt[15:0] - tcnt[15:0] - HEXRADIX - - - irq_o - irq_o - - - IO: GPIO - label - - - gpio_o[15:0] - gpio_o[15:0] - - - gpio_i[15:0] - gpio_i[15:0] - - - irq_o - irq_o - - - IO: Watchdog - label - - - wren - wren - - - enable - enable - - - clk_sel[2:0] - clk_sel[2:0] - - - cnt[16:0] - cnt[16:0] - - - rst_gen[3:0] - rst_gen[3:0] - - - rst_sync[1:0] - rst_sync[1:0] - - - rst_o - rst_o - - - source - source - - - IO: Wishbone Bus Interface - label - - - enable - enable - - - pending - pending - - - pipelined - pipelined - - - wb_adr_o[31:0] - wb_adr_o[31:0] - - - wb_dat_i[31:0] - wb_dat_i[31:0] - - - wb_dat_o[31:0] - wb_dat_o[31:0] - - - wb_we_o - wb_we_o - - - wb_sel_o[3:0] - wb_sel_o[3:0] - BINARYRADIX - - - wb_stb_o - wb_stb_o - - - wb_cyc_o - wb_cyc_o - - - wb_ack_i - wb_ack_i - - - Sysconfig - label - - - sysinfo_mem[0:7][15:0] - sysinfo_mem[0:7][15:0] - - - irqvec_mem[0:3][15:0] - irqvec_mem[0:3][15:0] - - - acc_en - acc_en - - - CFU - label - - - user_reg0[15:0] - user_reg0[15:0] - - - user_reg1[15:0] - user_reg1[15:0] - - - user_reg2[15:0] - user_reg2[15:0] - - - user_reg3[15:0] - user_reg3[15:0] - - - user_reg4[15:0] - user_reg4[15:0] - - - user_reg5[15:0] - user_reg5[15:0] - - - user_reg6[15:0] - user_reg6[15:0] - - - user_reg7[15:0] - user_reg7[15:0] - - Index: README.md =================================================================== --- README.md (revision 137) +++ README.md (nonexistent) @@ -1,146 +0,0 @@ -## Introduction - -Welcome to the __NEO430 Processor__ project! - -You need a small but still powerful, customizable and microcontroller-like -processor system for your next FPGA design? Then the NEO430 is the perfect -choice for you! - -This processor is based on the Texas Instruments MSP430(TM) ISA and provides 100% -compatibility with the original instruction set. The NEO430 is not an MSP430 -clone – it is more a complete new implementation from the bottom up. The -processor features a very small outline, already implementing standard -features like a timer, a watchdog, UART and SPI serial interfaces, general -purpose IO ports, an internal bootloader and of course internal memory for -program code and data. All of the peripheral modules are optional – so if you -do not need them, you can exclude them from implementation to reduce the size -of the system. Any additional modules, which make a more customized system, -can be connected via a Wishbone-compatible bus interface. By this, you can -built a system, that perfectly fits your needs. - -It is up to you to use the NEO430 as stand-alone, configurable and extensible -microcontroller, or to include it as controller within a more complex SoC -design. - -The high-level software development is based on the free TI msp430-gcc -compiler tool chain. You can either use Windows or Linux/Cygwin as build -environment for your applications – the project comes with build scripts -for both worlds. The example folder of this project features several demo -programs, from which you can start creating your own NEO430 applications. - -This project is intended to work "out of the box". Just synthesize the test -setup from this project, upload it to your FPGA board of choice and start -exploring the capabilities of the NEO430 processor. Application program -generation (and even installation) works by executing a single "make" command. -Jump to the "Let’s Get It Started" chapter, which provides a lot of guides and -tutorials to make your first NEO430 setup run: -https://github.com/stnolting/neo430/blob/master/doc/NEO430.pdf - - -## Processor Features - - -(optional modules are marked using dashed lines) - - -- 16-bit open source soft-core microcontroller-like processor system -- Code-efficient CISC-like instruction capabilities -- Full support of the original MSP430 instruction set architecture -- Tool chain based on free TI msp430-gcc compiler -- Application compilation scripts for Windows and Linux/Cygwin -- Completely described in behavioral, platform-independent VHDL -- Fully synchronous design, no latches, no gated clocks -- Very small outline and high operating frequency compared to other implementations ;) -- Internal DMEN (RAM, for data) and IMEM (RAM or ROM, for code), configurable sizes -- One external interrupt line -- Customizable processor hardware configuration -- Optional multiplier/divider unit (MULDIV) -- Optional high-precision timer (TIMER) -- Optional USART interface; UART and SPI in parallel (USART) -- Optional general purpose parallel IO port (GPIO), 16 inputs, 16 outputs, with pin-change interrupt -- Optional 32-bit Wishbone bus interface adapter (WB32) - including bridges to Avalon(TM) bus and AXI-Lite(TM) -- Optional watchdog timer (WDT) -- Optional cyclic redundancy check unit (CRC16/32) -- Optional custom functions unit (CFU) for user-defined processor extensions -- Optional 3 channel 8-bit PWM controller -- Optional internal bootloader (2kB ROM) with serial user console and automatic boot from external EEPROM - - -## Differences to TI's Original MSP430(TM) Processors - -- Completely different processor modules with different functionality -- Maximum of 32kB instruction memory and 28kB data memory -- Specific memory map – included NEO430 linker script and compilation script required -- Custom binary executable format -- Only 4 CPU interrupt channels (instead of 16) -- Single clock domain for complete processor -- Different numbers of instruction execution cycles -- Only one power-down (sleep) mode -- Wishbone-compatible interface to attach custom IP -- Internal bootloader with text interface (via UART serial port) - - -## Implementation Results - -Mapping results generated for HW version 0x0170. The full (default) configuration includes -all optional processor modules. - -| __Xilinx Virtex-6__ | LUTs | FFs | BRAMs | DSPs | f_max | -|-------------------------------------|:----:|-----|-------|------|---------| -| Full (default) configuration: | TBA | TBA | 4 | 0 | TBA MHz | -| Minimal configuration (CPU + GPIO): | TBA | TBA | 3 | 0 | TBA MHz | - -| __Intel/Altera Cyclone IV__ | LUTs | FFs | Memory bits | DSPs | f_max | -|-------------------------------------|:----:|-----|-------------|------|---------| -| Full (default) configuration: | 1588 | 868 | 65792 | 0 | 115 MHz | -| Minimal configuration (CPU + GPIO): | 614 | 232 | 49408 | 0 | 120 MHz | - - -## Let's Get It Started! - - * At first, make sure to get the most recent version of this project from GitHub: - - ~~~ - git clone https://github.com/stnolting/neo430.git - ~~~ - - * Next, install the compiler toolchain from the TI homepage (select the "compiler only" package): - - http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/latest/index_FDS.html - - * Follow the instructions from the "Let's Get It Started" section of the NEO430 documentary: - - https://github.com/stnolting/neo430/blob/master/doc/NEO430.pdf - - * The NEO430 documentary will guide you to create a simple test setup, which serves as "hello world" FPGA demo: - - - - * This project also includes some example programs, from which you can start: - - https://github.com/stnolting/neo430/tree/master/sw/example - - * Have fun! =) - - -## Questions? - -If you have any questions, bug reports, ideas or if you are facing problems with the NEO430, feel free to drop me a line: - - stnolting@gmail.com - - -## Proprietary Notice - -"MSP430" is a trademark of Texas Instruments Corporation. - -"Virtex", "ISE" and "Vivado" are trademarks of Xilinx Inc. - -"Cyclone", "Quartus" and "Avalon bus" are trademarks of Intel Corporation. - -"AXI" and "AXI-Lite" are trademarks of Arm Holdings plc. - - - - - Index: sw/tools/image_gen/main.cpp =================================================================== --- sw/tools/image_gen/main.cpp (revision 137) +++ sw/tools/image_gen/main.cpp (nonexistent) @@ -1,204 +0,0 @@ -// ################################################################################################# -// # < NEO430 Boot image generator > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 13.10.2017 # -// ################################################################################################# - -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - - if (argc != 4) { - printf("<<< NEO430 executable image generator >>>\n" - "Three arguments are required.\n" - "1st: Option\n" - " -app_bin : Generate application executable binary (with header!) \n" - " -app_img : Generate application raw executable memory image (text file, no header!)\n" - " -bld_img : Generate bootloader raw executable memory image (text file, no header!)\n" - "2nd: Input file (raw binary image)\n" - "3rd: Output file (as selected)\n"); - return 1; - } - - FILE *input, *output; - - // open input file - input = fopen(argv[2], "rb"); - if(input == NULL){ - printf("Input file error!"); - exit(-1); - } - - // open output file - output = fopen(argv[3], "wb"); - if(output == NULL){ - printf("Output file error!"); - exit(-2); - } - - unsigned char buffer[2]; - char tmp_string[512]; - uint16_t tmp = 0, size = 0, checksum = 0; - int i = 0; - int option = 0; - - if (strcmp(argv[1], "-app_bin") == 0) - option = 1; - else if (strcmp(argv[1], "-app_img") == 0) - option = 2; - else if (strcmp(argv[1], "-bld_img") == 0) - option = 3; - else { - printf("Invalid option!"); - return 2; - } - - -// ------------------------------------------------------------ -// Generate BINARY executable (with header!!!) -// ------------------------------------------------------------ - if (option == 1) { - // reserve space for header - fputc(char(0), output); - fputc(char(0), output); - fputc(char(0), output); - fputc(char(0), output); - fputc(char(0), output); - fputc(char(0), output); - - buffer[0] = 0; - buffer[1] = 0; - - checksum = 0; - size = 0; - rewind(input); - while(fread(&buffer, sizeof(unsigned char), 2, input) != 0) { - tmp = (((uint16_t)buffer[1] << 8) | buffer[0]); - checksum = checksum ^ tmp; - fputc(buffer[1], output); - fputc(buffer[0], output); - size += 2; - } - - // build header - rewind(output); - fputc((unsigned char)(0xCA), output); - fputc((unsigned char)(0xFE), output); - fputc((unsigned char)((size & 0xFF00) >> 8), output); - fputc((unsigned char)((size & 0x00FF) >> 0), output); - fputc((unsigned char)((checksum & 0xFF00) >> 8), output); - fputc((unsigned char)((checksum & 0x00FF) >> 0), output); - } - - -// ------------------------------------------------------------ -// Generate APPLICATION's executable memory init file (no header!!!) -// ------------------------------------------------------------ - if (option == 2) { - - // header - sprintf(tmp_string, "-- NEO430 Processor, by Stephan Nolting\r\n" - "-- Auto-generated memory init file (for APPLICATION)\r\n" - "\r\n" - "library ieee;\r\n" - "use ieee.std_logic_1164.all;\r\n" - "\r\n" - "package neo430_application_image is\r\n" - "\r\n" - " type application_init_image_t is array (0 to 65535) of std_ulogic_vector(15 downto 0);\r\n" - " constant application_init_image : application_init_image_t := (\r\n"); - fputs(tmp_string, output); - - // data - buffer[0] = 0; - buffer[1] = 0; - i = 0; - while(fread(&buffer, sizeof(unsigned char), 2, input) != 0) { - tmp = (((uint16_t)buffer[1] << 8) | buffer[0]); - sprintf(tmp_string, " %06d => x\"%04x\",\r\n", i, tmp); - fputs(tmp_string, output); - buffer[0] = 0; - buffer[1] = 0; - i++; - } - - sprintf(tmp_string, " others => x\"0000\" -- nop\r\n"); - fputs(tmp_string, output); - - // end - sprintf(tmp_string, " );\r\n" - "\r\n" - "end neo430_application_image;\r\n"); - fputs(tmp_string, output); - } - - -// ------------------------------------------------------------ -// Generate BOOTLOADER's executable memory init file (no header!!!) -// ------------------------------------------------------------ - if (option == 3) { - - // header - sprintf(tmp_string, "-- NEO430 Processor, by Stephan Nolting\r\n" - "-- Auto-generated memory init file (for BOOTLOADER)\r\n" - "\r\n" - "library ieee;\r\n" - "use ieee.std_logic_1164.all;\r\n" - "\r\n" - "package neo430_bootloader_image is\r\n" - "\r\n" - " type bootloader_init_image_t is array (0 to 65535) of std_ulogic_vector(15 downto 0);\r\n" - " constant bootloader_init_image : bootloader_init_image_t := (\r\n"); - fputs(tmp_string, output); - - // data - buffer[0] = 0; - buffer[1] = 0; - i = 0; - while(fread(&buffer, sizeof(unsigned char), 2, input) != 0) { - tmp = (((uint16_t)buffer[1] << 8) | buffer[0]); - sprintf(tmp_string, " %06d => x\"%04x\",\r\n", i, tmp); - fputs(tmp_string, output); - buffer[0] = 0; - buffer[1] = 0; - i++; - } - - sprintf(tmp_string, " others => x\"0000\" -- nop\r\n"); - fputs(tmp_string, output); - - // end - sprintf(tmp_string, " );\r\n" - "\r\n" - "end neo430_bootloader_image;\r\n"); - fputs(tmp_string, output); - } - - - fclose(input); - fclose(output); - - return 0; -} - Index: sw/tools/image_gen/image_gen.exe =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/tools/image_gen/image_gen.exe =================================================================== --- sw/tools/image_gen/image_gen.exe (revision 137) +++ sw/tools/image_gen/image_gen.exe (nonexistent)
sw/tools/image_gen/image_gen.exe Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: sw/lib/neo430/neo430_wdt.h =================================================================== --- sw/lib/neo430/neo430_wdt.h (revision 137) +++ sw/lib/neo430/neo430_wdt.h (nonexistent) @@ -1,74 +0,0 @@ -// ################################################################################################# -// # < neo430_wdt.h - Watchdog helper functions > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 24.04.2017 # -// ################################################################################################# - -#ifndef neo430_wdt_h -#define neo430_wdt_h - -// prototypes -void wdt_enable(uint8_t prsc); -void wdt_disable(void); -void wdt_reset(void); -void wdt_force_hw_reset(void); - - -/* ------------------------------------------------------------ - * INFO Enable watchdog - * PARAM Prescaler selection (0..7) - * ------------------------------------------------------------ */ -void wdt_enable(uint8_t prsc) { - - WDT_CTRL = (WDT_PASSWORD<<8) | (1< triggers reset -} - - -#endif // neo430_wdt_h Index: sw/lib/neo430/neo430_gpio.h =================================================================== --- sw/lib/neo430/neo430_gpio.h (revision 137) +++ sw/lib/neo430/neo430_gpio.h (nonexistent) @@ -1,109 +0,0 @@ -// ################################################################################################# -// # < neo430_gpio.h - PIO controller helper functions > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 21.02.2017 # -// ################################################################################################# - -#ifndef neo430_gpio_h -#define neo430_gpio_h - -// prototypes -void gpio_pin_set(uint8_t p); -void gpio_pin_clr(uint8_t p); -void gpio_port_set(uint16_t d); -void gpio_port_toggle(uint16_t d); -void gpio_pin_toggle(uint8_t p); -uint16_t gpio_pin_get(uint8_t p); -uint16_t gpio_port_get(void); - - -/* ------------------------------------------------------------ - * INFO Set output pin - * PARAM Pin number to be set (0..15) - * ------------------------------------------------------------ */ -void gpio_pin_set(uint8_t p) { - - GPIO_OUT = GPIO_OUT | (uint16_t)(1 << p); -} - - -/* ------------------------------------------------------------ - * INFO Clear output pin - * PARAM Pin number to be cleared (0..15) - * ------------------------------------------------------------ */ -void gpio_pin_clr(uint8_t p) { - - GPIO_OUT = GPIO_OUT & ~((uint16_t)(1 << p)); -} - - -/* ------------------------------------------------------------ - * INFO Set output port - * PARAM Output data - * ------------------------------------------------------------ */ -void gpio_port_set(uint16_t d) { - - GPIO_OUT = d; -} - - -/* ------------------------------------------------------------ - * INFO Toggle output port - * PARAM Toggle output data - * ------------------------------------------------------------ */ -void gpio_port_toggle(uint16_t d) { - - GPIO_OUT = GPIO_OUT ^ d; -} - - -/* ------------------------------------------------------------ - * INFO Toggle output pin - * PARAM Pin number (0..15) - * ------------------------------------------------------------ */ -void gpio_pin_toggle(uint8_t p) { - - GPIO_OUT = GPIO_OUT ^ (uint16_t)(1 << p); -} - - -/* ------------------------------------------------------------ - * INFO Get input pin state - * PARAM Pin number (0..15) - * RETURN 0 if pin cleared, pin set otherwise - * ------------------------------------------------------------ */ -uint16_t gpio_pin_get(uint8_t p) { - - return GPIO_IN & (uint16_t)(1 << p); -} - - -/* ------------------------------------------------------------ - * INFO Get input port - * RETURN Input port state - * ------------------------------------------------------------ */ -uint16_t gpio_port_get(void) { - - return GPIO_IN; -} - - -#endif // neo430_gpio_h Index: sw/lib/neo430/neo430_usart.h =================================================================== --- sw/lib/neo430/neo430_usart.h (revision 137) +++ sw/lib/neo430/neo430_usart.h (nonexistent) @@ -1,446 +0,0 @@ -// ################################################################################################# -// # < neo430_usart.h - Internal USART/USI UART & SPI control / AUX functions > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 21.07.2017 # -// ################################################################################################# - -#ifndef neo430_usart_h -#define neo430_usart_h - -// Libs required by functions -#include - -// prototypes (SPI) -void spi_cs_en(uint8_t cs); -void spi_cs_dis(uint8_t cs); -uint8_t spi_trans(uint8_t d); - -// prototypes (UART) -void uart_set_baud(uint32_t baudrate); -void uart_putc(char c); -char uart_getc(void); -uint16_t uart_char_received(void); -char uart_char_read(void); -void uart_print(char *s); -void uart_br_print(char *s); -uint16_t uart_scan(char *buffer, uint16_t max_size); -void uart_print_hex_char(char c); -void uart_print_hex_byte(uint8_t b); -void uart_print_hex_word(uint16_t w); -void uart_print_hex_dword(uint32_t dw); -void uart_print_bin_byte(uint8_t b); -void uart_print_bin_word(uint16_t w); -void uart_print_bin_dword(uint32_t dw); -void _itoa(uint32_t x); -void _printf(char *format, ...); - - -/* ------------------------------------------------------------ - * INFO Enable SPI CSx (set low) - * PARAM CS line (0..5) - * ------------------------------------------------------------ */ -void spi_cs_en(uint8_t cs) { - - USI_CT |= 1 << (USI_CT_SPICS0 + cs); -} - - -/* ------------------------------------------------------------ - * INFO Disable SPI CSx (set high) - * PARAM CS line (0..5) - * ------------------------------------------------------------ */ -void spi_cs_dis(uint8_t cs) { - - USI_CT &= ~(1 << (USI_CT_SPICS0 + cs)); -} - - -/* ------------------------------------------------------------ - * INFO SPI RTX byte transfer - * INFO SPI SCK speed: f_main/(2*PRSC), PRSC = see below (control reg) - * SPI clock prescaler select: - * 0: CLK/2 - * 1: CLK/4 - * 2: CLK/8 - * 3: CLK/64 - * 4: CLK/128 - * 5: CLK/1024 - * 6: CLK/2048 - * 7: CLK/4096 - * PARAM d byte to be send - * RETURN received byte - * ------------------------------------------------------------ */ -uint8_t spi_trans(uint8_t d) { - - USI_SPIRTX = (uint16_t)d; // trigger transfer - while((USI_CT & (1<= 2*baudrate) { - clock -= 2*baudrate; - i++; - } - - // find clock prsc - while (i >= 256) { - if ((p == 2) || (p == 4)) - i >>= 3; - else - i >>= 1; - p++; - } - - USI_BAUD = ((uint16_t)p << 8) | i; -} - - -/* ------------------------------------------------------------ - * INFO Send single char via internal UART - * PARAM c char to send - * ------------------------------------------------------------ */ -void uart_putc(char c){ - - // wait for previous transfer to finish - while ((USI_CT & (1< - * INFO This is the base for a non-blocking read access - * RETURN received char - * ------------------------------------------------------------ */ -char uart_char_read(void){ - - return (char)USI_UARTRTX; -} - - -/* ------------------------------------------------------------ - * INFO Print zero-terminated string of chars via internal UART - * PARAM *s pointer to source string - * ------------------------------------------------------------ */ -void uart_print(char *s){ - - char c = 0; - while ((c = *s++)) - uart_putc(c); -} - - -/* ------------------------------------------------------------ - * INFO Print zero-terminated string of chars via internal UART - * Prints true line break "\r\n" for every '\n' - * PARAM *s pointer to source string - * ------------------------------------------------------------ */ -void uart_br_print(char *s){ - - char c = 0; - while ((c = *s++)) { - if (c == '\n') - uart_putc('\r'); - uart_putc(c); - } -} - - -/* ------------------------------------------------------------ - * INFO Get string via UART, string is automatically zero-terminated. - * Input is acknowledged by ENTER, local echo, chars can be deleted using BACKSPACE. - * PARAM buffer to store string to - * PARAM size of buffer (=max string length incl. zero-termination) - * RETURN Length of string (without zero-termination character) - * ------------------------------------------------------------ */ -uint16_t uart_scan(char *buffer, uint16_t max_size) { - - char c = 0; - uint16_t length = 0; - - while (1) { - c = uart_getc(); - if (c == '\b') { // BACKSPACE - if (length != 0) { - uart_print("\b \b"); // delete last char - buffer--; - length--; - } - } - else if (c == '\r') // ENTER - break; - else if ((c >= ' ') && (c <= '~') && (length < (max_size-1))) { - uart_putc(c); // echo - *buffer++ = c; - length++; - } - } - *buffer = '\0'; // terminate string - - return length; -} - - -/* ------------------------------------------------------------ - * INFO Print single (capital) hexadecimal value (1 digit) - * PARAM char to be printed - * ------------------------------------------------------------ */ -void uart_print_hex_char(char c) { - - char d = c & 15; - if (d < 10) - d += '0'; - else - d += 'A'-10; - uart_putc(d); -} - - -/* ------------------------------------------------------------ - * INFO Print 8-bit hexadecimal value (2 digits) - * PARAM uint8_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_hex_byte(uint8_t b) { - - uart_print_hex_char((char)(b >> 4)); - uart_print_hex_char((char)(b >> 0)); -} - - -/* ------------------------------------------------------------ - * INFO Print 16-bit hexadecimal value (4 digits) - * PARAM uint16_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_hex_word(uint16_t w) { - - uart_print_hex_byte((uint8_t)(w >> 8)); - uart_print_hex_byte((uint8_t)(w >> 0)); -} - - -/* ------------------------------------------------------------ - * INFO Print 32-bit hexadecimal value (8 digits) - * PARAM uint32_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_hex_dword(uint32_t dw) { - - uart_print_hex_word((uint16_t)(dw >> 16)); - uart_print_hex_word((uint16_t)(dw >> 0)); -} - - -/* ------------------------------------------------------------ - * INFO Print 8-bit binary value (8 digits) - * PARAM uint8_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_bin_byte(uint8_t b) { - - uint8_t i; - for (i=0x80; i!=0; i>>=1) { - if (b & i) - uart_putc('1'); - else - uart_putc('0'); - } -} - - -/* ------------------------------------------------------------ - * INFO Print 16-bit decimal value (16 digits) - * PARAM uint16_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_bin_word(uint16_t w) { - - uart_print_bin_byte((uint8_t)(w >> 8)); - uart_print_bin_byte((uint8_t)(w >> 0)); -} - - -/* ------------------------------------------------------------ - * INFO Print 32-bit decimal value (32 digits) - * PARAM uint32_t value to be printed - * ------------------------------------------------------------ */ -void uart_print_bin_dword(uint32_t dw) { - - uart_print_bin_word((uint16_t)(dw >> 16)); - uart_print_bin_word((uint16_t)(dw >> 0)); -} - - -/* ------------------------------------------------------------ - * INFO Print 32-bit number as deciaml number - * INFO Slow custom version of itoa - * PARAM 32-bit value to be printed as decimal number - * ------------------------------------------------------------ */ -void _itoa(uint32_t x) { - - static const char numbers[10] = "0123456789"; - char buffer1[11], buffer2[11]; - uint8_t i, j; - - buffer1[10] = '\0'; - buffer2[10] = '\0'; - - // convert - for (i=0; i<10; i++) { - buffer1[i] = numbers[x%10]; - x /= 10; - } - - // delete 'leading' zeros - for (i=9; i!=0; i--) { - if (buffer1[i] == '0') - buffer1[i] = '\0'; - else - break; - } - - // reverse - j = 0; - do { - if (buffer1[i] != '\0') - buffer2[j++] = buffer1[i]; - } while (i--); - - buffer2[j] = '\0'; // terminate result string - - uart_br_print(buffer2); -} - - -/* ------------------------------------------------------------ - * INFO Embedded version of the printf function with reduced functionality - * INFO Only use this function if it is really required! - * INFO It is large and slow... ;) - * INFO Original from http://forum.43oh.com/topic/1289-tiny-printf-c-version/ - * PARAM Argument string - * ------------------------------------------------------------ */ -void _printf(char *format, ...) { - - char c; - int16_t i; - int32_t n; - - va_list a; - va_start(a, format); - - while ((c = *format++)) { - if (c == '%') { - c = *format++; - switch (c) { - case 's': // string - uart_print(va_arg(a, char*)); - break; - case 'c': // char - uart_putc((char)va_arg(a, int)); - break; - case 'i': // 16-bit integer - i = va_arg(a, int); - if (i < 0) { - i = -i; - uart_putc('-'); - } - _itoa((uint32_t)i); - break; - case 'u': // 16-bit unsigned - _itoa((uint32_t)va_arg(a, unsigned int)); - break; - case 'l': // 32-bit long - n = va_arg(a, int32_t); - if (n < 0) { - n = -n; - uart_putc('-'); - } - _itoa((uint32_t)n); - break; - case 'n': // 32-bit unsigned long - _itoa(va_arg(a, uint32_t)); - break; - case 'x': // 16-bit hexadecimal - uart_print_hex_word(va_arg(a, unsigned int)); - break; - case 'X': // 32-bit hexadecimal - uart_print_hex_dword(va_arg(a, uint32_t)); - break; - default: - return; - } - } - else { - if (c == '\n') - uart_putc('\r'); - uart_putc(c); - } - } - va_end(a); -} - - -#endif // neo430_usart_h Index: sw/lib/neo430/neo430_wishbone.h =================================================================== --- sw/lib/neo430/neo430_wishbone.h (revision 137) +++ sw/lib/neo430/neo430_wishbone.h (nonexistent) @@ -1,350 +0,0 @@ -// ################################################################################################# -// # < neo430_wishbone.h - Internal Wishbone interface control functions > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Thanks to Edward Sherriff! # -// # Stephan Nolting, Hannover, Germany 19.07.2017 # -// ################################################################################################# - -#ifndef neo430_wishbone_h -#define neo430_wishbone_h - -// prototypes blocking functions using classic transfers -uint32_t wishbone_read32(uint32_t a); -void wishbone_write32(uint32_t a, uint32_t d); -uint16_t wishbone_read16(uint32_t a); -void wishbone_write16(uint32_t a, uint16_t d); -uint8_t wishbone_read8(uint32_t a); -void wishbone_write8(uint32_t a, uint8_t d); - -// prototypes blocking functions using pipelined transfers -uint32_t wishbone_read32_pipelined(uint32_t a); -void wishbone_write32_pipelined(uint32_t a, uint32_t d); -uint16_t wishbone_read16_pipelined(uint32_t a); -void wishbone_write16_pipelined(uint32_t a, uint16_t d); -uint8_t wishbone_read8_pipelined(uint32_t a); -void wishbone_write8_pipelined(uint32_t a, uint8_t d); - - -// ************************************************************************************************ -// Blocking functions, classic transfer cycles -// ************************************************************************************************ - -/* ------------------------------------------------------------ - * INFO Read 32-bit from Wishbone device (blocking) via classic cycle - * PARAM 32-bit device address - * RETURN read data - * ------------------------------------------------------------ */ -uint32_t wishbone_read32(uint32_t a) { - - // 32-bit transfer, classic cycle - WB32_CT = 0xF; - - // device address aligned to 32-bit + transfer trigger - WB32_RA_32bit = a & (~3); - - // wait for access to be completed - blocking! - while((WB32_CT & (1< # -// # ********************************************************************************************* # -// # This file is crucial for all NEO430 software projects! # -// # You only need to include this file into your project code (all sub-libraries are included # -// # in this library file). # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 15.08.2017 # -// ################################################################################################# - -#ifndef neo430_h -#define neo430_h - -// STD libraries -#include -#include - -// ---------------------------------------------------------------------------- -// CPU Status Register (r2) Flags -// ---------------------------------------------------------------------------- -#define C_FLAG 0 // r/w: carry -#define Z_FLAG 1 // r/w: zero -#define N_FLAG 2 // r/w: negative -#define I_FLAG 3 // r/w: global interrupt enable -#define S_FLAG 4 // r/w: sleep -#define V_FLAG 8 // r/w: overflow -#define Q_FLAG 14 // -/w: clear pending IRQ buffer when set -#define R_FLAG 15 // r/w: allow write-access to IMEM - - -// ---------------------------------------------------------------------------- -// Processor peripheral/IO devices -// Beginning of IO area: 0xFF80 -// Size of IO area: 128 bytes -// ---------------------------------------------------------------------------- -#define REG8 (volatile uint8_t*) -#define REG16 (volatile uint16_t*) -#define REG32 (volatile uint32_t*) - -/* --- Custom Function Unit - CFU --- */ -#define CFU_REG0 (*(REG16 0xFF80)) // ?/? user defined -#define CFU_REG0_LO (*(REG8 0xFF80)) // ?/? user defined -#define CFU_REG0_HI (*(REG8 0xFF81)) // ?/? user defined -#define CFU_REG1 (*(REG16 0xFF82)) // ?/? user defined -#define CFU_REG1_LO (*(REG8 0xFF82)) // ?/? user defined -#define CFU_REG1_HI (*(REG8 0xFF83)) // ?/? user defined -#define CFU_REG2 (*(REG16 0xFF84)) // ?/? user defined -#define CFU_REG2_LO (*(REG8 0xFF84)) // ?/? user defined -#define CFU_REG2_HI (*(REG8 0xFF85)) // ?/? user defined -#define CFU_REG3 (*(REG16 0xFF86)) // ?/? user defined -#define CFU_REG3_LO (*(REG8 0xFF86)) // ?/? user defined -#define CFU_REG3_HI (*(REG8 0xFF87)) // ?/? user defined -#define CFU_REG4 (*(REG16 0xFF88)) // ?/? user defined -#define CFU_REG4_LO (*(REG8 0xFF88)) // ?/? user defined -#define CFU_REG4_HI (*(REG8 0xFF89)) // ?/? user defined -#define CFU_REG5 (*(REG16 0xFF8A)) // ?/? user defined -#define CFU_REG5_LO (*(REG8 0xFF8A)) // ?/? user defined -#define CFU_REG5_HI (*(REG8 0xFF8B)) // ?/? user defined -#define CFU_REG6 (*(REG16 0xFF8C)) // ?/? user defined -#define CFU_REG6_LO (*(REG8 0xFF8C)) // ?/? user defined -#define CFU_REG6_HI (*(REG8 0xFF8D)) // ?/? user defined -#define CFU_REG7 (*(REG16 0xFF8E)) // ?/? user defined -#define CFU_REG7_LO (*(REG8 0xFF8E)) // ?/? user defined -#define CFU_REG7_HI (*(REG8 0xFF8F)) // ?/? user defined - - -/* --- Wishbone Bus Adapter - WB32 --- */ -#define WB32_LRA (*(REG16 0xFF90)) // -/w: low address for read transfer -#define WB32_HRA (*(REG16 0xFF92)) // -/w: high address for read transfer (+trigger) -#define WB32_LWA (*(REG16 0xFF94)) // -/w: low address for write transfer -#define WB32_HWA (*(REG16 0xFF96)) // -/w: high address for write transfer (+trigger) -#define WB32_LD (*(REG16 0xFF98)) // r/w: low data -#define WB32_HD (*(REG16 0xFF9A)) // r/w: high data -#define WB32_xxx (*(REG16 0xFF9C)) // -/-: reserved -#define WB32_CT (*(REG16 0xFF9E)) // r/w: control register - -// WB32 - 32-bit register access -#define WB32_RA_32bit (*(REG32 (&WB32_LRA))) // -/w: address for read transfer (+trigger) -#define WB32_WA_32bit (*(REG32 (&WB32_LWA))) // -/w: address for write transfer (+trigger) -#define WB32_D_32bit (*(REG32 (&WB32_LD))) // r/w: read/write data (for 32-bit access) -#define WB32_D_8bit (*(REG8 (&WB32_LD))) // r/w: read/write data (for 8-bit access) - -// WB32 control register -#define WB32_CT_WBSEL0 0 // -/w: wishbone data byte enable bit 0 -#define WB32_CT_WBSEL1 1 // -/w: wishbone data byte enable bit 1 -#define WB32_CT_WBSEL2 2 // -/w: wishbone data byte enable bit 2 -#define WB32_CT_WBSEL3 3 // -/w: wishbone data byte enable bit 3 -#define WB32_CT_PMODE 4 // -/w: 0: standard transfers, 1: pipelined transfers -#define WB32_CT_PENDING 15 // r/-: pending transfer - - -/* --- Universal Serial Transceiver - USART/USI --- */ -#define USI_SPIRTX (*(REG16 0xFFA0)) // r/w: spi receive/transmit register -#define USI_UARTRTX (*(REG16 0xFFA2)) // r/w: uart receive/transmit register -#define USI_BAUD (*(REG16 0xFFA4)) // r/w: uart baud rate generator value -#define USI_CT (*(REG16 0xFFA6)) // r/w: control register - -// UART USI_BAUD[7:0]: baud rate value -// UART USI_BAUD[10:8]: baud prescaler select: -// 0: CLK/2 -// 1: CLK/4 -// 2: CLK/8 -// 3: CLK/64 -// 4: CLK/128 -// 5: CLK/1024 -// 6: CLK/2048 -// 7: CLK/4096 - -// USART UART RTX register -#define USI_UARTRTX_UARTRXAVAIL 15 // r/-: uart receiver data available - -// USART control register -#define USI_CT_EN 0 // r/w: USART enable -#define USI_CT_UARTRXIRQ 1 // r/w: uart rx done interrupt enable -#define USI_CT_UARTTXIRQ 2 // r/w: uart tx done interrupt enable -#define USI_CT_UARTTXBSY 3 // r/-: uart transmitter is busy -#define USI_CT_SPICPHA 4 // r/w: spi clock phase (idle polarity = '0') -#define USI_CT_SPIIRQ 5 // r/w: spi transmission done interrupt enable -#define USI_CT_SPIBSY 6 // r/-: spi transceiver is busy -#define USI_CT_SPIPRSC0 7 // r/w: spi prescaler select bit 0 -#define USI_CT_SPIPRSC1 8 // r/w: spi prescaler select bit 1 -#define USI_CT_SPIPRSC2 9 // r/w: spi prescaler select bit 2 -#define USI_CT_SPICS0 10 // r/w: spi direct CS 0, CS is low (active) when bit is set -#define USI_CT_SPICS1 11 // r/w: spi direct CS 1, CS is low (active) when bit is set -#define USI_CT_SPICS2 12 // r/w: spi direct CS 2, CS is low (active) when bit is set -#define USI_CT_SPICS3 13 // r/w: spi direct CS 3, CS is low (active) when bit is set -#define USI_CT_SPICS4 14 // r/w: spi direct CS 4, CS is low (active) when bit is set -#define USI_CT_SPICS5 15 // r/w: spi direct CS 5, CS is low (active) when bit is set - -// SPI clock prescaler select: -// 0: CLK/2 -// 1: CLK/4 -// 2: CLK/8 -// 3: CLK/64 -// 4: CLK/128 -// 5: CLK/1024 -// 6: CLK/2048 -// 7: CLK/4096 - - -/* --- Genearl Purpose Inputs/Outputs - GPIO --- */ -#define GPIO_IN (*(REG16 0xFFB0)) // r/-: parallel input -#define GPIO_OUT (*(REG16 0xFFB2)) // r/w: parallel output -#define GPIO_CTRL (*(REG16 0xFFB4)) // -/w: control register -#define GPIO_IRQMASK (*(REG16 0xFFB6)) // -/w: irq mask register - -// bits 1:0 of GPIO CTRL reg: Trigger -// 00: low level -// 01: high level -// 10: falling edge -// 11: rising edge -// bit 2: General interrupt enable flag - - -/* --- High-Precision Timer - TIMER --- */ -#define TMR_CNT (*(REG16 0xFFC0)) // r/w: counter register -#define TMR_THRES (*(REG16 0xFFC2)) // r/w: threshold register -#define TMR_CT (*(REG16 0xFFC4)) // r/w: control register - -// Timer control register -#define TMR_CT_EN 0 // r/w: timer enable -#define TMR_CT_ARST 1 // r/w: auto reset on match -#define TMR_CT_IRQ 2 // r/w: interrupt enable -#define TMR_CT_PRSC0 3 // r/w: prescaler select bit 0 -#define TMR_CT_PRSC1 4 // r/w: prescaler select bit 1 -#define TMR_CT_PRSC2 5 // r/w: prescaler select bit 2 - -// timer clock prescaler select: -// 0: CLK/2 -// 1: CLK/4 -// 2: CLK/8 -// 3: CLK/64 -// 4: CLK/128 -// 5: CLK/1024 -// 6: CLK/2048 -// 7: CLK/4096 - - -/* --- Watchdog Timer - WTD --- */ -#define WDT_CTRL (*(REG16 0xFFD0)) // r/w: Watchdog control register - -// Watchdog control register -#define WDT_PASSWORD 0x47 // must be set in the upper 8 bits of the WDT CTRL register -#define WDT_CLKSEL0 0 // r/w: prescaler select bit 0 -#define WDT_CLKSEL1 1 // r/w: prescaler select bit 1 -#define WDT_CLKSEL2 2 // r/w: prescaler select bit 2 -#define WDT_ENABLE 3 // r/w: WDT enable -#define WDT_RCAUSE 4 // r/-: reset cause (0: external, 1: watchdog timeout) -#define WDT_SYSRST 5 // -/w: set one to generate system hardware reset - -// watchdog clock prescaler select: -// 0: CLK/2 -// 1: CLK/4 -// 2: CLK/8 -// 3: CLK/64 -// 4: CLK/128 -// 5: CLK/1024 -// 6: CLK/2048 -// 7: CLK/4096 - - -/* --- System Configuration - SYSCONFIG --- */ -#define CPUID0 (*(REG16 0xFFE0)) // r/-: HW version -#define CPUID1 (*(REG16 0xFFE2)) // r/-: system configuration -#define CPUID2 (*(REG16 0xFFE4)) // r/-: CPU identifier -#define CPUID3 (*(REG16 0xFFE6)) // r/-: IMEM/ROM size in bytes -#define CPUID4 (*(REG16 0xFFE8)) // r/-: DMEM/RAM base address -#define CPUID5 (*(REG16 0xFFEA)) // r/-: DMEM/RAM size in bytes -#define CPUID6 (*(REG16 0xFFEC)) // r/-: clock speed lo -#define CPUID7 (*(REG16 0xFFEE)) // r/-: clock speed hi -// Aliases -#define HW_VERSION CPUID0 // r/-: HW verison number -#define SYS_FEATURES CPUID1 // r/-: synthesized system features -#define USER_CODE CPUID2 // r/-: custom user code -#define IMEM_SIZE CPUID3 // r/-: IMEM/ROM size in bytes -#define DMEM_BASE CPUID4 // r/-: DMEM/RAM base address -#define DMEM_SIZE CPUID5 // r/-: DMEM/RAM size in bytes -#define CLOCKSPEED_LO CPUID6 // r/-: clock speed (in Hz) low part -#define CLOCKSPEED_HI CPUID7 // r/-: clock speed (in Hz) high part - -// SysConfig - 32-bit register access -#define CLOCKSPEED_32bit (*(REG32 (&CLOCKSPEED_LO))) // r/-: clock speed (in Hz) - -// SYS features -#define SYS_CFU_EN 0 // CFU synthesized -#define SYS_WB32_EN 1 // WB32 synthesized -#define SYS_WDT_EN 2 // WDT synthesized -#define SYS_GPIO_EN 3 // GPIO synthesized -#define SYS_TIMER_EN 4 // timer synthesized -#define SYS_USART_EN 5 // USART synthesized -#define SYS_DADD_EN 6 // DADD instruction synthesized -#define SYS_BTLD_EN 7 // Bootloader installed and enabled? -#define SYS_IROM_EN 8 // Implement IMEM as true ROM? - -// Interrupt vectors (mirrored 2x times) -//#define IRQVEC_TIMER (*(REG16 0xFFF0)) // r/w: mirrored IRQ vector register -//#define IRQVEC_USART (*(REG16 0xFFF2)) // r/w: mirrored IRQ vector register -//#define IRQVEC_GPIO (*(REG16 0xFFF4)) // r/w: mirrored IRQ vector register -//#define IRQVEC_EXT (*(REG16 0xFFF6)) // r/w: mirrored IRQ vector register -#define IRQVEC_TIMER (*(REG16 0xFFF8)) // r/w: timer match -#define IRQVEC_USART (*(REG16 0xFFFA)) // r/w: uart rx avail / uart tx done / spi rtx done -#define IRQVEC_GPIO (*(REG16 0xFFFC)) // r/w: gpio pin change -#define IRQVEC_EXT (*(REG16 0xFFFE)) // r/w: external IRQ - - -// ---------------------------------------------------------------------------- -// Include IO libraries -// ---------------------------------------------------------------------------- -#include "neo430_cpu.h" -#include "neo430_gpio.h" -#include "neo430_usart.h" -#include "neo430_wdt.h" -#include "neo430_wishbone.h" - - -#endif // neo430_h Index: sw/lib/neo430/neo430_cpu.h =================================================================== --- sw/lib/neo430/neo430_cpu.h (revision 137) +++ sw/lib/neo430/neo430_cpu.h (nonexistent) @@ -1,237 +0,0 @@ -// ################################################################################################# -// # < neo430_cpu.h - CPU helper functions > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 14.10.2017 # -// ################################################################################################# - -#ifndef neo430_cpu_h -#define neo430_cpu_h - -// prototypes -inline void eint(void); -inline void dint(void); -inline uint16_t get_sp(void); -inline uint16_t get_sreg(void); -inline void set_sreg(uint16_t d); -inline void sleep(void); -inline void clear_irq_buffer(void); -void cpu_delay(uint16_t t); -void __memset(uint8_t *dst, uint8_t data, uint16_t num); -uint8_t __memcmp(uint8_t *dst, uint8_t *src, uint16_t num); -void __memcpy(uint8_t *dst, uint8_t *src, uint16_t num); -inline void soft_reset(void); -inline void jump_address(uint16_t addr); -inline void call_address(uint16_t addr); -inline uint16_t __bswap(uint16_t a); -inline uint16_t __dadd(uint16_t a, uint16_t b); - - -/* ------------------------------------------------------------ - * INFO Enable global interrupt flag - * ------------------------------------------------------------ */ -inline void eint(void){ - - asm volatile ("eint"); -} - - -/* ------------------------------------------------------------ - * INFO Disable global interrupt flag - * ------------------------------------------------------------ */ -inline void dint(void){ - - asm volatile ("dint"); - asm volatile ("nop"); -} - - -/* ------------------------------------------------------------ - * INFO Read stack pointer (for debugging only) - * RETURN current stack pointer - * ------------------------------------------------------------ */ -inline uint16_t get_sp(void){ - - register uint16_t d; - asm volatile ("mov r1, %0" : "=r" (d)); - uint16_t r = d; - return r; -} - - -/* ------------------------------------------------------------ - * INFO Read status register - * RETURN current status register - * ------------------------------------------------------------ */ -inline uint16_t get_sreg(void){ - - register uint16_t d; - asm volatile ("mov r2, %0" : "=r" (d)); - uint16_t r = d; - return r; -} - - -/* ------------------------------------------------------------ - * INFO Set status register - * PARAM d new value for status register - * ------------------------------------------------------------ */ -inline void set_sreg(uint16_t d){ - - register uint16_t r = d; - asm volatile ("mov %0, r2" : : "r" (r)); -} - - -/* ------------------------------------------------------------ - * INFO Set CPU to sleep mode - * ------------------------------------------------------------ */ -inline void sleep(void){ - - asm volatile ("bis %0, r2" : : "i" (1< rom - - .rodata : - { - . = ALIGN(2); - PROVIDE(__rodata_start = .); - PROVIDE(__rodatastart = .); - - *(.plt); - . = ALIGN(2); - *(.lower.rodata.* .lower.rodata) - . = ALIGN(2); - *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*) - . = ALIGN(2); - *(.either.rodata.* .either.rodata) - . = ALIGN(2); - *(.rodata1) - . = ALIGN(2); - - KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) - PROVIDE (__preinit_array_start = .); - KEEP (*(.preinit_array)) - PROVIDE (__preinit_array_end = .); - PROVIDE (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array)) - PROVIDE (__init_array_end = .); - PROVIDE (__fini_array_start = .); - KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE (__fini_array_end = .); - - PROVIDE(__rodata_end = .); - PROVIDE(__rodataend = .); - } > rom - _etext = .; /* Past last read-only (loadable) segment */ - - /* ----------------------------------- */ - - .data : - { - . = ALIGN(2); - PROVIDE(__data_start = .); - PROVIDE(__datastart = .); - - *(.lower.data.* .lower.data) - *(.data .data.* .gnu.linkonce.d.*) - *(.either.data.* .either.data) - - KEEP (*(.jcr)) - *(.data.rel.ro.local) *(.data.rel.ro*) - *(.dynamic) - - KEEP (*(.gnu.linkonce.d.*personality*)) - SORT(CONSTRUCTORS) - *(.data1) - *(.got.plt) *(.got) - - . = ALIGN(2); - *(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1) - - . = ALIGN(2); - _edata = .; - PROVIDE(edata = .); - PROVIDE(__data_end = .); - PROVIDE(__dataend = .); - } > ram AT > rom - - /* ----------------------------------- */ - - .bss : - { - . = ALIGN(2); - PROVIDE(__bss_start = .); - PROVIDE(__bssstart = .); - - *(.lower.bss.* .lower.bss) - *(.dynbss); - *(.sbss .sbss.*); - *(.bss .bss.* .gnu.linkonce.b.*); - *(.either.bss.* .either.bss) - . = ALIGN(2); - *(COMMON); - . = ALIGN(2); - - PROVIDE(__bss_end = .); - PROVIDE(__bssend = .); - } > ram - - .noinit (NOLOAD): - { - . = ALIGN(2); - *(.noinit) - . = ALIGN(2); - PROVIDE(__noinit_end = .); - end = .; - } > ram - - .MP430.attributes 0 : - { - KEEP (*(.MSP430.attributes)) - KEEP (*(.gnu.attributes)) - KEEP (*(__TI_build_attributes)) - } - - /* The rest are all not normally part of the runtime image. */ - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - /DISCARD/ : { *(.note.GNU-stack) } - -PROVIDE(__data_start_rom = _etext); -PROVIDE(__data_end_rom = _etext + SIZEOF(.data)); -PROVIDE(__romdatastart = __data_start_rom); -PROVIDE(__romdatacopysize = SIZEOF(.data)); -PROVIDE(__bsssize = SIZEOF(.bss)); - -} Index: sw/common/crt0.asm =================================================================== --- sw/common/crt0.asm (revision 137) +++ sw/common/crt0.asm (nonexistent) @@ -1,116 +0,0 @@ -; ################################################################################################# -; # < crt0.asm - general neo430 application start-up code > # -; # ********************************************************************************************* # -; # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -; # Copyright by Stephan Nolting: stnolting@gmail.com # -; # # -; # This source file may be used and distributed without restriction provided that this copyright # -; # statement is not removed from the file and that any derivative work contains the original # -; # copyright notice and the associated disclaimer. # -; # # -; # This source file is free software; you can redistribute it and/or modify it under the terms # -; # of the GNU Lesser General Public License as published by the Free Software Foundation, # -; # either version 3 of the License, or (at your option) any later version. # -; # # -; # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -; # See the GNU Lesser General Public License for more details. # -; # # -; # You should have received a copy of the GNU Lesser General Public License along with this # -; # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -; # ********************************************************************************************* # -; # Stephan Nolting, Hannover, Germany 06.10.2017 # -; ################################################################################################# - - .file "crt0.asm" - .section .text - .p2align 1,0 - -__crt0_begin: - nop - -; ----------------------------------------------------------- -; Get required system info -; ----------------------------------------------------------- - mov &0xFFE8, r8 ; = DMEM (RAM) base address - mov &0xFFEA, r1 ; = DMEM (RAM) size in byte - - -; ----------------------------------------------------------- -; Minimal required hardware setup -; ----------------------------------------------------------- - mov #0, r2 ; clear status register & disable interrupts - add r8, r1 ; r1 = stack pointer = end of RAM - mov #0x4700, &0xFFD0 ; deactivate watchdog - - -; ----------------------------------------------------------- -; Setup of peripheral modules -; ----------------------------------------------------------- - mov #0, &0xFF9E ; clear WB control register - mov #0, &0xFFA6 ; clear USI control register - mov #0, &0xFFB4 ; clear PIO control register - mov #0, &0xFFB2 ; clear PIO.OUT register - mov #0, &0xFFC4 ; clear TIMER control register - - -; ----------------------------------------------------------- -; Set all interrupt vectors to 0x0000 (reset) -; ----------------------------------------------------------- - mov #0, &0xFFF8 ; timer match IRQ vector - mov #0, &0xFFFA ; uart rx avail / uart tx done / spi rtx done IRQ vector - mov #0, &0xFFFC ; pio pin change IRQ vector - mov #0, &0xFFFE ; external IRQ vector - - -; ----------------------------------------------------------- -; Clear complete DMEM (including .bss section) -; ----------------------------------------------------------- -__crt0_clr_dmem: - cmp r8, r1 ; base address equal to end of RAM? - jeq __crt0_clr_dmem_end - mov #0, 0(r8) ; clear entry - incd r8 - jmp __crt0_clr_dmem -__crt0_clr_dmem_end: - - -; ----------------------------------------------------------- -; Copy .data section from ROM to RAM -; ----------------------------------------------------------- - mov #__data_start_rom, r5 - mov #__data_end_rom, r6 - mov #__data_start, r7 -__crt0_cpy_data: - cmp r5, r6 - jeq __crt0_cpy_data_end - mov @r5+, 0(r7) - incd r7 - jmp __crt0_cpy_data -__crt0_cpy_data_end: - - -; ----------------------------------------------------------- -; Re-init SR and clear all pending IRQs from buffer -; ----------------------------------------------------------- - mov #(1<<14), r2 ; this flag auto clears - - -; ----------------------------------------------------------- -; This is where the actual application is started -; ----------------------------------------------------------- - mov #0, r12 ; set argc = 0 - call #main - - -; ----------------------------------------------------------- -; Go to endless sleep mode if main returns -; ----------------------------------------------------------- -__crt0_this_is_the_end: - mov #0x4700, &0xFFD0 ; deactivate watchdog - mov #0, r2 ; deativate IRQ - mov #16, r2 ; set CPU to sleep mode - nop - -.Lfe0: - .size __crt0_begin,.Lfe0-__crt0_begin Index: sw/common/compile.bat =================================================================== --- sw/common/compile.bat (revision 137) +++ sw/common/compile.bat (nonexistent) @@ -1,86 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 application compilation script - Windows version > # -@REM # ********************************************************************************************* # -@REM # Edit the BIN_PATH variable to point to your compiler's binary folder! # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 13.10.2017 # -@REM ################################################################################################# - - -@REM ----------------------USER CONFIGURATION---------------------- -@REM Path of compiler binaries: -@set BIN_PATH=C:\msp430-gcc-6.4.0.32_win32\bin - -@REM Compiler effort (-Os = optimize for size) -@set EFFORT=-Os -@REM -------------------------------------------------------------- - - -@REM Compiler tools -@set AS=%BIN_PATH%\msp430-elf-as -@set CC=%BIN_PATH%\msp430-elf-gcc -@set LD=%BIN_PATH%\msp430-elf-ld -@set OBJDUMP=%BIN_PATH%\msp430-elf-objdump -@set OBJCOPY=%BIN_PATH%\msp430-elf-objcopy -@set SIZE=%BIN_PATH%\msp430-elf-size -@set IMAGE_GEN=..\tools\image_gen\image_gen - -@REM Compiler flags -@set CC_OPTS= -nostartfiles -pipe -fwhole-program -fdata-sections -ffunction-sections -Xlinker --gc-sections -Wl,-static -Wall -@set CC_OPTS=%CC_OPTS% -minrt -Xassembler --mY -mhwmult=none - -@REM Assemble start-up code -@%AS% -mcpu=msp430 crt0.asm -mY -o crt0.elf - -@REM Compile -@%CC% %CC_OPTS% %EFFORT% -mcpu=msp430 -hwmult=none %1 -T neo430_linker_script.x -o main.elf -lm - -@REM Print memory utilization -@echo Memory utilization: -@%SIZE% main.elf - -@REM Extract final image section -@%OBJCOPY% -I elf32-little main.elf -j .text -O binary text.bin -@%OBJCOPY% -I elf32-little main.elf -j .rodata -O binary rodata.bin -@%OBJCOPY% -I elf32-little main.elf -j .data -O binary data.bin -@copy /B /Y text.bin+rodata.bin+data.bin image.bin > NUL - -@REM Generate ASM listing file -@%OBJDUMP% -D -S -z main.elf > main.s - -@REM Generate NEO430 executable image file for bootloader upload -@%IMAGE_GEN% -app_bin image.bin main.bin - -@REM Generate NEO430 VHDL memory initialization image file -@%IMAGE_GEN% -app_img image.bin neo430_application_image.vhd - -@REM Install it to the rtl memory init image folder -@echo Installing application image to rtl\core\neo430_application_image.vhd -@copy neo430_application_image.vhd ..\..\rtl\core\. > nul - -@REM Check if "DADD" is used -@echo off -@find /I /C "dadd" main.s > NUL -@echo on -@if %errorlevel% equ 0 echo NEO430: WARNING! 'DADD' instruction might be used! Make sure it is synthesized! - -@REM Clean up -@del crt0.elf text.bin rodata.bin data.bin image.bin neo430_application_image.vhd Index: sw/common/Makefile =================================================================== --- sw/common/Makefile (revision 137) +++ sw/common/Makefile (nonexistent) @@ -1,141 +0,0 @@ -################################################################################################# -# < NEO430 Application Compile Script - Linux version > # -# ********************************************************************************************* # -# Edit the BIN_PATH variable to point to your compiler's binary folder! # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 14.10.2017 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# USER CONFIGURATION -#------------------------------------------------------------------------------- -# Path of compiler binaries: -BIN_PATH = /mnt/c/msp430-gcc-6.4.0.32_linux64/bin - -# Compiler effort (-Os = optimize for size) -EFFORT = -Os - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL := all - -#------------------------------------------------------------------------------- -# Application definitions -#------------------------------------------------------------------------------- -APP_SRC = $(APP_DIR)/$(MAIN) -APP_BIN = $(APP_DIR)/main.bin -APP_ASM = $(APP_DIR)/main.s - -all: $(APP_ASM) $(APP_BIN) neo430_application_image.vhd clean - -#------------------------------------------------------------------------------- -# Tools -#------------------------------------------------------------------------------- -#C ompiler tools -AS = $(BIN_PATH)/msp430-elf-as -CC = $(BIN_PATH)/msp430-elf-gcc -LD = $(BIN_PATH)/msp430-elf-ld -OBJDUMP = $(BIN_PATH)/msp430-elf-objdump -OBJCOPY = $(BIN_PATH)/msp430-elf-objcopy -SIZE = $(BIN_PATH)/msp430-elf-size -IMAGE_GEN = $(TOOL_PATH)/image_gen/image_gen - -# Compiler flags -CC_OPTS = -pipe -nostartfiles -fwhole-program -fdata-sections -ffunction-sections -Xlinker --gc-sections -Wl,-static -Wall -CC_OPTS += -minrt -Xassembler --mY -mhwmult=none - -#------------------------------------------------------------------------------- -# Paths -#------------------------------------------------------------------------------- -# Path to NEO430 image generator: -TOOL_PATH = ../tools -# PAth to NEO430 common SW folder: -COMMON_PATH = ../common - -#------------------------------------------------------------------------------- -# PC Host Compiler -#------------------------------------------------------------------------------- -CC_X86 = g++ -Wall -O -g -DWIN32 = -DWIN32 - -#------------------------------------------------------------------------------- -# Tool Targets -#------------------------------------------------------------------------------- -# Tools -.PHONY: tools -tools: $(IMAGE_GEN) - -$(IMAGE_GEN): $(TOOL_PATH)/image_gen/main.cpp - @echo Compiling $@ - @$(CC_X86) $< -o $@ - -#------------------------------------------------------------------------------- -# Application Targets -#------------------------------------------------------------------------------- -# Assemble startup code -crt0.elf: $(COMMON_PATH)/crt0.asm - @$(AS) -g -mY -mcpu=msp430 $< -o $@ - -# Compile app sources -main.elf: $(APP_SRC) crt0.elf - @$(CC) $(CC_OPTS) $(EFFORT) -mcpu=msp430 -hwmult=none $< -T neo430_linker_script.x -o $@ -lm - @echo Memory utilization: - @$(SIZE) main.elf - -# Generate final executable (from .image section only) -image.bin: main.elf - @$(OBJCOPY) -I elf32-little $< -j .text -O binary text.bin - @$(OBJCOPY) -I elf32-little $< -j .rodata -O binary rodata.bin - @$(OBJCOPY) -I elf32-little $< -j .data -O binary data.bin - @cat text.bin rodata.bin data.bin > $@ - -# Assembly listing file -$(APP_ASM): main.elf - @$(OBJDUMP) -D -S -z $< > $@ - if grep -qR "dadd" $@; \ - then echo "NEO430: WARNING! 'DADD' instruction might be used! Make sure it is synthesized!"; \ - fi - -# Generate NEO430 executable image for bootloader update -$(APP_BIN): image.bin $(IMAGE_GEN) - @$(IMAGE_GEN) -app_bin $< $@ - -# Generate NEO430 executable VHDL boot image -neo430_application_image.vhd: image.bin $(IMAGE_GEN) - @$(IMAGE_GEN) -app_img $< $@ - @echo Installing application image to rtl/core/neo430_application_image.vhd - @cp neo430_application_image.vhd ../../rtl/core/. - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -.PHONY: clean -clean: - @rm -f crt0.elf *.bin *.vhd - -#------------------------------------------------------------------------------- -# eof Index: sw/bootloader/boot_crt0.asm =================================================================== --- sw/bootloader/boot_crt0.asm (revision 137) +++ sw/bootloader/boot_crt0.asm (nonexistent) @@ -1,49 +0,0 @@ -; ################################################################################################# -; # < boot_crt0.asm - neo430 bootloader start-up code > # -; # ********************************************************************************************* # -; # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -; # Copyright by Stephan Nolting: stnolting@gmail.com # -; # # -; # This source file may be used and distributed without restriction provided that this copyright # -; # statement is not removed from the file and that any derivative work contains the original # -; # copyright notice and the associated disclaimer. # -; # # -; # This source file is free software; you can redistribute it and/or modify it under the terms # -; # of the GNU Lesser General Public License as published by the Free Software Foundation, # -; # either version 3 of the License, or (at your option) any later version. # -; # # -; # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -; # See the GNU Lesser General Public License for more details. # -; # # -; # You should have received a copy of the GNU Lesser General Public License along with this # -; # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -; # ********************************************************************************************* # -; # Stephan Nolting, Hannover, Germany 17.02.2017 # -; ################################################################################################# - - .file "boot_crt0.asm" - .section .text - .p2align 1,0 - -__boot_crt0: - nop ; for internal init of CPU - -; ----------------------------------------------------------- -; Minimal required hardware setup -; ----------------------------------------------------------- - clr r2 ; clear status register & disable interrupts - - mov &0xFFE8, r1 ; DMEM (RAM) base address - add &0xFFEA, r1 ; add DMEM (RAM) size in bytes to SP - - mov #0x4700, &0xFFD0 ; deactivate watchdog - - -; ----------------------------------------------------------- -; This is where the actual application is started -; ----------------------------------------------------------- - jmp main - -.Lfe0: - .size __boot_crt0,.Lfe0-__boot_crt0 Index: sw/bootloader/bootloader.c =================================================================== --- sw/bootloader/bootloader.c (revision 137) +++ sw/bootloader/bootloader.c (nonexistent) @@ -1,479 +0,0 @@ -// ################################################################################################# -// # < NEO430 Bootloader > # -// # ********************************************************************************************* # -// # Boot from IMEM, UART or SPI EEPROM at SPI.CS[0] # -// # # -// # UART configuration: 8N1 at 19200 baud # -// # Boot EEPROM: SPI, 16-bit addresses, SPI.CS[0], e.g. 25LC512 # -// # GPIO.out[0] is used as high-active status LED # -// # # -// # Auto boot sequence after timeout: # -// # -> Try booting from SPI EEPROM at SPI.CS[0] # -// # -> permanently light up status led and freeze if SPI EEPROM booting attempt fails # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 18.08.2017 # -// ################################################################################################# - -// Libraries -#include -#include "../lib/neo430/neo430.h" - -// Macros -#define xstr(a) str(a) -#define str(a) #a - -// Configuration -#define BAUD_RATE 19200 // default UART baud rate -#define AUTOBOOT_TIMEOUT 8 // countdown (seconds) to auto boot -#define STATUS_LED 0 // GPIO.out(0) is status LED - -// 25LC512 EEPROM -#define BOOT_EEP_CS 0 // boot EEPROM CS (SPI.CS0) -#define EEP_WRITE 0x02 // initialize start of write sequence -#define EEP_READ 0x03 // initialize start of read sequence -#define EEP_RDSR 0x05 // read status register -#define EEP_WREN 0x06 // write enable - -// Image sources -#define UART_IMAGE 0x00 -#define EEPROM_IMAGE 0x01 - -// Error codes -#define ERROR_EEPROM 0x00 // EEPROM access error -#define ERROR_ROMACCESS 0x01 // cannot write to IMEM -#define ERROR_EXECUTABLE 0x02 // invalid executable format -#define ERROR_SIZE 0x04 // executable is too big -#define ERROR_CHECKSUM 0x08 // checksum error -#define ERROR_UNKNOWN 0xFF // unknown error - -// Scratch register for timeout counter - abuse an unused IRQ vector for this -#define TIMEOUT_CNT IRQVEC_GPIO // this IRQ is disabled, so we are save ;) - -// Function prototypes -void __attribute__((__interrupt__)) timer_irq_handler(void); -void start_app(void); -void print_help(void); -void core_dump(void); -void store_eeprom(void); -void eeprom_write(uint16_t a, uint16_t d); -uint16_t eeprom_read(uint16_t a); -void get_image(uint8_t src); -uint16_t get_image_word(uint16_t a, uint8_t src); -void system_error(uint8_t err_code); - - -/* ------------------------------------------------------------ - * INFO Bootloader main - * ------------------------------------------------------------ */ -int main(void) { - - // **************************************************************** - // Processor hardware initialization - // **************************************************************** - - // stack setup - // -> done in boot_crt0.asm - - // disable watchdog timer - // -> done in boot_crt0.asm - - // clear status register and disable interrupts, just enable write access to IMEM - asm volatile ("mov %0, r2" : : "i" (1<> 14; // divide by 4096 - TMR_THRES = (CLOCKSPEED_HI << 2) -1; // "fake" ;D - TIMEOUT_CNT = 0; // timeout ticker - // enable timer, auto reset, enable IRQ, prsc = 1:2^16 - TMR_CT = (1< enter user console - if ((USI_UARTRTX & (1< "); - char c = uart_getc(); - uart_putc(c); // echo - uart_br_print("\n"); - - if (c == 'r') // restart bootloader - asm volatile ("mov #0xF000, r0"); // jump to beginning of bootloader ROM - else if (c == 'h') // help menu - print_help(); - else if (c == 'd') // core dump - core_dump(); - else if (c == 'u') // upload program to RAM via UART - get_image(UART_IMAGE); - else if (c == 'p') // program EEPROM from RAM - store_eeprom(); - else if (c == 'e') // copy program from EEPROM to RAM - get_image(EEPROM_IMAGE); - else if (c == 's') // start program in RAM - start_app(); - else // unknown command - uart_br_print("Bad CMD!"); - } -} - - - -/* ------------------------------------------------------------ - * INFO Timer IRQ handler - * ------------------------------------------------------------ */ -void __attribute__((__interrupt__)) timer_irq_handler(void) { - - TIMEOUT_CNT++; // increment system ticker - gpio_port_toggle(1<= ' ') && (c <= '~')) - uart_putc(c); - else - uart_putc('.'); - } - - uart_putc('|'); - - // user abort or all done? - if ((uart_char_received() != 0) || ((uint16_t)pnt == 0xFFF0)) - return; - - pnt += 16; - } -} - - -/* ------------------------------------------------------------ - * INFO Store full IMEM content to SPI EEPROM at SPI.CS0 - * ------------------------------------------------------------ */ -void store_eeprom(void) { - - uart_br_print("Proceed (y/n)?"); - if (uart_getc() != 'y') - return; - - uart_br_print("\nWriting... "); - - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_WREN); // write enable - spi_cs_dis(BOOT_EEP_CS); - - // check if eeprom ready (or available at all) - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_RDSR); // read status register CMD - uint8_t b = spi_trans(0x00); // read status register data - spi_cs_dis(BOOT_EEP_CS); - - if ((b & 0x8F) != 0x02) - system_error(ERROR_EEPROM); - - // write signature - eeprom_write(0x0000, 0xCAFE); - - // write size - uint16_t end = IMEM_SIZE; - eeprom_write(0x0002, end); - - // store data from IMEM and update checksum - uint16_t *mem_pnt = 0; - uint16_t eep_index = 0x0006; - uint16_t checksum = 0; - uint16_t d = 0; - while ((uint16_t)mem_pnt < end) { - d = *mem_pnt; - eeprom_write(eep_index, d); - checksum ^= d; - mem_pnt++; - eep_index += 2; - } - - // write checksum - eeprom_write(0x0004, checksum); - - uart_br_print("OK"); -} - - -/* ------------------------------------------------------------ - * INFO EEPROM write data - * PARAM a destination address (16 bit) - * PARAM d word to be written - * ------------------------------------------------------------ */ -void eeprom_write(uint16_t a, uint16_t d) { - - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_WREN); // write enable - spi_cs_dis(BOOT_EEP_CS); - - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_WRITE); // byte write instruction - spi_trans((uint8_t)(a >> 8)); - spi_trans((uint8_t)(a >> 0)); - spi_trans((uint8_t)(d >> 8)); - spi_trans((uint8_t)(d >> 0)); - spi_cs_dis(BOOT_EEP_CS); - - // wait for write to finish - uint8_t s = 0; - do { - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_RDSR); // read status register CMD - s = spi_trans(0x00); - spi_cs_dis(BOOT_EEP_CS); - } while (s & 0x01); // check WIP flag -} - - -/* ------------------------------------------------------------ - * INFO EEPROM read data - * PARAM a destination address (16 bit) - * RETURN word read data - * ------------------------------------------------------------ */ -uint16_t eeprom_read(uint16_t a) { - - spi_cs_en(BOOT_EEP_CS); - spi_trans(EEP_READ); // byte read instruction - spi_trans((uint8_t)(a >> 8)); - spi_trans((uint8_t)(a >> 0)); - uint8_t b0 = spi_trans(0x00); - uint8_t b1 = spi_trans(0x00); - spi_cs_dis(BOOT_EEP_CS); - - return ((uint16_t)b0 << 8) | (uint16_t)b1; -} - - -/* ------------------------------------------------------------ - * INFO Get IMEM image from SPI EEPROM at SPI.CS0 or from UART - * PARAM src Image source 0: UART, 1: EEPROM - * RETURN error code (0 if successful) - * ------------------------------------------------------------ */ -void get_image(uint8_t src) { - - // abort if IMEM was implemented as true ROM - if (SYS_FEATURES & (1< end) - system_error(ERROR_SIZE); - - // transfer program data - uint16_t *pnt = 0x0000; - uint16_t addr = 0x0006; - uint16_t checksum = 0; - uint16_t d = 0; - while ((uint16_t)pnt < size) { - d = get_image_word(addr, src); - checksum ^= d; - *pnt++ = d; - addr += 2; - } - - // clear rest of IMEM - while((uint16_t)pnt < end) - *pnt++ = 0x0000; - - // error during transfer? - if (checksum == check) - uart_br_print("OK"); - else - system_error(ERROR_CHECKSUM); -} - - -/* ------------------------------------------------------------ - * INFO Get image word from EEPROM or UART - * PARAM a source address (16 bit) - * PARAM src: 0: UART, 1: EEPROM - * RETURN accessed data word - * ------------------------------------------------------------ */ -uint16_t get_image_word(uint16_t a, uint8_t src) { - - uint16_t d; - - // reads have to be consecutive when reading from the UART ;) - if (src == UART_IMAGE) { // get image data via UART - uint8_t c0 = (uint8_t)uart_getc(); - uint8_t c1 = (uint8_t)uart_getc(); - d = ((uint16_t)c0 << 8) | (uint16_t)c1; - } - else //if (src == EEPROM_IMAGE) // get image data from EEPROM - d = eeprom_read(a); - - return d; -} - - -/* ------------------------------------------------------------ - * INFO Print error message, light up status LED and freeze system - * PARAM error code - * ------------------------------------------------------------ */ -void system_error(uint8_t err_code){ - - uart_br_print("\n\aERROR "); - uart_print_hex_byte(err_code); - - asm volatile ("mov #0, r2"); // deactivate IRQs, no more write access to IMEM - gpio_port_set(1< # -# ********************************************************************************************* # -# Edit the BIN_PATH variable to point to your compiler's binary folder! # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 06.10.2017 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# USER CONFIGURATION -#------------------------------------------------------------------------------- -# Path of compiler binaries: -BIN_PATH = /mnt/c/msp430-gcc-6.4.0.32_linux64/bin - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL := all - -#------------------------------------------------------------------------------- -# Application definitions -#------------------------------------------------------------------------------- -all: bootloader.s neo430_bootloader_image.vhd -$(warning Making bootloader.c) - -#------------------------------------------------------------------------------- -# Tools -#------------------------------------------------------------------------------- -AS = $(BIN_PATH)/msp430-elf-as -CC = $(BIN_PATH)/msp430-elf-gcc -LD = $(BIN_PATH)/msp430-elf-ld -OBJDUMP = $(BIN_PATH)/msp430-elf-objdump -OBJCOPY = $(BIN_PATH)/msp430-elf-objcopy -SIZE = $(BIN_PATH)/msp430-elf-size -IMAGE_GEN = $(TOOL_PATH)/image_gen/image_gen - -# Remove -g to exclude debugging information -CC_OPTS = -nostartfiles -pipe -fwhole-program -fdata-sections -ffunction-sections -Xlinker --gc-sections -Wl,-static -Wall -CC_OPTS += -lm -Os -mcpu=msp430 -T boot_linker_script.x -minrt -Xassembler --mY -mhwmult=none - -#------------------------------------------------------------------------------- -# Paths -#------------------------------------------------------------------------------- -# Path to NEO430 image generator: -TOOL_PATH = ../tools - -#------------------------------------------------------------------------------- -# PC Host Compiler -#------------------------------------------------------------------------------- -CC_X86 = g++ -Wall -O -g -DWIN32 = -DWIN32 - -#------------------------------------------------------------------------------- -# Tool Targets -#------------------------------------------------------------------------------- -# Tools -.PHONY: tools -tools: $(IMAGE_GEN) - -$(IMAGE_GEN): $(TOOL_PATH)/image_gen/main.cpp - @echo Creating $@ - @$(CC_X86) $< -o $@ - -#------------------------------------------------------------------------------- -# Application Targets -#------------------------------------------------------------------------------- -# Assemble startup code -crt0.elf: boot_crt0.asm - @$(AS) -g -mY -mcpu=msp430 $< -o $@ - -# Compile app sources -main.elf: bootloader.c crt0.elf - @echo NEO430 BOOTLOADER compilation script - @$(CC) $(CC_OPTS) $< -o $@ - @echo Memory utilization: - @$(SIZE) main.elf - -# Generate final executable (from .image section only) -bootloader.bin: main.elf - @$(OBJCOPY) -I elf32-little $< -j .image -O binary $@ - -# Assembly listing file -bootloader.s: main.elf - @$(OBJDUMP) -S --disassemble $< > $@ - -# Converter for VHLD memory init image -neo430_bootloader_image.vhd: bootloader.bin $(IMAGE_GEN) - @echo Image size \(bytes\): - @stat -c "%s" bootloader.bin - @$(IMAGE_GEN) -bld_img $< $@ - @echo Installing bootloader image to rtl/core/neo430_bootloader_image.vhd - @cp neo430_bootloader_image.vhd ../../rtl/core/. - @rm -f *.elf *.bin main.s neo430_bootloader_image.vhd - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -.PHONY: clean -clean: - @rm -f *.elf *.bin *.s neo430_bootloader_image.vhd - -#------------------------------------------------------------------------------- -# eof Index: sw/bootloader/boot_linker_script.x =================================================================== --- sw/bootloader/boot_linker_script.x (revision 137) +++ sw/bootloader/boot_linker_script.x (nonexistent) @@ -1,84 +0,0 @@ -/* ################################################################################################# */ -/* # < NEO430 MSPGCC bootloader linker script > # */ -/* # ********************************************************************************************* # */ -/* # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # */ -/* # Copyright by Stephan Nolting: stnolting@gmail.com # */ -/* # # */ -/* # This source file may be used and distributed without restriction provided that this copyright # */ -/* # statement is not removed from the file and that any derivative work contains the original # */ -/* # copyright notice and the associated disclaimer. # */ -/* # # */ -/* # This source file is free software; you can redistribute it and/or modify it under the terms # */ -/* # of the GNU Lesser General Public License as published by the Free Software Foundation, # */ -/* # either version 3 of the License, or (at your option) any later version. # */ -/* # # */ -/* # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # */ -/* # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # */ -/* # See the GNU Lesser General Public License for more details. # */ -/* # # */ -/* # You should have received a copy of the GNU Lesser General Public License along with this # */ -/* # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # */ -/* # ********************************************************************************************* # */ -/* # Stephan Nolting, Hannover, Germany 27.11.2016 # */ -/* ################################################################################################# */ - -OUTPUT_ARCH(msp430) - - -/* Address space layout - only the boot rom size is required here */ -MEMORY -{ - boot_rom (rx) : ORIGIN = 0xF000, LENGTH = 0x0800 -} - -/* Final executable layout */ -SECTIONS -{ - .image : - { - . = ALIGN(2); - KEEP(crt0.elf(.text)); - - *(.init .init.*); - *(.init0); /* Start here after reset. */ - *(.init1); /* User definable */ - *(.init2); /* Initialize stack */ - *(.init3); /* Initialize hardware */ - *(.init4); /* Copy data to .data, clear bss */ - *(.init5); /* User definable. */ - *(.init6); /* C++ constructors. */ - *(.init7); /* User definable. */ - *(.init8); /* User definable. */ - *(.init9); /* Call main(). */ - - *(.fini9); /* Falls into here after main(). User definable. */ - *(.fini8); /* User definable. */ - *(.fini7); /* User definable. */ - *(.fini6); /* C++ destructors. */ - *(.fini5); /* User definable. */ - *(.fini4); /* User definable. */ - *(.fini3); /* User definable. */ - *(.fini2); /* User definable. */ - *(.fini1); /* User definable. */ - *(.fini0); /* Infinite loop after program termination. */ - *(.fini .fini.*); - - . = ALIGN(2); - __ctors_start = .; - KEEP(*(.ctors)); - __ctors_end = .; - __dtors_start = .; - KEEP(*(.dtors)); - __dtors_end = .; - - . = ALIGN(2); - *(.text .text.*); - *(.near.text .near.text.*); - - . = ALIGN(2); - *(.rodata .rodata.*); - *(.data .data.*); - *(.sdata .sdata.*); - - } > boot_rom -} Index: sw/bootloader/make.bat =================================================================== --- sw/bootloader/make.bat (revision 137) +++ sw/bootloader/make.bat (nonexistent) @@ -1,79 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 bootloader (!) compilation script - Windows Version > # -@REM # ********************************************************************************************* # -@REM # Edit the BIN_PATH variable to point to your compiler's binary folder! # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 14.10.2017 # -@REM ################################################################################################# - - -@REM ----------------------USER CONFIGURATION---------------------- -@REM Path of MSPGCC binaries: -@set BIN_PATH=C:\msp430-gcc-6.4.0.32_win32\bin -@REM -------------------------------------------------------------- - -@REM Tools -@set AS=%BIN_PATH%\msp430-elf-as -@set CC=%BIN_PATH%\msp430-elf-gcc -@set LD=%BIN_PATH%\msp430-elf-ld -@set OBJDUMP=%BIN_PATH%\msp430-elf-objdump -@set OBJCOPY=%BIN_PATH%\msp430-elf-objcopy -@set IMAGE_GEN=..\tools\image_gen\image_gen -@set SIZE=%BIN_PATH%\msp430-elf-size - -@echo NEO430 BOOTLOADER compilation script - -@REM Compiler flags -@set CC_OPTS=-nostartfiles -pipe -fwhole-program -fdata-sections -ffunction-sections -Xlinker --gc-sections -Wl,-static -Wall -@set CC_OPTS=%CC_OPTS% -lm -Os -mcpu=msp430 -T boot_linker_script.x -minrt -Xassembler --mY -mhwmult=none - - -@REM Assemble startup code -@%AS% -mcpu=msp430 boot_crt0.asm -mY -o crt0.elf - -@REM Compile app sources -@%CC% %CC_OPTS% bootloader.c -o main.elf - -@REM Print memory utilization -@echo Memory utilization: -@%SIZE% main.elf - -@REM Generate ASM listing -@%OBJDUMP% -D -S -z main.elf > bootloader.s - -@REM Extract final executable -@%OBJCOPY% -I elf32-little main.elf -j .image -O binary bootloader.bin - -@REM Converter for VHLD memory init image -@%IMAGE_GEN% -bld_img bootloader.bin neo430_bootloader_image.vhd - -@REM Install bootloader image -@echo Installing bootloader image to rtl\core\neo430_bootloader_image.vhd -@copy neo430_bootloader_image.vhd ..\..\rtl\core\. > nul - -@REM Display file size -@for %%A in (bootloader.bin) do @set fileSize=%%~zA -@echo Image size (bytes): -@echo %fileSize% - - -@REM Clean up -@del main.elf crt0.elf main.elf bootloader.bin bootloader.asm neo430_bootloader_image.vhd Index: sw/example/timer_simple/main.c =================================================================== --- sw/example/timer_simple/main.c (revision 137) +++ sw/example/timer_simple/main.c (nonexistent) @@ -1,97 +0,0 @@ -// ################################################################################################# -// # < simple timer usage example > # -// # ********************************************************************************************* # -// # Prints "TICK" every second (1Hz) using the timer module. # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - -// Function prototypes -void __attribute__((__interrupt__)) timer_irq_handler(void); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1<> 12 - uint32_t f_clock = ((uint32_t)CLOCKSPEED_HI<<16) | (uint32_t)CLOCKSPEED_LO; - TMR_THRES = (uint16_t)(f_clock >> 12); - - // clear timer counter - TMR_CNT = 0; - - // configure timer operation - TMR_CT = (1< prescaler =4096 - - // enable global IRQs - eint(); - - // do something else... - while (1) { - sleep(); // go to power down mode - } - - return 0; -} - - -/* ------------------------------------------------------------ - * INFO Timer interrupt handler - * ------------------------------------------------------------ */ -void __attribute__((__interrupt__)) timer_irq_handler(void) { - - uart_br_print("TICK\n"); -} Index: sw/example/timer_simple/Makefile =================================================================== --- sw/example/timer_simple/Makefile (revision 137) +++ sw/example/timer_simple/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/timer_simple/make.bat =================================================================== --- sw/example/timer_simple/make.bat (revision 137) +++ sw/example/timer_simple/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/README.txt =================================================================== --- sw/example/README.txt (revision 137) +++ sw/example/README.txt (nonexistent) @@ -1,39 +0,0 @@ -About: The NEO430 example programs -by Stephan Nolting, 17th of February, 2017 - -========================================================================= -Adding new projects: -========================================================================= -Copy an existing example project (e.g. "blink_led") into this folder and start from there. ;) -This will ensure, that all path depencies will be correct. - - -========================================================================= -Compiling an application: -========================================================================= -All example projects feature batch make scripts (make.bat) for using Windows and Linux-style -makefiles (Makefile) for using Cygwin/Linux. - -For Windows: -Execute "make.bat" inside an example program folder to generate the target files. -The compile script uses "main.c" as default main source file. -Execute "make.bat " to set your specific main source file. - -For Linux/Cygwin: -Execute "make" inside an example program folder to generate the target files. -The compile script uses "main.c" as default main source file. -Execute "make MAIN=" to set your specific main source file. - - -========================================================================= -Generated target files: -========================================================================= - main.s : Assembler listing file (for debugging). - main.bin : Binary executable (including EXE header), meant for uploading via the bootloader (serial console). - - Additionally, a main.elf object file is created in the sw\common\ folder for further objecft file analysis. - -Also, the IMEM initialization image "application_image.txt" in the rtl\core folder is generated. -This image is automatically loaded into the processor's IMEM during synthesis. This allows to start -the non-volatile application directly from the internal ROM (if you are not using the bootloader to -install the image). Index: sw/example/sw_pwm/Makefile =================================================================== --- sw/example/sw_pwm/Makefile (revision 137) +++ sw/example/sw_pwm/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/sw_pwm/make.bat =================================================================== --- sw/example/sw_pwm/make.bat (revision 137) +++ sw/example/sw_pwm/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/sw_pwm/main.c =================================================================== --- sw/example/sw_pwm/main.c (revision 137) +++ sw/example/sw_pwm/main.c (nonexistent) @@ -1,140 +0,0 @@ -// ################################################################################################# -// # < Software PWM generating a "heartbeat" > # -// # ********************************************************************************************* # -// # Generates a heartbeat with software PWM using the internal timer. # -// # PWM refresh rate: 1MHz. # -// # Output via GPIO.out(0) (bootloader status LED) # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Function prototypes -void __attribute__((__interrupt__)) timer_irq_handler(void); - -// Global variables -volatile uint8_t pwm_cnt; -volatile uint8_t led_brightness; - -// Configuration -#define LED_PIN 0 // GPIO output pin #0 -#define MIN_VAL 5 // minimum intensity (0 = 0%) -#define MAX_VAL 255 // maximum intensity (255 = 100%) -#define BAUD_RATE 19200 - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1< PRSC = 128 - - // beat - uint16_t beat = 0; - beat = (uint16_t)(f_clock / 10000); - - // init IRQ variables - pwm_cnt = 0; - led_brightness = MIN_VAL; - - // enable global IRQs - eint(); - - // generate heartbeat - uint8_t up_down = 0; // start with decreasing intensity - while (1) { - // min/max reached? - if ((led_brightness == MAX_VAL) || (led_brightness == MIN_VAL)) - up_down = ~up_down; - - if (up_down) // increase brightness - led_brightness++; - else // decrease brightness - led_brightness--; - - uint16_t i = 0; - for (i=0; i # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/cfu_test/make.bat =================================================================== --- sw/example/cfu_test/make.bat (revision 137) +++ sw/example/cfu_test/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/cfu_test/main.c =================================================================== --- sw/example/cfu_test/main.c (revision 137) +++ sw/example/cfu_test/main.c (nonexistent) @@ -1,182 +0,0 @@ -// ################################################################################################# -// # < Custom Functions Unit Test Program > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - -// Prototypes -void verify16(char *s, uint16_t a, uint16_t b); -void verify8(char *s, uint8_t a, uint8_t b); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1< # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/game_of_life/make.bat =================================================================== --- sw/example/game_of_life/make.bat (revision 137) +++ sw/example/game_of_life/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/game_of_life/main.c =================================================================== --- sw/example/game_of_life/main.c (revision 137) +++ sw/example/game_of_life/main.c (nonexistent) @@ -1,277 +0,0 @@ -// ################################################################################################# -// # < Conway's Game of Life > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define NUM_CELLS_X 128 // must be a multiple of 8 -#define NUM_CELLS_Y 32 -#define BAUD_RATE 19200 - -// Global variables -uint8_t universe[2][NUM_CELLS_X/8][NUM_CELLS_Y]; - -// Prototypes -void clear_universe(uint8_t u); -void set_cell(uint8_t u, int16_t x, int16_t y); -uint8_t get_cell(uint8_t u, int16_t x, int16_t y); -uint8_t get_neighborhood(uint8_t u, int16_t x, int16_t y); -void print_universe(uint8_t u); -uint32_t xorshift32(void); -uint16_t pop_count(uint8_t u); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - uint8_t u = 0, cell = 0, n = 0; - int16_t x, y; - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1<> 6) + 1); - } - - return 0; -} - - -/* ------------------------------------------------------------ - * INFO Print universe u to console - * ------------------------------------------------------------ */ -void print_universe(uint8_t u){ - - int16_t x, y; - - uart_putc('+'); - for (x=0; x= NUM_CELLS_X) || (y >= NUM_CELLS_Y)) - return; // out of range - - universe[u][x>>3][y] |= 1 << (7 - (x & 7)); -} - - -/* ------------------------------------------------------------ - * INFO Get state of cell - * RETURN Cell state (DEAD or ALIVE) - * ------------------------------------------------------------ */ -uint8_t get_cell(uint8_t u, int16_t x, int16_t y){ - - // range check: wrap around -> torus-style universe - if (x < 0) - x = NUM_CELLS_X-1; - - if (x > NUM_CELLS_X-1) - x = 0; - - if (y < 0) - y = NUM_CELLS_Y-1; - - if (y > NUM_CELLS_Y-1) - y = 0; - - // check bit according to cell - uint8_t tmp = universe[u][x>>3][y]; - tmp &= 1 << (7 - (x & 7)); - - if (tmp == 0) - return 0; - else - return 1; -} - - -/* ------------------------------------------------------------ - * INFO Get number of alive cells in direct neigbourhood - * RETURN Number of set cells in neigbourhood - * ------------------------------------------------------------ */ -uint8_t get_neighborhood(uint8_t u, int16_t x, int16_t y){ - -// Cell index layout: -// 012 -// 3#4 -// 567 - - uint8_t num = 0; - num += get_cell(u, x-1, y-1); // 0 - num += get_cell(u, x, y-1); // 1 - num += get_cell(u, x+1, y-1); // 2 - num += get_cell(u, x-1, y); // 3 - num += get_cell(u, x+1, y); // 4 - num += get_cell(u, x-1, y+1); // 5 - num += get_cell(u, x, y+1); // 6 - num += get_cell(u, x+1, y+1); // 7 - - return num; -} - - -/* ------------------------------------------------------------ - * INFO Pseudo-random number generator - * RETURN 32-bit random data - * ------------------------------------------------------------ */ -uint32_t xorshift32(void) { - - static uint32_t x32 = 314159265; - - x32 ^= x32 << 13; - x32 ^= x32 >> 17; - x32 ^= x32 << 5; - - return x32; -} - - -/* ------------------------------------------------------------ - * INFO Population count - * RETURN 16-bit number of living cells in universe u - * ------------------------------------------------------------ */ -uint16_t pop_count(uint8_t u) { - - uint16_t x, y, cnt; - - cnt = 0; - for (x=0; x # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/wdt_test/make.bat =================================================================== --- sw/example/wdt_test/make.bat (revision 137) +++ sw/example/wdt_test/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/wdt_test/main.c =================================================================== --- sw/example/wdt_test/main.c (revision 137) +++ sw/example/wdt_test/main.c (nonexistent) @@ -1,85 +0,0 @@ -// ################################################################################################# -// # < Test program for the Watchdog Timer (WDT) > # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1<>>\n\n"); - - // check if WDT was synthesized, exit if no WDT is available - if (!(SYS_FEATURES & (1< # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/morse_translator/main.c =================================================================== --- sw/example/morse_translator/main.c (revision 137) +++ sw/example/morse_translator/main.c (nonexistent) @@ -1,202 +0,0 @@ -// ################################################################################################# -// # < Morse code translator > # -// # ********************************************************************************************* # -// # Translates a text string into Morse code. The encode can only encode letters. # -// # Output via GPIO.output(0) (bootloader status LED). # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define MAX_STRING_LENGTH 128 // max length of plain morse text -#define LED_PIN 0 // GPIO output pin #0 -#define TIME_PRSC 192 -#define BAUD_RATE 19200 - -// Global vars -uint32_t time_base; - -// Prototypes -void send_morse(char *s); - -// Morse alphabet -char morse_code[][7] = { - "--..--", // , - "-....-", // - - ".-.-.-", // . - "-..-.", // / - - "-----", // 0 - ".----", // 1 - "..---", // 2 - "...--", // 3 - "....-", // 4 - ".....", // 5 - "-....", // 6 - "--...", // 7 - "---..", // 8 - "----.", // 9 - - "---...", // : - "-.-.-.", // ; - "", // < (not implemented) - "-...-", // = - "", // > (not implemented) - "..--..", // ? - "", // @ (not implemented) - - ".-", // A - "-...", // B - "-.-.", // C - "-..", // D - ".", // E - "..-.", // F - "--.", // G - "....", // H - "..", // I - ".---", // J - "-.-", // K - ".-..", // L - "--", // M - "-.", // N - "---", // O - ".--.", // P - "--.-", // Q - ".-.", // R - "...", // S - "-", // T - "..-", // U - "...-", // V - ".--", // W - "-..-", // X - "-.--", // Y - "--..", // Z -}; - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - char buffer[MAX_STRING_LENGTH]; - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1<= TIME_PRSC) { - clock = clock - TIME_PRSC; - time_base++; // time base for a 'Dit' - } - - uart_br_print("\n--- Morse code translator ---\n"); - uart_br_print("Enter a string to translate it to Morse code.\n"); - uart_br_print("Output via high-active LED at GPIO.out(0) (bootloader status LED).\n"); - - // check if GPIO unit was synthesized, exit if no GPIO is available - if (!(SYS_FEATURES & (1<= 'a') && (c <= 'z')) - c -= 32; - - // in valid alphabet? - if ((c >= ',') && (c <= 'Z')) { - uint8_t index = c - ','; - uart_br_print(" "); - send_morse(morse_code[index]); - - uint32_t time = time_base * 3; // inter-letter pause - while(time--) - asm volatile ("nop"); - - } - // user abort? - if (uart_char_received() != 0) { - uart_br_print("\nAborted."); - break; - } - } - - } - - return 0; -} - - -/* ------------------------------------------------------------ - * INFO Send morse code via LED pin - * PARAM *s pointer to source morse symbol string - * ------------------------------------------------------------ */ -void send_morse(char *s){ - - char c = 0; - uint32_t time = 0; - - while ((c = *s++)) { - - gpio_pin_set(LED_PIN); // LED on - - if (c == '.') - time = time_base; - else if (c == '-') - time = time_base * 3; - else - time = 0; - - uart_putc(c); - - // wait - while(time--) - asm volatile ("nop"); - - gpio_pin_clr(LED_PIN); // LED off - - // inter-symbol pause - time = time_base; - while(time--) - asm volatile ("nop"); - } -} \ No newline at end of file Index: sw/example/morse_translator/Makefile =================================================================== --- sw/example/morse_translator/Makefile (revision 137) +++ sw/example/morse_translator/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/hw_analysis/Makefile =================================================================== --- sw/example/hw_analysis/Makefile (revision 137) +++ sw/example/hw_analysis/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/hw_analysis/make.bat =================================================================== --- sw/example/hw_analysis/make.bat (revision 137) +++ sw/example/hw_analysis/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/hw_analysis/main.c =================================================================== --- sw/example/hw_analysis/main.c (revision 137) +++ sw/example/hw_analysis/main.c (nonexistent) @@ -1,142 +0,0 @@ -// ################################################################################################# -// # < Processor hardware analysis tool > # -// # ********************************************************************************************* # -// # Prints various information from the system. # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - -// Prototypes -void print_state(uint16_t d); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1<> 8) & 0x0007) { - case 0: prsc = 2; break; - case 1: prsc = 4; break; - case 2: prsc = 8; break; - case 3: prsc = 64; break; - case 4: prsc = 128; break; - case 5: prsc = 1024; break; - case 6: prsc = 2048; break; - case 7: prsc = 4096; break; - default: prsc = 0; break; - } - uint32_t baud_value = clock / (uint32_t)(prsc * baud); - _printf("UART Baud rate: %n\n", baud_value); - - - // Interrupt vectors - // -------------------------------------------- - _printf("\nInterrupt Vectors"); - _printf("\n(0) IRQVEC_TIMER -> 0x%x", IRQVEC_TIMER); - _printf("\n(1) IRQVEC_USART -> 0x%x", IRQVEC_USART); - _printf("\n(2) IRQVEC_GPIO -> 0x%x", IRQVEC_GPIO); - _printf("\n(3) IRQVEC_EXT -> 0x%x", IRQVEC_EXT); - - - // System features - // -------------------------------------------- - uint16_t ft = SYS_FEATURES; - _printf("\n\nSystem features\n"); - // CFU - _printf("- Custom Functions Unit: "); - print_state(ft & (1< # -// # ********************************************************************************************* # -// # Prints a message whenever a GPIO input pin goes HIGH. Uses the PIO pin-change interrupt. # -// # Also outputs a counter on GPIO.OUT[7:0], driven by the timer interrupt. # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - -// Function prototypes -void __attribute__((__interrupt__)) gpio_irq_handler(void); -void __attribute__((__interrupt__)) timer_irq_handler(void); -void delay(uint16_t t); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1< PRSC = 4096 - - // enable global IRQs - eint(); - - // do nothing - while (1) { - sleep(); - } - - return 0; -} - - -/* ------------------------------------------------------------ - * INFO GPIO pin-change interrupt handler - * ------------------------------------------------------------ */ -void __attribute__((__interrupt__)) gpio_irq_handler(void) { - - // we cannot ensure to actually get the specific state of - // the input register, which caused the IRQ - - uart_br_print("GPIO pin.change interrupt! Current input state: 0x"); - uart_print_hex_word(GPIO_IN); - uart_br_print("\n"); -} - - -/* ------------------------------------------------------------ - * INFO Timer interrupt handler - * ------------------------------------------------------------ */ -void __attribute__((__interrupt__)) timer_irq_handler(void) { - - // increment LED counter - GPIO_OUT = (GPIO_OUT + 1) & 0x00FF; -} - Index: sw/example/pio_interrupt/Makefile =================================================================== --- sw/example/pio_interrupt/Makefile (revision 137) +++ sw/example/pio_interrupt/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/pio_interrupt/make.bat =================================================================== --- sw/example/pio_interrupt/make.bat (revision 137) +++ sw/example/pio_interrupt/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/blink_led/main.c =================================================================== --- sw/example/blink_led/main.c (revision 137) +++ sw/example/blink_led/main.c (nonexistent) @@ -1,80 +0,0 @@ -// ################################################################################################# -// # < Blinking LED example program > # -// # ********************************************************************************************* # -// # Displays an 8-bit counter on the high-active LEDs connected to the parallel output port. # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include "../../lib/neo430/neo430.h" - -// Configuration -#define BAUD_RATE 19200 - -// Function prototypes -void delay(uint16_t t); - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1< # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof Index: sw/example/blink_led/make.bat =================================================================== --- sw/example/blink_led/make.bat (revision 137) +++ sw/example/blink_led/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/wb_terminal/make.bat =================================================================== --- sw/example/wb_terminal/make.bat (revision 137) +++ sw/example/wb_terminal/make.bat (nonexistent) @@ -1,55 +0,0 @@ -@REM ################################################################################################# -@REM # < NEO430 make file - Windows version > # -@REM # ********************************************************************************************* # -@REM # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -@REM # Copyright by Stephan Nolting: stnolting@gmail.com # -@REM # # -@REM # This source file may be used and distributed without restriction provided that this copyright # -@REM # statement is not removed from the file and that any derivative work contains the original # -@REM # copyright notice and the associated disclaimer. # -@REM # # -@REM # This source file is free software; you can redistribute it and/or modify it under the terms # -@REM # of the GNU Lesser General Public License as published by the Free Software Foundation, # -@REM # either version 3 of the License, or (at your option) any later version. # -@REM # # -@REM # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -@REM # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -@REM # See the GNU Lesser General Public License for more details. # -@REM # # -@REM # You should have received a copy of the GNU Lesser General Public License along with this # -@REM # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -@REM # ********************************************************************************************* # -@REM # Stephan Nolting, Hannover, Germany 23.09.2016 # -@REM ################################################################################################# - - -@REM Path to common files -@set COMMON_PATH=..\..\common - -@REM Path of this project -@set PROJECT_PATH=%~dp0 - -@REM Delete old project files -@del main.bin main.s main.vhd - -@REM Check if MAIN source file is specified -@REM set "main.c" if not defined -@if [%1]==[] ( - @set MAIN=main.c -) else ( - @set MAIN=%1 -) - -@REM Compile project's main.c and get main.bin (executable), -@REM main.s (listing file) and VHDL memory initialzation file -@cd %COMMON_PATH% -@call compile.bat %PROJECT_PATH%\%MAIN% -@move main.bin %PROJECT_PATH%\. > nul -@move main.s %PROJECT_PATH%\. > nul -@cd %PROJECT_PATH% - - -@REM Display file size -@for %%A in (main.bin) do @set fileSize=%%~zA -@echo Final executable size (bytes): -@echo %fileSize% Index: sw/example/wb_terminal/main.c =================================================================== --- sw/example/wb_terminal/main.c (revision 137) +++ sw/example/wb_terminal/main.c (nonexistent) @@ -1,349 +0,0 @@ -// ################################################################################################# -// # < Wishbone bus explorer > # -// # ********************************************************************************************* # -// # Manual access to the registers of modules, which are connected to Wishbone bus. This is also # -// # a neat example to illustrate the construction of a console-like user interface. # -// # ********************************************************************************************* # -// # This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -// # Copyright by Stephan Nolting: stnolting@gmail.com # -// # # -// # This source file may be used and distributed without restriction provided that this copyright # -// # statement is not removed from the file and that any derivative work contains the original # -// # copyright notice and the associated disclaimer. # -// # # -// # This source file is free software; you can redistribute it and/or modify it under the terms # -// # of the GNU Lesser General Public License as published by the Free Software Foundation, # -// # either version 3 of the License, or (at your option) any later version. # -// # # -// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -// # See the GNU Lesser General Public License for more details. # -// # # -// # You should have received a copy of the GNU Lesser General Public License along with this # -// # source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -// # ********************************************************************************************* # -// # Stephan Nolting, Hannover, Germany 06.10.2017 # -// ################################################################################################# - - -// Libraries -#include -#include -#include "../../lib/neo430/neo430.h" - -// Global variables -uint8_t wb_config = 0; - -// Prototypes -void setup_wb(void); -void read_wb_address(void); -void write_wb_address(void); -void dump_wb(void); -uint32_t hex_str_to_uint32(char *buffer); - -// Configuration -#define MAX_CMD_LENGTH 16 -#define BAUD_RATE 19200 - - -/* ------------------------------------------------------------ - * INFO Main function - * ------------------------------------------------------------ */ -int main(void) { - - // setup UART - uart_set_baud(BAUD_RATE); - USI_CT = (1< "); - length = uart_scan(buffer, MAX_CMD_LENGTH); - uart_br_print("\n"); - - if (!length) // nothing to be done - continue; - - // decode input - selection = 0; - if (!strcmp(buffer, "help")) - selection = 1; - if (!strcmp(buffer, "setup")) - selection = 2; - if (!strcmp(buffer, "read")) - selection = 3; - if (!strcmp(buffer, "write")) - selection = 4; - if (!strcmp(buffer, "dump")) - selection = 5; - if (!strcmp(buffer, "reset")) - selection = 6; - if (!strcmp(buffer, "exit")) - selection = 7; - - // execute command - switch(selection) { - - case 1: // print help menu - uart_br_print("Available commands:\n" - " help - show this text\n" - " setup - configure WB interface\n" - " read - read from WB address\n" - " write - write to WB address\n" - " dump - dump data from WB addresses\n" - " reset - perform soft-reset\n" - " exit - exit program and return to bootloader\n"); - break; - - case 2: // setup Wishbone adapter - setup_wb(); - break; - - case 3: // read from address - read_wb_address(); - break; - - case 4: // write to address - write_wb_address(); - break; - - case 5: // dump data - dump_wb(); - break; - - case 6: // restart - while ((USI_CT & (1<= '0') && (c <= '9')) - d = (uint32_t)(c - '0'); - else if ((c >= 'a') && (c <= 'f')) - d = (uint32_t)((c - 'a') + 10); - else if ((c >= 'A') && (c <= 'F')) - d = (uint32_t)((c - 'A') + 10); - else - d = 0; - - res = res + (d << (length*4)); - } - - return res; -} Index: sw/example/wb_terminal/Makefile =================================================================== --- sw/example/wb_terminal/Makefile (revision 137) +++ sw/example/wb_terminal/Makefile (nonexistent) @@ -1,74 +0,0 @@ -################################################################################################# -# < NEO430 make file - Linux version > # -# ********************************************************************************************* # -# Application's relative path from the common folder and application's main file are passed as # -# arguments. Use "make MAIN=" to define other main file. "make" or "make all" will build # -# the default main "make clean" to clean up generated files. # -# ********************************************************************************************* # -# This file is part of the NEO430 Processor project: https://github.com/stnolting/neo430 # -# Copyright by Stephan Nolting: stnolting@gmail.com # -# # -# This source file may be used and distributed without restriction provided that this copyright # -# statement is not removed from the file and that any derivative work contains the original # -# copyright notice and the associated disclaimer. # -# # -# This source file is free software; you can redistribute it and/or modify it under the terms # -# of the GNU Lesser General Public License as published by the Free Software Foundation, # -# either version 3 of the License, or (at your option) any later version. # -# # -# This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# See the GNU Lesser General Public License for more details. # -# # -# You should have received a copy of the GNU Lesser General Public License along with this # -# source; if not, download it from https://www.gnu.org/licenses/lgpl-3.0.en.html # -# ********************************************************************************************* # -# Stephan Nolting, Hannover, Germany 23.09.2016 # -################################################################################################# - - -#------------------------------------------------------------------------------- -# Make defaults -#------------------------------------------------------------------------------- -.SUFFIXES: -.PHONY: all -.DEFAULT_GOAL = all - - -#------------------------------------------------------------------------------- -# Definitions -#------------------------------------------------------------------------------- -# default main file -ifeq ($(MAIN),) - MAIN = main.c -endif - -# relative path TO common foler -COMMON_PATH = ../../common - -# relative path from common folder to current folder -mkfile_path = $(abspath $(lastword $(MAKEFILE_LIST))) -curr_folder = $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -APP_PATH = ../example/$(curr_folder) - - -#------------------------------------------------------------------------------- -# Main target -#------------------------------------------------------------------------------- -all: - @echo $(WARNING) - @make -r -s -C $(COMMON_PATH) APP_DIR=$(APP_PATH) MAIN=$(MAIN) - @echo Final executable size '(bytes)': - @stat -c "%s" main.bin - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -clean: - @rm -f main.bin main.s - @make -r -s -C $(COMMON_PATH) clean - - -#------------------------------------------------------------------------------- -# eof

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.