├── .gitignore ├── README.md ├── Screenshot 2023-05-03 at 18.27.54.png ├── change.log ├── documents ├── Getting_started.pdf ├── uCore.pdf ├── uCore_Public_License.pdf ├── uCore_instructions.pdf ├── uCore_overview.pdf └── uForth.pdf ├── gforth062.sh ├── modelSim ├── break.do ├── core.do ├── core_cache.do ├── debug.do ├── download.do ├── dstack.do ├── ext_datamem.do ├── handshake.do ├── microCore.mpf ├── progload.do ├── upload.do └── work │ └── .gitignore ├── software ├── bootload.fs ├── bootload_sim.fs ├── constants.fs ├── coretest.fs ├── debugger.fs ├── disasm.fs ├── epilog.vhd ├── epilog_internal.vhd ├── extensions.fs ├── float_lib.fs ├── forth_lib.fs ├── header.fs ├── hfloat.fs ├── images.fs ├── library.fs ├── load_template.fs ├── messages.fs ├── microcross.fs ├── monitor.fs ├── multitask.fs ├── objects.fs ├── opcodes.fs ├── prolog.vhd ├── prolog_boot.vhd ├── prolog_internal.vhd ├── rs232_linux.fs ├── rs232_macosx.fs ├── rs232_windows.fs ├── sim.fs ├── sim_break.fs ├── sim_core.fs ├── sim_debug.fs ├── sim_download.fs ├── sim_handshake.fs ├── sim_progload.fs ├── sim_template.fs ├── sim_upload.fs ├── task_lib.fs ├── umbilical.fs └── vhdl.fs ├── synplify ├── get_version.tcl ├── microCore.fdc └── microCore.prj └── vhdl ├── architecture_pkg.vhd ├── architecture_pkg_sim.vhd ├── architectures ├── 12 │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── 16 │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── 27 │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── 32 │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── 16b │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── 32b │ ├── architecture_pkg.vhd │ ├── architecture_pkg_sim.vhd │ └── uDatacache.vhd ├── uDatacache_byte.vhd └── uDatacache_cell.vhd ├── bench.vhd ├── bootload.vhd ├── bootload_sim.vhd ├── debugger.vhd ├── external_SRAM.vhd ├── fpga.vhd ├── functions_pkg.vhd ├── header.vhd ├── program.vhd ├── uArithmetic.vhd ├── uCntrl.vhd ├── uCore.vhd ├── uDatacache.vhd ├── uProgmem.vhd └── uart.vhd /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | synplify/.recordref 3 | 4 | synplify/dm/ 5 | 6 | *.areasrr 7 | 8 | *.edn 9 | 10 | *.fse 11 | 12 | *.htm 13 | 14 | *.srd 15 | 16 | *.srm 17 | 18 | *.srr 19 | 20 | *.db 21 | 22 | *.srs 23 | 24 | *.rpt 25 | 26 | *.lpf 27 | 28 | *.txt 29 | 30 | *.prs 31 | 32 | *.rptmap 33 | 34 | synplify/synlog/ 35 | 36 | synplify/syntmp/ 37 | 38 | synplify/synwork/ 39 | 40 | *.mti 41 | 42 | modelSim/transcript 43 | 44 | *.wlf 45 | 46 | software/program.mem 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # microCore 2 | microCore is a hardware/software co-design environment based on Forth and VHDL. It supports Communicating Sequential Processes (CSP). 3 | 4 | The hardware is a high-performance, extensible, dual stack, deterministic, real-time processor for embedded FPGA applications. It has been ported to Xilinx, Lattice, Altera/Intel, and Actel/Microsemi FPGAs. The desktop software is a co-design environment consisting of a cross-compiler and an interactive debugger. The VHDL includes a system model which is used by both the desktop software and by the synthesis software. The VHDL is designed so that it is quite easy to add up to 42 additional instructions. 5 | 6 | ### Documentation 7 | 8 | file | content 9 | ------------ | ------------- 10 | [uCore_overview.pdf](documents/uCore_overview.pdf) | brief description of its architecture.
11 | [uCore_instructions.pdf](documents/uCore_instructions.pdf) | brief description of its instruction set.
12 | [uCore.pdf](documents/uCore.pdf) | processor manual explaining how to work with it.
13 | [uForth.pdf](documents/uForth.pdf) | description of uCore's assembler and cross-compiler/debugger.
14 | [Getting_started.pdf](documents/Getting_started.pdf) | necessary steps for a first uCore simulation.
15 | [uCore_Public_License.pdf](documents/uCore_Public_License.pdf) | free license for research, development and manufacture. 16 | 17 | ### Introductory Video 18 | 19 | 20 | 21 | 22 | ### Architecture 23 | ![uCore_architecture](https://user-images.githubusercontent.com/77505995/105734708-36113400-5f33-11eb-819f-f72972bb19c1.jpg) 24 | 25 | ### License: 26 | 27 | The public license allows the creation, manufacture and sale of products in general using microCore. It is similar to the BSD and LGPL licenses. 28 | 29 | -------------------------------------------------------------------------------- /Screenshot 2023-05-03 at 18.27.54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/Screenshot 2023-05-03 at 18.27.54.png -------------------------------------------------------------------------------- /change.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/change.log -------------------------------------------------------------------------------- /documents/Getting_started.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/Getting_started.pdf -------------------------------------------------------------------------------- /documents/uCore.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/uCore.pdf -------------------------------------------------------------------------------- /documents/uCore_Public_License.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/uCore_Public_License.pdf -------------------------------------------------------------------------------- /documents/uCore_instructions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/uCore_instructions.pdf -------------------------------------------------------------------------------- /documents/uCore_overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/uCore_overview.pdf -------------------------------------------------------------------------------- /documents/uForth.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/documents/uForth.pdf -------------------------------------------------------------------------------- /gforth062.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo sh -c 'docker run --rm -i --device=/dev/ttyUSB0:/dev/ttyUSB0 --user $(id -u):$(id -g) -t -v $PWD:/home/gforth microcore/gforth_062:latest' 3 | -------------------------------------------------------------------------------- /modelSim/break.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/uCore/warmboot 4 | add wave -noupdate /bench/myFPGA/reset_n 5 | add wave -noupdate /bench/myFPGA/reset 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/cycle_ctr 8 | add wave -noupdate /bench/myFPGA/uCore/clk_en 9 | add wave -noupdate /bench/myFPGA/uCore/uBus 10 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 11 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 12 | add wave -noupdate /bench/myFPGA/flags 13 | add wave -noupdate /bench/bitout 14 | add wave -noupdate -divider Sequencer 15 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 16 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 17 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 18 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 19 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 20 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 21 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 22 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 23 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 24 | add wave -noupdate -divider Datenpfad 25 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 26 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 27 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 28 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 29 | add wave -noupdate -divider {Return Stack} 30 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 31 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 32 | add wave -noupdate /bench/myFPGA/cache_addr 33 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 34 | add wave -noupdate -divider Debugger 35 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 36 | add wave -noupdate -divider Dsu 37 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(20) 38 | add wave -noupdate -divider Rerun 39 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(29) 40 | add wave -noupdate -divider Counter 41 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(28) 42 | add wave -noupdate -divider Tptr 43 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(10) 44 | add wave -noupdate -divider Background 45 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(21) 46 | add wave -noupdate -divider Terminal 47 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(11) 48 | TreeUpdate [SetDefaultTree] 49 | WaveRestoreCursors {{Cursor 1} {207512 ns} 0} {{Cursor 2} {24400 ns} 0} 50 | quietly wave cursor active 1 51 | configure wave -namecolwidth 121 52 | configure wave -valuecolwidth 68 53 | configure wave -justifyvalue left 54 | configure wave -signalnamewidth 1 55 | configure wave -snapdistance 10 56 | configure wave -datasetprefix 0 57 | configure wave -rowmargin 4 58 | configure wave -childrowmargin 2 59 | configure wave -gridoffset 0 60 | configure wave -gridperiod 1 61 | configure wave -griddelta 40 62 | configure wave -timeline 0 63 | configure wave -timelineunits ns 64 | update 65 | WaveRestoreZoom {0 ns} {220500 ns} 66 | -------------------------------------------------------------------------------- /modelSim/core.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/uCore/warmboot 5 | add wave -noupdate /bench/myFPGA/clk 6 | add wave -noupdate /bench/myFPGA/cycle_ctr 7 | add wave -noupdate /bench/myFPGA/delay 8 | add wave -noupdate /bench/myFPGA/clk_en 9 | add wave -noupdate /bench/myFPGA/uBus 10 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 11 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 12 | add wave -noupdate /bench/myFPGA/flags 13 | add wave -noupdate /bench/bitout 14 | add wave -noupdate -divider Sequencer 15 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 16 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 17 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 18 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 19 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 20 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 21 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 22 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 23 | add wave -noupdate -divider Datenpfad 24 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 25 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 26 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 27 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/stack_addr 28 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 29 | add wave -noupdate -divider {Return Stack} 30 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 31 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 32 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 33 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/uCore_control/rstack_addr 34 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/mem_addr 35 | add wave -noupdate -divider Alu 36 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/cin 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_x 38 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_y 39 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_out 40 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/multiplicand 41 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/multiplier 42 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/product 43 | add wave -noupdate -divider Pause 44 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 45 | add wave -noupdate -divider interrupt 46 | add wave -noupdate /bench/myFPGA/flags(0) 47 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ienable 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.ie 49 | add wave -noupdate /bench/myFPGA/int_n 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pending 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/interrupt 52 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.iis 53 | TreeUpdate [SetDefaultTree] 54 | WaveRestoreCursors {{Cursor 1} {1900 ns} 0} {{Cursor 2} {121737 ns} 0} 55 | quietly wave cursor active 1 56 | configure wave -namecolwidth 111 57 | configure wave -valuecolwidth 68 58 | configure wave -justifyvalue left 59 | configure wave -signalnamewidth 1 60 | configure wave -snapdistance 10 61 | configure wave -datasetprefix 0 62 | configure wave -rowmargin 4 63 | configure wave -childrowmargin 2 64 | configure wave -gridoffset 0 65 | configure wave -gridperiod 1 66 | configure wave -griddelta 40 67 | configure wave -timeline 0 68 | configure wave -timelineunits ns 69 | update 70 | WaveRestoreZoom {1004 ns} {3764 ns} 71 | -------------------------------------------------------------------------------- /modelSim/core_cache.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/clk 5 | add wave -noupdate /bench/myFPGA/cycle_ctr 6 | add wave -noupdate /bench/myFPGA/clk_en 7 | add wave -noupdate /bench/myFPGA/uBus 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 10 | add wave -noupdate /bench/myFPGA/flags 11 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 12 | add wave -noupdate /bench/bitout 13 | add wave -noupdate -divider Sequencer 14 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 15 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 16 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 17 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 18 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 19 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 20 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 21 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 22 | add wave -noupdate -divider Datenpfad 23 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 24 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 25 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 26 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/stack_addr 27 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 28 | add wave -noupdate -divider {Return Stack} 29 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 30 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 31 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 32 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/uCore_control/rstack_addr 33 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/mem_addr 34 | add wave -noupdate -divider datamem 35 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/mem_en 36 | add wave -noupdate /bench/myFPGA/internal_data_mem/bytes 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/bytes_d 38 | add wave -noupdate -radix binary /bench/myFPGA/internal_data_mem/bytes_en 39 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/bytea_i 40 | add wave -noupdate /bench/myFPGA/uBus.addr 41 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/addra_i 42 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/addra_d 43 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ena 44 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/wea 45 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/mem_wdata 46 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/dia 47 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/mem_rdata 48 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/doa 49 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(0) 50 | TreeUpdate [SetDefaultTree] 51 | WaveRestoreCursors {{Cursor 1} {1727 ns} 0} {{Cursor 2} {1790 ns} 0} 52 | quietly wave cursor active 2 53 | configure wave -namecolwidth 134 54 | configure wave -valuecolwidth 68 55 | configure wave -justifyvalue left 56 | configure wave -signalnamewidth 1 57 | configure wave -snapdistance 10 58 | configure wave -datasetprefix 0 59 | configure wave -rowmargin 4 60 | configure wave -childrowmargin 2 61 | configure wave -gridoffset 0 62 | configure wave -gridperiod 1 63 | configure wave -griddelta 40 64 | configure wave -timeline 0 65 | configure wave -timelineunits ns 66 | update 67 | WaveRestoreZoom {1255 ns} {2831 ns} 68 | -------------------------------------------------------------------------------- /modelSim/debug.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_reset 5 | add wave -noupdate /bench/myFPGA/uCore/uBus 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/uCore/clk_en 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 10 | add wave -noupdate /bench/bitout 11 | add wave -noupdate -divider Debugger 12 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 13 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_data 14 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_full 15 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_ctr 16 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_reg 17 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_read 18 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_state 19 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_state 20 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_ctr 21 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_reg 22 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_written 23 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_empty 24 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_write 25 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/send_ack 26 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/txd 27 | add wave -noupdate -divider host 28 | add wave -noupdate /bench/sending 29 | add wave -noupdate /bench/send_byte 30 | add wave -noupdate /bench/host_ack 31 | add wave -noupdate /bench/host_full 32 | add wave -noupdate /bench/host_buf 33 | add wave -noupdate /bench/host_reg 34 | add wave -noupdate -divider Sequencer 35 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 36 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 38 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 39 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 40 | add wave -noupdate -divider Datenpfad 41 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 42 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 43 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 44 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 45 | add wave -noupdate -divider {Return Stack} 46 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 47 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 49 | TreeUpdate [SetDefaultTree] 50 | WaveRestoreCursors {{Cursor 1} {64680 ns} 0} {{Cursor 2} {45674 ns} 0} 51 | quietly wave cursor active 1 52 | configure wave -namecolwidth 135 53 | configure wave -valuecolwidth 68 54 | configure wave -justifyvalue left 55 | configure wave -signalnamewidth 1 56 | configure wave -snapdistance 10 57 | configure wave -datasetprefix 0 58 | configure wave -rowmargin 4 59 | configure wave -childrowmargin 2 60 | configure wave -gridoffset 0 61 | configure wave -gridperiod 1 62 | configure wave -griddelta 40 63 | configure wave -timeline 0 64 | configure wave -timelineunits ns 65 | update 66 | WaveRestoreZoom {0 ns} {105 us} 67 | -------------------------------------------------------------------------------- /modelSim/download.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_reset 5 | add wave -noupdate /bench/myFPGA/uCore/uBus 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/uCore/clk_en 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/bitout 10 | add wave -noupdate -divider Debugger 11 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/download 12 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 13 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_data 14 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_full 15 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_reg 16 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_ctr 17 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_state 18 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_state 19 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_ctr 20 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_data 21 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_write 22 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/txd 23 | add wave -noupdate -divider Memory 24 | add wave -noupdate -radix hexadecimal /bench/myFPGA/uCore/debug_unit/addr_ptr 25 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/addr_ctr 26 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_drequest 27 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_denable 28 | add wave -noupdate /bench/myFPGA/uCore/deb_ext_en 29 | add wave -noupdate /bench/myFPGA/uCore/deb_mem_en 30 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/dread 31 | add wave -noupdate /bench/myFPGA/internal_data_mem/enable 32 | add wave -noupdate /bench/myFPGA/internal_data_mem/bytes_en 33 | add wave -noupdate /bench/myFPGA/uCore/memory.write 34 | add wave -noupdate /bench/myFPGA/uCore/memory.addr 35 | add wave -noupdate /bench/myFPGA/uCore/memory.wdata 36 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 37 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/new_outreg 38 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_reg 39 | add wave -noupdate -divider bench 40 | add wave -noupdate /bench/downloading 41 | add wave -noupdate /bench/out_buf 42 | add wave -noupdate /bench/sending 43 | add wave -noupdate /bench/send_byte 44 | add wave -noupdate /bench/host_full 45 | add wave -noupdate /bench/host_ack 46 | add wave -noupdate /bench/host_buf 47 | add wave -noupdate /bench/host_reg 48 | add wave -noupdate -divider Sequencer 49 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 52 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 53 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 54 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 55 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 56 | add wave -noupdate -divider Datenpfad 57 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 58 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 59 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 60 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 61 | add wave -noupdate -divider {Return Stack} 62 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 63 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 64 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 65 | TreeUpdate [SetDefaultTree] 66 | WaveRestoreCursors {{Cursor 1} {129088 ns} 0} {{Cursor 2} {36940 ns} 0} 67 | quietly wave cursor active 1 68 | configure wave -namecolwidth 152 69 | configure wave -valuecolwidth 68 70 | configure wave -justifyvalue left 71 | configure wave -signalnamewidth 1 72 | configure wave -snapdistance 10 73 | configure wave -datasetprefix 0 74 | configure wave -rowmargin 4 75 | configure wave -childrowmargin 2 76 | configure wave -gridoffset 0 77 | configure wave -gridperiod 1 78 | configure wave -griddelta 40 79 | configure wave -timeline 0 80 | configure wave -timelineunits ns 81 | update 82 | WaveRestoreZoom {0 ns} {136500 ns} 83 | -------------------------------------------------------------------------------- /modelSim/dstack.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/uCore/warmboot 4 | add wave -noupdate /bench/myFPGA/reset_n 5 | add wave -noupdate /bench/myFPGA/reset 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/cycle_ctr 8 | add wave -noupdate /bench/myFPGA/uCore/clk_en 9 | add wave -noupdate /bench/myFPGA/uCore/uBus 10 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 11 | add wave -noupdate /bench/myFPGA/flags 12 | add wave -noupdate /bench/myFPGA/ctrl 13 | add wave -noupdate -divider Sequencer 14 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 15 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 16 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 17 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 18 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 19 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 20 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 21 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 22 | add wave -noupdate -divider Datenpfad 23 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 24 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 25 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 26 | add wave -noupdate -radix unsigned /bench/myFPGA/uCore/uCntrl/r.dsp 27 | add wave -noupdate -divider dstack 28 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(896) 29 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(897) 30 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(265) 31 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(266) 32 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(267) 33 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(268) 34 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(269) 35 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/ram(270) 36 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/en 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/we 38 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/addr 39 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/di 40 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/data_stack/do 41 | add wave -noupdate -divider {Return Stack} 42 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 43 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 44 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 45 | add wave -noupdate -divider Alu 46 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/cin 47 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_x 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_y 49 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ladd_out 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/uCore_control/tos_power2 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/multiplicand 52 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/multiplier 53 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/product 54 | add wave -noupdate -divider interrupt 55 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 56 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.ie 57 | add wave -noupdate /bench/myFPGA/int_n 58 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/interrupt 59 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ienable 60 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pending 61 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.iis 62 | TreeUpdate [SetDefaultTree] 63 | WaveRestoreCursors {{Cursor 1} {125420 ns} 0} {{Cursor 2} {2340 ns} 0} 64 | quietly wave cursor active 1 65 | configure wave -namecolwidth 111 66 | configure wave -valuecolwidth 68 67 | configure wave -justifyvalue left 68 | configure wave -signalnamewidth 1 69 | configure wave -snapdistance 10 70 | configure wave -datasetprefix 0 71 | configure wave -rowmargin 4 72 | configure wave -childrowmargin 2 73 | configure wave -gridoffset 0 74 | configure wave -gridperiod 1 75 | configure wave -griddelta 40 76 | configure wave -timeline 0 77 | configure wave -timelineunits ns 78 | update 79 | WaveRestoreZoom {0 ns} {136500 ns} 80 | -------------------------------------------------------------------------------- /modelSim/ext_datamem.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/clk 5 | add wave -noupdate /bench/myFPGA/cycle_ctr 6 | add wave -noupdate /bench/myFPGA/uCore/clk_en 7 | add wave -noupdate /bench/myFPGA/uCore/uBus 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 10 | add wave -noupdate /bench/myFPGA/flags 11 | add wave -noupdate /bench/myFPGA/memory 12 | add wave -noupdate -divider {address diffs} 13 | add wave -noupdate /architecture_pkg/data_width 14 | add wave -noupdate /architecture_pkg/ram_chunks 15 | add wave -noupdate /architecture_pkg/ram_subbits 16 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/residue 17 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/leader 18 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/if_wide_data/data_mux_proc/maxdata 19 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/if_wide_data/data_mux_proc/subaddr 20 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/if_wide_data/data_mux_proc/subdata 21 | add wave -noupdate -divider SRAM 22 | add wave -noupdate /bench/myFPGA/with_external_mem/SRAM/delay_ctr 23 | add wave -noupdate /bench/myFPGA/uCore/deb_denable 24 | add wave -noupdate /bench/myFPGA/uBus.ext_en 25 | add wave -noupdate /bench/ext_ce_n 26 | add wave -noupdate /bench/myFPGA/uBus.addr 27 | add wave -noupdate /bench/ext_we_n 28 | add wave -noupdate /bench/ext_oe_n 29 | add wave -noupdate -radix hexadecimal -childformat {{/bench/ext_addr(13) -radix hexadecimal} {/bench/ext_addr(12) -radix hexadecimal} {/bench/ext_addr(11) -radix unsigned} {/bench/ext_addr(10) -radix unsigned} {/bench/ext_addr(9) -radix unsigned} {/bench/ext_addr(8) -radix unsigned} {/bench/ext_addr(7) -radix unsigned} {/bench/ext_addr(6) -radix unsigned} {/bench/ext_addr(5) -radix unsigned} {/bench/ext_addr(4) -radix unsigned} {/bench/ext_addr(3) -radix unsigned} {/bench/ext_addr(2) -radix unsigned} {/bench/ext_addr(1) -radix unsigned} {/bench/ext_addr(0) -radix unsigned}} -subitemconfig {/bench/ext_addr(13) {-height 15 -radix hexadecimal} /bench/ext_addr(12) {-height 15 -radix hexadecimal} /bench/ext_addr(11) {-height 15 -radix unsigned} /bench/ext_addr(10) {-height 15 -radix unsigned} /bench/ext_addr(9) {-height 15 -radix unsigned} /bench/ext_addr(8) {-height 15 -radix unsigned} /bench/ext_addr(7) {-height 15 -radix unsigned} /bench/ext_addr(6) {-height 15 -radix unsigned} /bench/ext_addr(5) {-height 15 -radix unsigned} /bench/ext_addr(4) {-height 15 -radix unsigned} /bench/ext_addr(3) {-height 15 -radix unsigned} /bench/ext_addr(2) {-height 15 -radix unsigned} /bench/ext_addr(1) {-height 15 -radix unsigned} /bench/ext_addr(0) {-height 15 -radix unsigned}} /bench/ext_addr 30 | add wave -noupdate /bench/ext_data 31 | add wave -noupdate /bench/ext_SRAM/ram(0) 32 | add wave -noupdate /bench/ext_SRAM/ram(1) 33 | add wave -noupdate /bench/ext_SRAM/ram(2) 34 | add wave -noupdate /bench/ext_SRAM/ram(3) 35 | add wave -noupdate -divider Sequencer 36 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 38 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 39 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 40 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 41 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 42 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 43 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 44 | add wave -noupdate -divider Datenpfad 45 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 46 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 47 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/stack_addr 49 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 50 | add wave -noupdate -divider {Return Stack} 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 52 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 53 | add wave -noupdate /bench/myFPGA/cache_addr 54 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 55 | TreeUpdate [SetDefaultTree] 56 | WaveRestoreCursors {{Cursor 1} {2381 ns} 0} {{Cursor 2} {86980 ns} 0} 57 | quietly wave cursor active 2 58 | configure wave -namecolwidth 145 59 | configure wave -valuecolwidth 69 60 | configure wave -justifyvalue left 61 | configure wave -signalnamewidth 1 62 | configure wave -snapdistance 10 63 | configure wave -datasetprefix 0 64 | configure wave -rowmargin 4 65 | configure wave -childrowmargin 2 66 | configure wave -gridoffset 0 67 | configure wave -gridperiod 1 68 | configure wave -griddelta 40 69 | configure wave -timeline 0 70 | configure wave -timelineunits ns 71 | update 72 | WaveRestoreZoom {86294 ns} {87666 ns} 73 | -------------------------------------------------------------------------------- /modelSim/handshake.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_reset 5 | add wave -noupdate /bench/myFPGA/uCore/uBus 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/uCore/clk_en 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s 10 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 11 | add wave -noupdate /bench/bitout 12 | add wave -noupdate -divider Debugger 13 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 14 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_data 15 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_full 16 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_ctr 17 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_reg 18 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_read 19 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_state 20 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/send_ack 21 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_state 22 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_ctr 23 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_reg 24 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_written 25 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_empty 26 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/tx_write 27 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/send_ack 28 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/txd 29 | add wave -noupdate -divider host 30 | add wave -noupdate /bench/sending 31 | add wave -noupdate /bench/host_ack 32 | add wave -noupdate /bench/host_buf 33 | add wave -noupdate /bench/host_full 34 | add wave -noupdate /bench/host_reg 35 | add wave -noupdate -divider Sequencer 36 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/s.lit 37 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 38 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 39 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 40 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 41 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 42 | add wave -noupdate -divider Datenpfad 43 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 44 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 45 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 46 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 47 | add wave -noupdate -divider {Return Stack} 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 49 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 51 | TreeUpdate [SetDefaultTree] 52 | WaveRestoreCursors {{Cursor 1} {65715 ns} 0} {{Cursor 2} {45674 ns} 0} 53 | quietly wave cursor active 1 54 | configure wave -namecolwidth 135 55 | configure wave -valuecolwidth 68 56 | configure wave -justifyvalue left 57 | configure wave -signalnamewidth 1 58 | configure wave -snapdistance 10 59 | configure wave -datasetprefix 0 60 | configure wave -rowmargin 4 61 | configure wave -childrowmargin 2 62 | configure wave -gridoffset 0 63 | configure wave -gridperiod 1 64 | configure wave -griddelta 40 65 | configure wave -timeline 0 66 | configure wave -timelineunits ns 67 | update 68 | WaveRestoreZoom {0 ns} {105 us} 69 | -------------------------------------------------------------------------------- /modelSim/progload.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/uCore/warmboot 4 | add wave -noupdate /bench/myFPGA/reset 5 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_reset 6 | add wave -noupdate /bench/myFPGA/uCore/uBus 7 | add wave -noupdate /bench/myFPGA/clk 8 | add wave -noupdate /bench/myFPGA/cycle_ctr 9 | add wave -noupdate /bench/myFPGA/uCore/clk_en 10 | add wave -noupdate -divider Debugger 11 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/send_ack 12 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/txd 13 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 14 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_data 15 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_full 16 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_read 17 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_ctr 18 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_reg 19 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_state 20 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_prequest 21 | add wave -noupdate /bench/myFPGA/uCore/deb_penable 22 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/upload 23 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_state 24 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/addr_ptr 25 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/addr_ctr 26 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/write 27 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/debugmem.enable 28 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/debugmem.write 29 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/debugmem.addr 30 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/debugmem.wdata 31 | add wave -noupdate /bench/myFPGA/uCore/memory.wdata 32 | add wave -noupdate -divider progmem 33 | add wave -noupdate /bench/myFPGA/uCore/internal_prog_mem/paddr 34 | add wave -noupdate /bench/myFPGA/uCore/internal_prog_mem/penable 35 | add wave -noupdate /bench/myFPGA/uCore/internal_prog_mem/prdata 36 | add wave -noupdate /bench/myFPGA/uCore/internal_prog_mem/pwdata 37 | add wave -noupdate /bench/myFPGA/uCore/internal_prog_mem/pwrite 38 | add wave -noupdate -divider bench 39 | add wave -noupdate /bench/out_buf 40 | add wave -noupdate /bench/sending 41 | add wave -noupdate /bench/host_ack 42 | add wave -noupdate /bench/host_full 43 | add wave -noupdate -divider Sequencer 44 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 45 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.inst 46 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 47 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 48 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 49 | add wave -noupdate -divider Datenpfad 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 52 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 53 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 54 | add wave -noupdate -divider {Return Stack} 55 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 56 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 57 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 58 | TreeUpdate [SetDefaultTree] 59 | WaveRestoreCursors {{Cursor 1} {71700 ns} 0} {{Cursor 2} {679600 ns} 0} 60 | quietly wave cursor active 1 61 | configure wave -namecolwidth 148 62 | configure wave -valuecolwidth 68 63 | configure wave -justifyvalue left 64 | configure wave -signalnamewidth 1 65 | configure wave -snapdistance 10 66 | configure wave -datasetprefix 0 67 | configure wave -rowmargin 4 68 | configure wave -childrowmargin 2 69 | configure wave -gridoffset 0 70 | configure wave -gridperiod 1 71 | configure wave -griddelta 40 72 | configure wave -timeline 0 73 | configure wave -timelineunits ns 74 | update 75 | WaveRestoreZoom {0 ns} {68250 ns} 76 | -------------------------------------------------------------------------------- /modelSim/upload.do: -------------------------------------------------------------------------------- 1 | onerror {resume} 2 | quietly WaveActivateNextPane {} 0 3 | add wave -noupdate /bench/myFPGA/reset 4 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_reset 5 | add wave -noupdate /bench/myFPGA/uCore/uBus 6 | add wave -noupdate /bench/myFPGA/clk 7 | add wave -noupdate /bench/myFPGA/uCore/clk_en 8 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r 9 | add wave -noupdate /bench/bitout 10 | add wave -noupdate -divider Debugger 11 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rxd 12 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_data 13 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/rx_full 14 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/upload 15 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_reg 16 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_ctr 17 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/in_state 18 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/out_state 19 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/send_ack 20 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/txd 21 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/addr_ptr 22 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/addr_ctr 23 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_drequest 24 | add wave -noupdate /bench/myFPGA/uCore/debug_unit/deb_denable 25 | add wave -noupdate /bench/myFPGA/uCore/memory.enable 26 | add wave -noupdate /bench/myFPGA/internal_data_mem/bytes_en 27 | add wave -noupdate /bench/myFPGA/uCore/memory.write 28 | add wave -noupdate /bench/myFPGA/uCore/memory.addr 29 | add wave -noupdate /bench/myFPGA/uCore/memory.wdata 30 | add wave -noupdate /bench/myFPGA/uCore/mem_rdata 31 | add wave -noupdate /bench/myFPGA/uCore/uBus.mem_en 32 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(8) 33 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(9) 34 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(10) 35 | add wave -noupdate /bench/myFPGA/internal_data_mem/make_sim_mem/internal_data_mem/ram(11) 36 | add wave -noupdate /bench/myFPGA/uCore/uBus.ext_en 37 | add wave -noupdate /bench/ext_SRAM/ram(0) 38 | add wave -noupdate /bench/ext_SRAM/ram(4) 39 | add wave -noupdate /bench/ext_SRAM/ram(8) 40 | add wave -noupdate /bench/ext_SRAM/ram(12) 41 | add wave -noupdate -divider bench 42 | add wave -noupdate /bench/out_buf 43 | add wave -noupdate /bench/sending 44 | add wave -noupdate /bench/uploading 45 | add wave -noupdate /bench/host_ack 46 | add wave -noupdate /bench/host_full 47 | add wave -noupdate /bench/host_buf 48 | add wave -noupdate -divider Sequencer 49 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/pause 50 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.chain 51 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/instruction 52 | add wave -noupdate /bench/myFPGA/uCore/prog_rdata 53 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/prog_addr 54 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/paddr 55 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.pc 56 | add wave -noupdate -divider Datenpfad 57 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tos 58 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.nos 59 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/ds_rdata 60 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.dsp 61 | add wave -noupdate -divider {Return Stack} 62 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.tor 63 | add wave -noupdate /bench/myFPGA/uCore/uCntrl/r.rsp 64 | TreeUpdate [SetDefaultTree] 65 | WaveRestoreCursors {{Cursor 1} {48385 ns} 0} {{Cursor 2} {67703 ns} 0} 66 | quietly wave cursor active 1 67 | configure wave -namecolwidth 153 68 | configure wave -valuecolwidth 68 69 | configure wave -justifyvalue left 70 | configure wave -signalnamewidth 1 71 | configure wave -snapdistance 10 72 | configure wave -datasetprefix 0 73 | configure wave -rowmargin 4 74 | configure wave -childrowmargin 2 75 | configure wave -gridoffset 0 76 | configure wave -gridperiod 1 77 | configure wave -griddelta 40 78 | configure wave -timeline 0 79 | configure wave -timelineunits ns 80 | update 81 | WaveRestoreZoom {0 ns} {52500 ns} 82 | -------------------------------------------------------------------------------- /modelSim/work/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /software/bootload.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : bootload.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 05.04.2021 16:44:55 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : The bootloader for synthesis. 25 | \ 26 | \ Version Author Date Changes 27 | \ 210 ks 14-Jun-2020 initial version 28 | \ ---------------------------------------------------------------------- 29 | Only Forth also definitions 30 | 31 | [IFDEF] unpatch unpatch [ENDIF] 32 | [IFDEF] close-port close-port [ENDIF] 33 | [IFDEF] microcore microcore [ENDIF] Marker microcore 34 | 35 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 36 | include ../vhdl/architecture_pkg.vhd 37 | include microcross.fs \ the cross-compiler 38 | 39 | Target new \ go into target compilation mode and initialize target compiler 40 | 41 | 0 code-origin 42 | 0 data-origin 43 | 44 | ] 0 BEGIN REPEAT [ \ hang in endless loop waiting for program loading via umbilical 45 | 46 | end 47 | 48 | Boot-file ../vhdl/bootload.vhd cr .( bootload.fs written to ../vhdl/bootload.vhd ) 49 | 50 | -------------------------------------------------------------------------------- /software/bootload_sim.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : bootload_sim.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 05.04.2021 16:46:46 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : The bootloader for VHDL-simulation. 25 | \ 26 | \ Version Author Date Changes 27 | \ 210 ks 14-Jun-2020 initial version 28 | \ ---------------------------------------------------------------------- 29 | Only Forth also definitions 30 | 31 | [IFDEF] unpatch unpatch [ENDIF] 32 | [IFDEF] close-port close-port [ENDIF] 33 | [IFDEF] microcore microcore [ENDIF] Marker microcore 34 | 35 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 36 | include ../vhdl/architecture_pkg_sim.vhd 37 | include microcross.fs \ the cross-compiler 38 | 39 | Target new \ go into target compilation mode and initialize target compiler 40 | 41 | 0 code-origin 42 | 0 data-origin 43 | 44 | ] 0 noop BRANCH [ \ immediately go to the preset program memory 45 | 46 | end 47 | 48 | Boot-file ../vhdl/bootload_sim.vhd cr .( bootload_sim.fs written to ../vhdl/bootload_sim.vhd ) -------------------------------------------------------------------------------- /software/constants.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : constants.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 03.08.2022 23:02:10 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : MicroCore hardware/software interface: Register Constants 25 | \ Quantities between H ..... T due to loading 26 | \ architecture_pkg.VHD on the Host. 27 | \ 28 | \ Version Author Date Changes 29 | \ 210 ks 14-Jun-2020 initial version 30 | \ ---------------------------------------------------------------------- 31 | Target 32 | 33 | \ ---------------------------------------------------------------------- 34 | \ Memory mapping 35 | \ ---------------------------------------------------------------------- 36 | 37 | \ ---------------------------------------------------------------------- 38 | \ registers and bits 39 | \ ---------------------------------------------------------------------- 40 | 41 | H STATUS_REG T Register Status 42 | H s_c T Bit #c \ 1 carry mask 43 | H s_ovfl T Bit #ovfl \ 2 integer and float overflow mask 44 | H s_ie T Bit #ie \ 4 interrupt enable mask 45 | H s_iis T Bit #iis \ 8 interrupt in service mask 46 | H s_lit T Bit #lit \ $10 previous instruction was lit_instruction mask 47 | H s_neg T Bit #neg \ $20 sign mask 48 | H s_zero T Bit #zero \ $40 zero mask 49 | H s_div T Bit #sign-div \ $80 sign of DIVisor mask 50 | H s_den T Bit #sign-den \ $100 sign of DividENd mask 51 | H s_unfl T Bit #unfl \ $200 float underflow mask 52 | 53 | H DSP_REG T Register Dsp 54 | 55 | H RSP_REG T Register Rsp 56 | 57 | H INT_REG T Register Intflags 58 | H i_ext T Bit #i-ext 59 | H FLAG_REG T Register Flags 60 | H f_dsu T Bit #f-dsu \ set when the dsu is connected to the umbilical (no break!) 61 | H f_sema T Bit #f-sema 62 | H f_bitout T Bit #f-bitout 63 | 64 | H VERSION_REG T Register Version-reg 65 | 66 | H DEBUG_REG T Register Debug-reg 67 | 68 | H CTRL_REG T Register Ctrl-reg 69 | H c_bitout T Bit #c-bitout 70 | 71 | H TIME_REG T Register Time-reg 72 | 73 | -------------------------------------------------------------------------------- /software/disasm.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : disasm.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 07.07.2022 16:58:10 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : microCore disassembler with macro resolution. 25 | \ DISASM displays one instruction per key pressed. 26 | \ or to finish. 27 | \ 28 | \ Version Author Date Changes 29 | \ 210 ks 14-Jun-2020 initial version 30 | \ ---------------------------------------------------------------------- 31 | Only Forth also definitions 32 | 33 | Variable Expand Expand off \ OFF: display macros with macro name. 34 | \ ON: display every single instruction 35 | Variable out out off 36 | 37 | : dis-cr ( -- ) out off _CR ; 38 | : dis-emit ( char -- ) 1 out +! _EMIT ; 39 | : dis-type ( addr len -- ) dup out +! _TYPE ; 40 | : position ( n -- ) 41 | out @ max BEGIN dup out @ - WHILE BL dis-emit REPEAT drop 42 | ; 43 | : results ( -- ) &18 position ; 44 | 45 | : std-output ( -- ) 46 | ['] _CR IS CR ['] _EMIT IS EMIT ['] _TYPE IS TYPE 47 | ; 48 | : dis-output ( -- ) 49 | ['] dis-cr IS CR ['] dis-EMIT IS EMIT ['] dis-TYPE IS TYPE 50 | ; 51 | \ ---------------------------------------------------------------------- 52 | \ manipulating the stack field 53 | \ ---------------------------------------------------------------------- 54 | 55 | : patch-stack ( op stack -- op' ) 56 | swap [ #stack not #codemask and ] Literal and or 57 | ; 58 | : Stack: ( stack -- ) Create , Does> ( op -- op' ) @ patch-stack ; 59 | 60 | #none Stack: NONE 61 | #pop Stack: POP 62 | #push Stack: PUSH 63 | #both Stack: BOTH 64 | 65 | : .addr ( addr -- ) 0 <# [ data_width 3 + 4 / ] Literal 0 DO # LOOP #> type ." : " ; 66 | 67 | : .opcode ( opcode -- ) 0 <# [ inst_width 3 + 4 / ] Literal 0 DO # LOOP #> type space ; 68 | 69 | : tdump ( caddr quan -- ) 70 | temp-hex cells bounds 71 | ?DO cr I .addr space 72 | I >memory $10 cells bounds 73 | DO I @ .opcode #cell +LOOP 74 | $10 +LOOP 75 | ; 76 | : .listname? ( caddr link -- f ) 77 | swap >r 78 | BEGIN @ dup 79 | WHILE dup cell- @ r@ = 80 | IF cell- .wordname r> EXIT THEN 81 | REPEAT rdrop 82 | ; 83 | : .listname ( caddr link -- ) .listname? drop ; 84 | 85 | : a-call? ( caddr n -- caddr n ff | caddr+1 tf ) 86 | over opcode@ op_CALL - IF false EXIT THEN 87 | op_CALL .opcode results 88 | over + 1+ dup Colons .listname tu. ." call" 89 | 1+ true 90 | ; 91 | : a-branch? ( opcode -- addr | ff ) 92 | Branches 93 | BEGIN @ dup 94 | WHILE 2dup 2 cells - @ #codemask and = IF nip EXIT THEN 95 | REPEAT nip 96 | ; 97 | : a-condition? ( caddr n -- caddr n ff | caddr+1 tf ) 98 | over opcode@ a-branch? dup 0= ?EXIT 99 | >r over opcode@ .opcode 100 | results over + 1+ 101 | dup Colons .listname tu. 102 | r> 2 cells - .wordname 103 | 1+ true 104 | ; 105 | : literals? ( caddr -- caddr ff | caddr' tf ) 106 | dup opcode@ #literal and 0= IF false EXIT THEN 107 | dup nibbles@ BEGIN ?dup WHILE swap .opcode 1- REPEAT 108 | dup >branch drop swap nibbles@ nibbles> 109 | a-call? IF true EXIT THEN 110 | a-condition? IF true EXIT THEN 111 | over opcode@ noop? IF op_NOOP .opcode swap 1+ swap THEN 112 | results dup >r . r@ 2 u> 113 | IF Variables 114 | BEGIN @ ?dup 115 | WHILE dup cell- @ r@ = IF 3 cells - >name .name true rdrop EXIT THEN 116 | REPEAT 117 | THEN Colons 118 | BEGIN @ ?dup 119 | WHILE dup cell- @ r@ = IF ." ['] " 3 cells - >name .name true rdrop EXIT THEN 120 | REPEAT 121 | r> tu. true 122 | ; 123 | : .inst-name ( opcode link -- opcode ff | tf ) 124 | BEGIN @ dup 125 | WHILE 2dup 2 cells - @ #opmask and = 126 | IF results 2 cells - .wordname drop true EXIT THEN 127 | REPEAT 128 | ; 129 | : decode ( opcode -- ) 130 | Branches .inst-name ?EXIT 131 | BEGIN Operators .inst-name ?EXIT 132 | dup #groupmask and [ #alu #push or ] Literal = 133 | WHILE results ." 2dup " POP 134 | REPEAT 135 | .opcode 136 | ; 137 | : macro? ( caddr -- caddr' tf | caddr ff ) 138 | Expand @ IF False EXIT THEN 139 | dup macro@ dup 0= ?EXIT >r \ macro# on rstack 140 | BEGIN dup macro@ r@ = 141 | WHILE dup opcode@ .opcode 1+ 142 | REPEAT results true 143 | Macro-link BEGIN @ ?dup 144 | WHILE dup cell- @ r@ = 145 | IF 2 cells - .wordname rdrop EXIT THEN 146 | REPEAT ." macro" r> . 147 | ; 148 | : .instruction ( caddr -- caddr' ) temp-hex 149 | cr dup Colons .listname? IF results ." ---------------" cr THEN 150 | dup .addr 151 | macro? ?EXIT 152 | literals? ?EXIT 153 | dup 1+ swap opcode@ dup .opcode decode 154 | ; 155 | : break-key? ( -- f ) key dup #cr = swap #esc = or ; 156 | 157 | : disasm ( caddr -- ) \ displays one instruction per key pressed. or to finish 158 | dis-output 159 | BEGIN .instruction break-key? UNTIL 160 | drop space std-output 161 | ; 162 | : show ( -- ) 163 | Context @ >r Target defined r> Context ! 164 | 0= ?missing >body @ disasm 165 | ; 166 | -------------------------------------------------------------------------------- /software/epilog.vhd: -------------------------------------------------------------------------------- 1 | WHEN OTHERS => RETURN "--------"; 2 | END CASE; 3 | END program; 4 | 5 | BEGIN 6 | 7 | data <= program(to_integer(addr)); 8 | 9 | END sim_model; -------------------------------------------------------------------------------- /software/epilog_internal.vhd: -------------------------------------------------------------------------------- 1 | OTHERS => (OTHERS => 'U') 2 | ); ATTRIBUTE syn_ramstyle OF program : SIGNAL IS "block_ram"; 3 | 4 | BEGIN 5 | 6 | internal_ram: PROCESS(clk) 7 | BEGIN 8 | IF rising_edge(clk) THEN 9 | IF en='1' THEN 10 | IF we='1' THEN 11 | program(to_integer(addr)) <= di; 12 | do <= di; 13 | ELSE 14 | do <= program(to_integer(addr)); 15 | END IF; 16 | END IF; 17 | END IF; 18 | END PROCESS internal_ram; 19 | 20 | END inference_model; 21 | -------------------------------------------------------------------------------- /software/header.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : .fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 05.04.2021 16:47:25 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : 25 | \ 26 | \ Version Author Date Changes 27 | \ ---------------------------------------------------------------------- 28 | 29 | -------------------------------------------------------------------------------- /software/images.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : images.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 03.04.2022 18:25:39 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : Generating the target object code image in different formats. 25 | \ 26 | \ Version Author Date Changes 27 | \ 210 ks 14-Jun-2020 initial version 28 | \ 2300 ks 06-Feb-2021 CRC-file modified for variable data_widths 29 | \ ---------------------------------------------------------------------- 30 | Only Forth also definitions 31 | 32 | : Bin-file ( -- ) \ write program memory image to file as binary 33 | BL word dup c@ 0= abort" file name required" 34 | count R/W BIN Create-file abort" File could not be created" >r 35 | 0 >memory there cells r@ write-file abort" File write error" 36 | r> close-file abort" File close failed" 37 | ; 38 | : Byte-file ( -- ) \ write program memory image to file as byte oriented binary 39 | BL word dup c@ 0= abort" file name required" 40 | count R/W BIN Create-file abort" File could not be created" 41 | there 0 ?DO I >memory @ pad c! dup pad 1 rot write-file abort" File write error" LOOP 42 | close-file abort" File close failed" 43 | ; 44 | \ ---------------------------------------------------------------------- 45 | \ Create bootable code for 8-bit EEPROM 46 | \ CRC16-CCITT Width = 16 bits 47 | \ CRC computed following the algorithm specified in the ECSS-E-70-41A 48 | \ 49 | \ 2 byte length-field | program image | 2 byte crc 50 | \ ---------------------------------------------------------------------- 51 | 52 | $1021 Constant #polynom 53 | $FFFF Constant #crc-init 54 | $8000 Constant #X15-bit 55 | $FFFF Constant #crc-mask 56 | 2 Constant #bytes/crc 57 | 2 Constant #bytes/len 58 | 59 | : crc-step ( w crc1 -- w' crc2 ) \ process one bit 60 | 2dup xor >r 2* swap 2* swap 61 | r> #X15-bit and IF #polynom xor THEN 62 | ; 63 | : crc8 ( crc1 c -- crc2 ) \ process one byte 64 | 8 lshift swap 7 FOR crc-step NEXT nip 65 | ; 66 | : crc-check ( addr length -- crc ) \ process string of bytes 67 | #crc-init -rot 1- FOR dup >r c@ crc8 r> 1+ NEXT drop 68 | #crc-mask and 69 | ; 70 | : pack_image ( -- addr len ) 71 | Pad dup #bytes/len + 0 72 | 0 >memory there cells bounds 73 | DO I c@ swap >r swap >r r@ c! r> 1+ r> 1+ 1 cells +LOOP 74 | swap >r over #bytes/len + over crc-check 75 | unpack r@ c! r> 1+ c! \ append two CRC bytes 76 | swap over #bytes/len 2 - FOR unpack NEXT \ fill in length-field 77 | Pad #bytes/len + 1- #bytes/len 1- FOR tuck c! 1- NEXT drop 78 | swap #bytes/len + #bytes/crc + \ compute total image length 79 | ; 80 | : CRC-file ( -- ) \ write program memory image length field and CRC 81 | BL word dup c@ 0= abort" file name required" 82 | count R/W BIN Create-file abort" File could not be created" >r 83 | pack_image r@ write-file abort" File write error" 84 | r> close-file abort" File close failed" 85 | ; 86 | \ ---------------------------------------------------------------------- 87 | \ Create VHDL output files for the object code 88 | \ ---------------------------------------------------------------------- 89 | 90 | : makeopcode ( opcode -- string ) 91 | Base save binary 0 <# inst_width 0 DO # LOOP #> 92 | ; 93 | : writeclause ( handle addr -- ) 94 | count rot write-file abort" File write error" 95 | ; 96 | : file>here ( string -- addr len ) 97 | count r/o open-file abort" PROLOG/EPILOG file not present" >r 98 | here 2000 r@ read-file abort" PROLOG/EPILOG: could not read" 99 | here swap r> close-file drop 100 | ; 101 | \ ---------------------------------------------------------------------- 102 | \ Create VHDL program memory code using case statement 103 | \ ---------------------------------------------------------------------- 104 | 105 | Create romclause ," WHEN 16#0000# => RETURN _00000000_; " 106 | 107 | : >romclause ( offset -- addr ) romclause + 6 + ; 108 | 109 | char " $19 >romclause c! 110 | char " $22 >romclause c! 111 | #cr $24 >romclause c! 112 | #lf $25 >romclause c! 113 | 114 | 9 Constant vhdladdr 115 | $1A Constant vhdlcode 116 | 117 | : makeaddr ( addr -- string ) temp-hex 0 <# # # # # #> ; 118 | 119 | : make_whenclause ( caddr -- ) 120 | dup makeaddr vhdladdr >romclause swap cmove 121 | >memory @ makeopcode vhdlcode >romclause swap cmove 122 | ; 123 | Create prolog ," prolog.vhd" 124 | Create epilog ," epilog.vhd" 125 | 126 | : VHDL-file ( -- ) 127 | BL word dup c@ 0= abort" file name required" 128 | count R/W BIN create-file abort" File could not be created" >r 129 | prolog file>here r@ write-file abort" PROLOG write error" 130 | r> 0 there bounds DO I make_whenclause dup romclause writeclause LOOP >r 131 | epilog file>here r@ write-file abort" EPILOG write error" 132 | r> close-file abort" File close failed" 133 | ; 134 | Target definitions Forth 135 | 136 | ' VHDL-file Alias VHDL-file 137 | 138 | definitions 139 | 140 | \ ---------------------------------------------------------------------- 141 | \ Create VHDL boot loader rom code using case statement 142 | \ ---------------------------------------------------------------------- 143 | 144 | Create boot_prolog ," prolog_boot.vhd" 145 | 146 | : Boot-file ( -- ) 147 | BL word dup c@ 0= abort" file name required" 148 | count R/W BIN create-file abort" File could not be created" >r 149 | boot_prolog file>here r@ write-file abort" PROLOG write error" 150 | r> 0 there bounds DO I make_whenclause dup romclause writeclause LOOP >r 151 | epilog file>here r@ write-file abort" EPILOG write error" 152 | r> close-file abort" File close failed" 153 | ; 154 | \ ---------------------------------------------------------------------- 155 | \ Create VHDL blockRAM memory 156 | \ ---------------------------------------------------------------------- 157 | 158 | Create clause ," _00000000_, " 159 | 160 | : >clause ( offset -- addr ) clause + ; 161 | 162 | char " $1 >clause c! 163 | char " $A >clause c! 164 | #cr $C >clause c! 165 | #lf $D >clause c! 166 | 167 | $2 Constant vhdlcode 168 | 169 | : make_initstring ( caddr -- ) 170 | >memory @ makeopcode vhdlcode >clause swap cmove 171 | ; 172 | Create internal_prolog ," prolog_internal.vhd" 173 | Create internal_epilog ," epilog_internal.vhd" 174 | 175 | : Prog-file ( -- ) 176 | BL word dup c@ 0= abort" file name required" 177 | count R/W BIN create-file abort" File could not be created" >r 178 | internal_prolog file>here r@ write-file abort" PROLOG write error" 179 | r> 0 there bounds DO I make_initstring dup Clause writeclause LOOP >r 180 | internal_epilog file>here r@ write-file abort" EPILOG write error" 181 | r> close-file abort" File close failed" 182 | ; 183 | \ ---------------------------------------------------------------------- 184 | \ Create Xilinx MEM File for block ram initialization 185 | \ ---------------------------------------------------------------------- 186 | 187 | : placeaddr ( addr paddr -- addr paddr+ ) 188 | \ >r dup 0 <# # # # # [char] @ hold #> r> 2dup + >r swap cmove r> \ Xilinx format 189 | >r dup 0 <# [char] : hold BL hold # # # # #> r> 2dup + >r swap cmove r> \ Lattice format 190 | ; 191 | : placebyte ( caddr paddr -- caddr+ paddr+ ) 192 | >r dup 1+ swap opcode@ 0 <# # # BL hold #> r> 2dup + >r swap cmove r> 193 | ; 194 | : make_romline ( caddr -- caddr+ saddr slen ) 195 | temp-hex 196 | here placeaddr $10 0 DO placebyte LOOP 197 | #cr over c! 1+ #lf over c! 1+ 198 | here tuck - 199 | ; 200 | : MEM-file ( -- ) 201 | BL word dup c@ 0= abort" file name required" 202 | count R/W BIN create-file abort" File could not be created" >r 203 | 0 BEGIN make_romline r@ write-file abort" File write error" 204 | dup there u> 205 | UNTIL drop r> close-file abort" File close failed" 206 | ; 207 | -------------------------------------------------------------------------------- /software/load_template.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 03.07.2023 12:08:03 3 | \ 4 | \ Basic microCore load screen for execution on the target. 5 | \ 6 | Only Forth also definitions 7 | 8 | [IFDEF] unpatch unpatch [ENDIF] 9 | [IFDEF] close-port close-port [ENDIF] 10 | [IFDEF] microcore microcore [ENDIF] Marker microcore 11 | 12 | include extensions.fs \ Some System word (re)definitions 13 | include ../vhdl/architecture_pkg.vhd 14 | include microcross.fs \ the cross-compiler 15 | 16 | \ Verbose on \ Library loading messages 17 | 18 | Target new initialized \ go into target compilation mode and initialize target compiler 19 | 20 | 6 trap-addr code-origin 21 | 0 data-origin 22 | 23 | include constants.fs \ MicroCore Register addresses and bits 24 | include debugger.fs 25 | library forth_lib.fs 26 | 27 | \ ---------------------------------------------------------------------- 28 | \ Booting, Interrupts and TRAPs 29 | \ ---------------------------------------------------------------------- 30 | 31 | : interrupt ( -- ) Intflags @ drop ; 32 | 33 | : boot ( -- ) 0 #cache erase CALL initialization debug-service ; 34 | 35 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 36 | #isr TRAP: isr ( -- ) interrupt IRET ; 37 | #psr TRAP: psr ( -- ) pause ; \ call the scheduler, eventually re-execute instruction 38 | #break TRAP: break ( -- ) debugger ; \ Debugger 39 | #does> TRAP: dodoes ( addr -- addr' ) ld cell+ swap BRANCH ; \ the DOES> runtime primitive 40 | #data! TRAP: data! ( dp n -- dp+1 ) swap st cell+ ; \ Data memory initialization 41 | 42 | end 43 | -------------------------------------------------------------------------------- /software/messages.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : messages.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 07.07.2022 18:37:59 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : Definition of warnings, errors, and execution tokens on the host. 25 | \ 26 | \ Version Author Date Changes 27 | \ 210 ks 14-Jun-2020 initial version 28 | \ 2400 ks 03-Nov-2022 byte addressing using byte_addr_width 29 | \ ---------------------------------------------------------------------- 30 | Forth definitions 31 | 32 | \ ---------------------------------------------------------------------- 33 | \ Message# defines target signals for target/host interaction. 34 | \ ---------------------------------------------------------------------- 35 | 36 | : Message# ( n -- ) #datamask and 37 | source> Target definitions over T Constant H 38 | >source Forth definitions Constant 39 | ; 40 | \ warnings 41 | $4000 Message# #string-overflow 42 | 43 | \ errors 44 | #signbit Message# #breakpoint 45 | -1 Message# #warmboot 46 | -2 Message# #all-tasks-busy 47 | -3 Message# #task-not-linked 48 | -4 Message# #catch-not-initialized 49 | -5 Message# #not-my-semaphore 50 | 51 | : .error ( -n -- ) 52 | #warmboot case? IF ." warmboot " EXIT THEN 53 | #all-tasks-busy case? IF ." all-tasks-busy " EXIT THEN 54 | #task-not-linked case? IF ." task-not-linked " EXIT THEN 55 | #catch-not-initialized case? IF ." catch-not-initialized " EXIT THEN 56 | #not-my-semaphore case? IF ." not-my-semaphore " EXIT THEN 57 | ." error: " signextend . 58 | ; 59 | : .warning ( +n -- ) cr ." warning: " 60 | #string-overflow case? IF ." string-overflow " EXIT THEN 61 | $. 62 | ; 63 | \ ---------------------------------------------------------------------- 64 | \ target words, which can be executed during compilation for simulation 65 | \ ---------------------------------------------------------------------- 66 | SIMULATION [IF] Target definitions Forth 67 | 68 | : here ( -- addr ) ?exec Tdp @ ; 69 | : allot ( n -- ) ?exec Tdp +! ; 70 | : , ( n -- ) ?exec Tdp @ d! #cell Tdp +! ; 71 | 72 | : . ( n -- ) ?exec . ; 73 | : .r ( n u -- ) ?exec .r ; 74 | : u. ( u -- ) ?exec tu. ; 75 | : d. ( d -- ) ?exec d. ; 76 | : ud. ( ud -- ) ?exec ud. ; 77 | : cr ( -- ) ?exec cr ; 78 | : emit ( char -- ) ?exec emit ; 79 | : $. ( u -- ) ?exec $. ; 80 | : &. ( n -- ) ?exec &. ; 81 | : #. ( n -- ) ?exec #. ; 82 | : %. ( u -- ) ?exec %. ; 83 | 84 | Forth definitions 85 | 86 | : do-messages ( n -- ) drop ; 87 | 88 | [ELSE] 89 | \ ---------------------------------------------------------------------- 90 | \ debug words that can be compiled on the target to be executed by the host 91 | \ The matching target side definitions are at the end of debugger.fs 92 | \ ---------------------------------------------------------------------- 93 | 94 | $101 Message# #dot 95 | $102 Message# #dotr 96 | $103 Message# #udot 97 | $104 Message# #ddot 98 | $105 Message# #uddot 99 | $106 Message# #cret 100 | $107 Message# #emit 101 | 102 | : do-messages ( n -- ) 103 | dup #signbit and IF State off cr .error EXIT THEN 104 | #dot case? IF target> signextend . EXIT THEN 105 | #udot case? IF target> tu. EXIT THEN 106 | #dotr case? IF target> target> signextend swap .r space EXIT THEN 107 | #ddot case? IF target> target> swap dtarget d. EXIT THEN 108 | #uddot case? IF target> target> swap udtarget ud. EXIT THEN 109 | #cret case? IF cr EXIT THEN 110 | #emit case? IF target> emit EXIT THEN 111 | dup $3FFF > IF .warning EXIT THEN 112 | cr ." message: " $. 113 | ; 114 | 115 | [THEN] 116 | -------------------------------------------------------------------------------- /software/microcross.fs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microCore-VHDL/microCore/9a751f16f77498eac7335450591da27b5402c338/software/microcross.fs -------------------------------------------------------------------------------- /software/monitor.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : monitor.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 07.10.2022 12:04:19 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : microCore target monitor for the umbilical debugger. 25 | \ The hardware must be configured with an RS232 serial interface. 26 | \ 27 | \ Version Author Date Changes 28 | \ 210 ks 14-Jun-2020 initial version 29 | \ ---------------------------------------------------------------------- 30 | Target 31 | 32 | Variable tmpStatus 33 | 34 | : monitor ( -- ) BEGIN 0 host! host@ execute REPEAT ; 35 | 36 | : debugger ( -- ) \ main debugger loop called via break instruction 37 | Status @ tmpStatus ! #breakpoint host! r> 1- host! monitor 38 | ; 39 | : clear ( ? -- ) Dsp @ [ #ds-depth 1- not ] Literal and Dsp ! ; 40 | 41 | : rclear ( r: ? -- ) r> Rsp @ [ #rs-depth cell- ] Literal or 42 | [ #cell 1- not ] Literal and Rsp ! >r 43 | ; 44 | : debug-service ( -- ) 45 | rclear clear host@ drop 46 | BEGIN #warmboot host! host@ $3F5 = UNTIL 47 | BEGIN $305 host! host@ 0= UNTIL \ synchronise Host <-> Target communication 48 | GOTO monitor 49 | ; 50 | 51 | \ ---------------------------------------------------------------------- 52 | \ Some words that are needed by the debugger 53 | \ ---------------------------------------------------------------------- 54 | 55 | : message ( n -- ) \ transfer message number to host 56 | dup host! 0< IF clear rclear GOTO monitor THEN 57 | ; 58 | : nextstep ( -- ) rdrop host@ >r tmpStatus @ Status ! ; \ call and jump (modified via >r) 59 | 60 | : depth ( -- depth ) Dsp @ [ #ds-depth 1- ] Literal and ; 61 | 62 | : copyds ( -- ) depth dup host! 63 | dup ?FOR swap r> swap >r >r NEXT 64 | ?FOR r> r> swap >r dup host! NEXT 65 | ; 66 | Variable tmpTOR 67 | 68 | : saveTOR ( -- ) r> r> tmpTOR ! >r ; 69 | : restoreTOR ( -- ) r> tmpTOR @ >r >r ; 70 | 71 | : \host! ( n -- ) host! ; 72 | : \host@ ( -- n ) host@ ; 73 | : \@ ( addr -- n ) @ ; 74 | : \! ( n addr -- ) ! ; 75 | : \does ( addr -- addr+1 ) H op_DOES t, T ; 76 | byte_addr_width [IF] 77 | : \c@ ( caddr -- char ) c@ ; 78 | [THEN] 79 | -------------------------------------------------------------------------------- /software/objects.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : objects.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 05.04.2021 16:48:03 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : OOP package. Its primary use is for operator overloading. 25 | \ - no polymorphism nor vtables, 26 | \ - only early binding at compile time. 27 | \ 28 | \ Version Author Date Changes 29 | \ 2300 ks 19-Feb-2021 Initial release 30 | \ ---------------------------------------------------------------------- 31 | Forth definitions 32 | 33 | Variable Last-class Last-class off 34 | Variable 'classroot 'classroot off 35 | 36 | Variable (doClass : doClass ( -- xt ) (doClass @ ; 37 | Variable (doObj : doObj ( -- xt ) (doObj @ ; 38 | 39 | : set-class ( class -- ) dup Last-class ! Class-context ! ; 40 | 41 | : class-def? ( -- f ) Current @ cell- @ doClass = ; 42 | 43 | : ?class-def ( -- ) 44 | class-def? Class-context @ or 0= ABORT" No Class context defined" 45 | ; 46 | : Class ( -- ) 47 | Vocabulary 0 , 0 , 'classroot @ , 48 | \ | search-xt | wordlist | Voclink | ext || attr | size | parent | 49 | DOES> ( -- ) [ here (doClass ! ] set-class ; 50 | 51 | : c.last ( cpa -- addr ) @ cell+ ; \ cpa = Code Pointer Address 52 | 53 | : c.attr ( cpa -- addr ) @ [ 4 cells ] Literal + ; 54 | 55 | : c.size ( cpa -- addr ) @ [ 5 cells ] Literal + ; 56 | 57 | : c.parent ( cpa -- addr ) @ [ 6 cells ] Literal + ; 58 | 59 | 1 Constant #sealed \ attr bit 60 | 61 | : ?unsealed ( -- ) 62 | Current c.attr @ #sealed and ABORT" Class already sealed" 63 | ; 64 | :noname ( addr len -- xt | 0 ) 65 | Last-class >r BEGIN r@ @ 66 | WHILE 2dup r@ @ find-name-in 67 | ?dup IF nip nip rdrop EXIT THEN 68 | r> c.parent >r 69 | REPEAT 70 | rdrop 2drop false 71 | ; IS find-methods 72 | 73 | : >object ( addr -- obj ) dup @ swap cell+ cell+ @ set-class ; 74 | 75 | : (object ( addr -- ) 76 | Method dup @ Constant 77 | Last-class c.size @ swap +! 78 | here Variables @ , Variables ! 79 | Last-class @ , 80 | \ | Tdp | varlink | class | 81 | DOES> ( -- obj ) [ here (doObj ! ] >object 82 | comp? IF lit, EXIT THEN 83 | dbg? IF >t THEN 84 | ; 85 | \ ------------------------------------------------------------------------- 86 | \ Root definitions 87 | \ ------------------------------------------------------------------------- 88 | Root definitions Forth 89 | 90 | : Self ( -- ) 91 | class-def? IF Current ELSE Last-class THEN @ set-class 92 | ; immediate 93 | 94 | : .classes ( -- ) space Voclink 95 | BEGIN @ ?dup 96 | WHILE dup cell- cell- 97 | dup cell- @ doClass = 98 | IF ?cr dup .wordname THEN drop 99 | REPEAT 100 | ; 101 | : Object ( -- ) Tdp (object ; 102 | 103 | \ ------------------------------------------------------------------------- 104 | \ ClassRoot definitions 105 | \ ------------------------------------------------------------------------- 106 | Forth definitions 107 | 108 | : classorder ( -- ) \ put class into normal search order until closing ; 109 | Method r> Context save >r Last-class @ Context ! 110 | ; 111 | Class ClassRoot 112 | ' ClassRoot >body 'classroot ! \ every class inherits ClassRoot 113 | ' ClassRoot >body Current ! \ ClassRoot definitions 114 | 115 | : .. ( -- ) Method ; immediate 116 | 117 | : addr ( obj -- addr ) Method ; immediate 118 | 119 | : definitions ( -- ) Method Last-class @ Current ! ; 120 | 121 | : ' ( -- xt ) ?exec classorder T ' H ; 122 | 123 | : h' ( -- xt ) ?exec classorder ' ; 124 | 125 | : show ( -- ) ?exec classorder show ; 126 | 127 | : see ( -- ) ?exec classorder see ; 128 | 129 | : allot ( u -- ) ?exec Method ?class-def Current c.size +! ; 130 | 131 | : seal ( -- ) ?exec Method ?class-def Current c.attr dup @ #sealed or swap ! ; 132 | 133 | : size ( -- u ) 134 | Method Last-class c.size @ 135 | comp? IF postpone Literal EXIT THEN 136 | dbg? IF >t THEN 137 | ; immediate 138 | 139 | : units ( u1 -- u2 ) ?exec Method Last-class c.size @ * ; 140 | 141 | : inherit ( -- ) ?exec Method ?class-def 142 | Current c.last @ Current c.size @ or ABORT" inherit only once" 143 | Last-class c.size @ Current c.size ! 144 | Last-class @ Current c.parent ! 145 | ; 146 | : words ( -- ) ?exec Method Context @ Last-class @ 147 | BEGIN Context ! words Context c.parent @ ?dup 0= UNTIL Context ! 148 | ; 149 | : order ( -- ) ?exec Method Last-class >r 150 | BEGIN r@ @ ?dup WHILE .voc r> c.parent >r REPEAT rdrop 151 | ." " H Current @ .voc 152 | ; 153 | : Constant ( n -- ) 154 | Method dbg? IF t> THEN Constant 155 | here Constants @ , Constants ! 156 | Last-class @ , 157 | \ | n | varlink | class | 158 | DOES> ( -- obj ) >object 159 | comp? IF lit, EXIT THEN 160 | dbg? IF >t THEN 161 | ; 162 | : Object ( -- ) Method Object ; 163 | 164 | : Attribute ( -- ) 165 | ?exec Method ?class-def ?unsealed 166 | Tcreate Last-class @ , 167 | Current c.size @ here 3 cells - ! 168 | Last-class c.size @ Current c.size +! 169 | \ | offset | Varlink | class | 170 | DOES> ( object1 -- object2 ) >object 171 | comp? IF ?dup 0= ?EXIT lit, T + H EXIT THEN 172 | dbg? IF t> + >t EXIT THEN 173 | + 174 | ; 175 | 176 | ' [ Alias [ immediate \ for debugging 177 | ' ] Alias ] \ for debugging 178 | 179 | \ ------------------------------------------------------------------------- 180 | \ Target definitions 181 | \ ------------------------------------------------------------------------- 182 | Target definitions Forth 183 | 184 | ' Class Alias Class 185 | ' ClassRoot Alias ClassRoot 186 | ' Method Alias Method 187 | 188 | Forth definitions 189 | 190 | \ **************************************************************** 191 | \ Examples for basic Objects: Cell and Point 192 | \ These can not be compiled here, because first the cross-compiler 193 | \ must have been completely loaded. 194 | \ **************************************************************** 195 | \ Target 196 | \ 197 | \ Class Cell Cell definitions 198 | \ 1 Cell allot Cell seal 199 | \ Macro: @ ( obj -- n ) T @ H ; 200 | \ Macro: ! ( n obj -- ) T ! H ; 201 | \ : +! ( n obj -- ) +! ; 202 | \ : on ( obj -- ) on ; 203 | \ : off ( obj -- ) off ; 204 | \ : ? ( obj -- ) @ . ; 205 | \ Target 206 | \ 207 | \ Class Point Point definitions 208 | \ Cell Attribute X 209 | \ Cell Attribute Y 210 | \ Point seal 211 | \ : set ( X Y obj -- ) swap over Self Y ! Self X ! ; 212 | \ : ? ( obj -- ) dup Point X ? Point Y ? ; 213 | \ Target 214 | \ 215 | \ Point Object Punkt init: init-Punkt ( -- ) 1 2 Punkt set ; 216 | \ 217 | \ **************************************************************** 218 | \ int16 with sign extension 219 | \ **************************************************************** 220 | \ 221 | \ Class int16 int16 definitions 222 | \ 1 int16 allot int16 seal 223 | \ : @ ( addr -- n ) @ $FFFF and dup $8000 and IF $FFFF not or THEN ; 224 | \ Macro: ! ( n addr -- ) T ! H ; 225 | \ Target 226 | \ 227 | \ int16 Object Dies \ an int16 variable in the data memory 228 | \ $200 int16 Constant Das \ an int16 variable at address $200 229 | -------------------------------------------------------------------------------- /software/prolog.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Program memory ROM implemented using a case statement. 3 | -- It is generated by the microCore cross compiler. 4 | 5 | LIBRARY IEEE; 6 | USE IEEE.STD_LOGIC_1164.ALL; 7 | USE IEEE.NUMERIC_STD.ALL; 8 | USE work.architecture_pkg.ALL; 9 | 10 | ENTITY program_rom IS PORT ( 11 | addr : IN program_addr; 12 | data : OUT inst_bus 13 | ); END program_rom; 14 | 15 | ARCHITECTURE sim_model OF program_rom IS 16 | 17 | SUBTYPE rom_address IS NATURAL RANGE 0 TO 2**prog_addr_width-1; 18 | 19 | FUNCTION program(addr : rom_address) RETURN UNSIGNED IS 20 | BEGIN 21 | CASE addr IS 22 | -------------------------------------------------------------------------------- /software/prolog_boot.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Program memory ROM implemented using a case statement. 3 | -- Its content was generated by the microCore cross compiler. 4 | -- It will be statically synthesized into the design as cold bootrom. 5 | 6 | LIBRARY IEEE; 7 | USE IEEE.STD_LOGIC_1164.ALL; 8 | USE IEEE.NUMERIC_STD.ALL; 9 | USE work.architecture_pkg.ALL; 10 | 11 | ENTITY boot_rom IS PORT ( 12 | addr : IN boot_addr_bus; 13 | data : OUT inst_bus 14 | ); END boot_rom; 15 | 16 | ARCHITECTURE sim_model OF boot_rom IS 17 | 18 | SUBTYPE rom_address IS NATURAL RANGE 0 TO 2**boot_addr_width-1; 19 | 20 | FUNCTION program(addr : rom_address) RETURN UNSIGNED IS 21 | BEGIN 22 | CASE addr IS 23 | -------------------------------------------------------------------------------- /software/prolog_internal.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Internal program memory RAM implemented using an array type. 3 | -- It is generated by the cross compiler. 4 | 5 | LIBRARY IEEE; 6 | USE IEEE.STD_LOGIC_1164.ALL; 7 | USE IEEE.NUMERIC_STD.ALL; 8 | USE work.architecture_pkg.ALL; 9 | 10 | ENTITY internal_program IS PORT ( 11 | clk : IN STD_LOGIC; 12 | en : IN STD_LOGIC; 13 | we : IN STD_LOGIC; 14 | addr : IN program_addr; 15 | di : IN inst_bus; 16 | do : OUT inst_bus 17 | ); 18 | ATTRIBUTE ram_style : STRING; 19 | ATTRIBUTE ram_style OF internal_program : ENTITY IS "block"; 20 | 21 | END internal_program; 22 | 23 | ARCHITECTURE inference_model OF internal_program IS 24 | 25 | ATTRIBUTE syn_ramstyle : STRING; 26 | 27 | TYPE inst_ram IS ARRAY (0 TO 2**prog_addr_width-1) OF inst_bus; 28 | 29 | SIGNAL program : inst_ram 30 | := ( 31 | -------------------------------------------------------------------------------- /software/rs232_linux.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : rs232_linux.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 27.03.2021 22:14:11 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: uho - Ulrich Hoffmann 10 | \ @contributor: ks - Klaus Schleisiek 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : Terminal for gforth/R8C hacked by uho to run as an rs232 25 | \ interface under linux. 26 | \ 27 | \ Version Author Date Changes 28 | \ uho 15-Feb-2009 initial version 29 | \ ks 10-Apr-2020 addition of the gforth_07x version. 30 | \ ---------------------------------------------------------------------- 31 | Only Forth also definitions 32 | 33 | gforth_062 [IF] cr .( UART for gforth_062, 32 bit) 34 | 35 | require lib.fs 36 | 37 | [IFUNDEF] libc library libc libc.so.6 [THEN] 38 | 39 | libc tcgetattr int ptr (int) tcgetattr ( port termios -- r ) 40 | libc tcsetattr int int ptr (int) tcsetattr ( port opt termios -- r ) 41 | libc tcflow int int (int) tcflow ( port action -- r ) 42 | libc ioctl

int int ptr (int) ioctl ( d request ptr -- r ) 43 | libc fileno ptr (int) fileno ( file* -- port ) 44 | 45 | 4 4 2Constant int% 46 | $20 Constant NCCS 47 | 48 | struct 49 | int% field c_iflag 50 | int% field c_oflag 51 | int% field c_cflag 52 | int% field c_lflag 53 | char% NCCS * field c_line 54 | int% field c_ispeed 55 | int% field c_ospeed 56 | end-struct termios 57 | 58 | Create t_old termios %allot drop 59 | Create t_buf termios %allot drop 60 | 61 | 1 Constant B50 62 | 2 Constant B75 63 | 3 Constant B110 64 | 4 Constant B134 65 | 5 Constant B150 66 | 6 Constant B200 67 | 7 Constant B300 68 | 8 Constant B600 69 | 9 Constant B1200 70 | $A Constant B1800 71 | $B Constant B2400 72 | $C Constant B4800 73 | $D Constant B9600 74 | $E Constant B19200 75 | $F Constant B38400 76 | $1001 Constant B57600 77 | $1002 Constant B115200 78 | $30 Constant CS8 \ 8 bits/character 79 | $80 Constant CREAD \ input enable 80 | $400 Constant CSTOPB \ 2 stop bits 81 | $800 Constant CLOCAL \ don't check RS232 status lines 82 | 1 Constant IGNBRK \ ignore break 83 | 4 Constant IGNPAR \ ignore parity/framing errors 84 | 6 Constant VTIME 85 | 7 Constant VMIN 86 | 87 | : set-baud ( baud handle -- ) 88 | fileno >r r@ t_old tcgetattr drop 89 | t_old t_buf termios %size move 90 | [ IGNBRK IGNPAR or ] Literal t_buf c_iflag ! 91 | 0 t_buf c_oflag ! 92 | [ CS8 CSTOPB or CREAD or CLOCAL or ] Literal or t_buf c_cflag ! 93 | 0 t_buf c_lflag ! 94 | 0 t_buf c_line 2dup VMIN + c! VTIME + c! \ return after every read, even if no char available 95 | &28800 t_buf c_cflag @ $F and lshift 96 | dup t_buf c_ispeed ! t_buf c_ospeed ! 97 | r> 1 t_buf tcsetattr drop 98 | ; 99 | : reset-baud ( handle -- ) fileno 1 t_old tcsetattr drop ; 100 | 101 | [THEN] gforth_079 gforth_072 or [IF] cr .( UART for gforth_07x, 32/64 bit) 102 | 103 | require libcc.fs 104 | 105 | c-library serial 106 | \c #include 107 | \c #include 108 | \c #include 109 | \c #include 110 | \c #include 111 | \c #include 112 | \c #include 113 | 114 | c-function tcgetattr tcgetattr n a -- n ( port termios -- r ) 115 | c-function tcsetattr tcsetattr n n a -- n ( port opt termios -- r ) 116 | c-function cfmakeraw cfmakeraw a -- void ( termios -- ) 117 | c-function cfsetispeed cfsetispeed a n -- n ( termios speed -- r ) 118 | c-function cfsetospeed cfsetospeed a n -- n ( termios speed -- r ) 119 | c-function tcflow tcflow n n -- n ( port action -- n ) 120 | c-function ioctl ioctl n n a -- n ( port cmd ptr -- n ) 121 | c-function setvbuf setvbuf a a n n -- n ( file* buf mode size -- r ) 122 | end-c-library 123 | 124 | [IFDEF] android 125 | ' wfield: alias flagfield: ( offset -- offset' ) 126 | ' w@ alias flag@ 127 | ' w! alias flag! 128 | [ELSE] 129 | ' lfield: alias flagfield: ( offset -- offset' ) 130 | ' l@ alias flag@ 131 | ' l! alias flag! 132 | [THEN] 133 | 134 | begin-structure termios 135 | flagfield: c_iflag \ input mode flags 136 | flagfield: c_oflag \ output mode flags 137 | flagfield: c_cflag \ control mode flags 138 | flagfield: c_lflag \ local mode flags 139 | cfield: c_line 140 | 32 +field c_cc \ line discipline 141 | flagfield: c_ispeed \ input speed 142 | flagfield: c_ospeed \ output speed 143 | end-structure 144 | 145 | Create t_old termios allot 146 | Create t_buf termios allot 147 | 148 | 1 Constant B50 149 | 2 Constant B75 150 | 3 Constant B110 151 | 4 Constant B134 152 | 5 Constant B150 153 | 6 Constant B200 154 | 7 Constant B300 155 | 8 Constant B600 156 | 9 Constant B1200 157 | $A Constant B1800 158 | $B Constant B2400 159 | $C Constant B4800 160 | $D Constant B9600 161 | $E Constant B19200 162 | $F Constant B38400 163 | $1001 Constant B57600 164 | $1002 Constant B115200 165 | $1003 Constant B230400 166 | $1004 Constant B460800 167 | $1005 Constant B500000 168 | $1006 Constant B576000 169 | $1007 Constant B921600 170 | $1008 Constant B1000000 171 | $1009 Constant B1152000 172 | $100A Constant B1500000 173 | $100B Constant B2000000 174 | $100C Constant B2500000 175 | $100D Constant B3000000 176 | $100E Constant B3500000 177 | $100F Constant B4000000 178 | $30 Constant CS8 179 | $80 Constant CREAD 180 | $40 Constant CSTOPB 181 | $800 Constant CLOCAL 182 | $800 Constant IXANY 183 | 1 Constant IGNBRK 184 | 4 Constant IGNPAR 185 | $100 Constant NOCTTY 186 | $800 Constant NODELAY 187 | 5 Constant VTIME 188 | 6 Constant VMIN 189 | 190 | : set-baud ( baud handle -- ) 191 | fileno >r r@ t_old tcgetattr ?ior 192 | t_old t_buf termios move 193 | t_buf cfmakeraw 194 | t_buf c_iflag dup flag@ CLOCAL or swap flag! 195 | t_buf over cfsetispeed ?ior 196 | t_buf swap cfsetospeed ?ior 197 | 0 t_buf c_line 2dup VMIN + c! VTIME + c! \ return after every read, even if no char available 198 | r> 0 t_buf tcsetattr ?ior 199 | ; 200 | : reset-baud ( handle -- ) fileno 0 t_old tcsetattr ?ior ; 201 | 202 | [THEN] 203 | 204 | 0 Value handle 205 | 206 | : open-port ( addr u -- ) r/w open-file throw to handle ; 207 | 208 | : close-port ( -- ) handle ?dup 0= ?EXIT close-file throw 0 TO handle ; 209 | 210 | &120 Constant #buf-length 211 | Create read-buf #buf-length chars allot 212 | 213 | : term-read ( -- u ) read-buf #buf-length handle read-file throw ; 214 | 215 | : term-flush ( -- ) handle flush-file throw ; 216 | 217 | : term-emit ( char -- ) handle emit-file throw ; 218 | 219 | : (term-type) ( addr u -- ) handle write-file throw term-flush ; 220 | 221 | Variable read-len 0 read-len ! 222 | 223 | : term-key? ( -- flag ) read-len @ IF true EXIT THEN term-read dup read-len ! 0<> ; 224 | 225 | : term-key ( -- char ) 226 | BEGIN term-key? UNTIL 227 | read-buf c@ -1 read-len +! 228 | read-buf char+ read-buf read-len @ cmove 229 | ; 230 | : Umbilical: ( baud -- ) \ e.g. B115200 Umbilical: /dev/ttyUSB0 231 | name open-port handle set-baud 232 | ; 233 | -------------------------------------------------------------------------------- /software/rs232_macosx.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : rs232_macosx.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 24.03.2021 17:53:45 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: uho - Ulrich Hoffmann 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : Terminal for gforth/R8C hacked by uho to run as an rs232 25 | \ interface under MAC-OS. 26 | \ 27 | \ Version Author Date Changes 28 | \ uho 15-Feb-2009 initial version 29 | \ ---------------------------------------------------------------------- 30 | Only Forth also definitions 31 | 32 | require lib.fs 33 | 34 | [IFUNDEF] libc library libc libc.dylib [THEN] 35 | 36 | libc tcgetattr int ptr (int) tcgetattr ( port termios -- r ) 37 | libc tcsetattr int int ptr (int) tcsetattr ( port opt termios -- r ) 38 | libc tcflow int int (int) tcflow ( port action -- r ) 39 | libc ioctl

int int ptr (int) ioctl ( d request ptr -- r ) 40 | libc fileno ptr (int) fileno ( handle -- port ) 41 | 42 | cell dup 2Constant int% 43 | 20 Constant NCCS 44 | 45 | struct 46 | int% field c_iflag 47 | int% field c_oflag 48 | int% field c_cflag 49 | int% field c_lflag 50 | char% NCCS * field c_line 51 | int% field c_ispeed 52 | int% field c_ospeed 53 | end-struct termios 54 | 55 | Create t_old termios %allot drop 56 | Create t_buf termios %allot drop 57 | 58 | $300 Constant CS8 59 | $800 Constant CREAD 60 | $8000 Constant CLOCAL 61 | 0 Constant CBAUD 62 | 1 Constant IGNBRK 63 | 4 Constant IGNPAR 64 | &17 Constant VTIME 65 | &16 Constant VMIN 66 | $4004667F Constant FIONREAD 67 | 68 | &19200 Constant B19200 69 | &38400 Constant B38400 70 | &57600 Constant B57600 71 | &115200 Constant B115200 72 | 73 | : set-baud ( baud handle -- ) 74 | fileno >r r@ t_old tcgetattr drop 75 | t_old t_buf termios %size move 76 | [ IGNBRK IGNPAR or ] Literal t_buf c_iflag ! 77 | 0 t_buf c_oflag ! 78 | [ CS8 CREAD or CLOCAL or ] Literal t_buf c_cflag ! 79 | 0 t_buf c_lflag ! 80 | dup t_buf c_ispeed ! 81 | t_buf c_ospeed ! 82 | 0 t_buf c_line VMIN + c! 83 | 0 t_buf c_line VTIME + c! 84 | r> 1 t_buf tcsetattr drop 85 | ; 86 | : reset-baud ( handle -- ) fileno 1 t_old tcsetattr drop ; 87 | 88 | : check-read ( handle -- n ) fileno >r 0 sp@ r> FIONREAD rot ioctl

drop ; 89 | 90 | 0 Value handle 91 | 92 | : open-port ( addr u -- ) r/w open-file throw TO handle ; 93 | 94 | : term-read ( -- addr u ) pad handle check-read handle read-file throw pad swap ; 95 | 96 | : term-emit ( char -- ) handle emit-file throw ; 97 | 98 | : (term-type) ( addr u -- ) handle write-file throw ; 99 | 100 | : term-flush ( -- ) handle flush-file throw ; 101 | 102 | Create read-buf $400 chars allot 103 | Variable read-len 0 read-len ! 104 | 105 | : term-key? ( -- flag ) 106 | read-len @ IF true EXIT THEN 107 | term-read dup read-len ! read-buf swap chars cmove 108 | read-len @ 0<> ; 109 | 110 | : term-key ( -- char ) 111 | BEGIN term-key? UNTIL 112 | read-buf c@ -1 read-len +! 113 | read-buf char+ read-buf read-len @ cmove 114 | ; 115 | : Umbilical: ( baud -- ) \ e.g. B115200 Umbilical: /dev/cu.usbserial 116 | name open-port handle set-baud 117 | ; 118 | -------------------------------------------------------------------------------- /software/rs232_windows.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : rs232_windows.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 24.03.2021 17:54:31 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: uho - Ulrich Hoffmann 10 | \ @contributor: ks - Klaus Schleisiek 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : Terminal for gforth/R8C hacked by uho to run as an rs232 25 | \ cygwin interface under windows. 26 | \ This rs232-interface is unreliable and blocks infrequently 27 | \ due to Microsoft's infamous device drivers. 28 | \ 29 | \ Version Author Date Changes 30 | \ uho 15-Feb-2009 initial version 31 | \ ks 10-Apr-2020 some code simplifications. Didn't help thou. 32 | \ ---------------------------------------------------------------------- 33 | Only Forth also definitions 34 | 35 | require lib.fs 36 | 37 | library kernel32 kernel32 38 | 39 | kernel32 GetCommState int ptr (int) GetCommState ( handle addr -- r ) 40 | kernel32 SetCommState int ptr (int) SetCommState ( handle addr -- r ) 41 | kernel32 CreateFile ptr int int ptr int int ptr (int) CreateFileA ( name access share security disp attr temp -- handle ) 42 | kernel32 WriteFile int ptr int ptr ptr (int) WriteFile ( handle data size &len &data -- flag ) 43 | kernel32 ReadFile int ptr int ptr ptr (int) ReadFile ( handle data size &len &data -- flag ) 44 | kernel32 SetCommTimeouts int ptr (int) SetCommTimeouts ( handle addr -- flag ) 45 | kernel32 GetCommTimeouts int ptr (int) GetCommTimeouts ( handle addr -- flag ) 46 | kernel32 CloseHandle int (int) CloseHandle ( handle -- flag ) 47 | kernel32 SetupComm int int int (int) SetupComm ( handle #inq #outq -- flag ) 48 | 49 | 4 4 2Constant int% 50 | 2 2 2Constant word% 51 | 52 | struct 53 | int% field DCBlength 54 | int% field BaudRate 55 | int% field flags 56 | word% field wReserved 57 | word% field XonLim 58 | word% field XoffLim 59 | char% field ByteSize 60 | char% field Parity 61 | char% field StopBits 62 | char% field XonChar 63 | char% field XoffChar 64 | char% field ErrorChar 65 | char% field EofChar 66 | char% field EvtChar 67 | word% field wReserved1 68 | end-struct DCB 69 | 70 | struct 71 | int% field ReadIntervalTimeout 72 | int% field ReadTotalTimeoutMultiplier 73 | int% field ReadTotalTimeoutConstant 74 | int% field WriteTotalTimeoutMultiplier 75 | int% field WriteTotalTimeoutConstant 76 | end-struct COMMTIMEOUTS 77 | 78 | Create t_buf DCB %allot drop 79 | Create timeouts COMMTIMEOUTS %allot drop 80 | &128 Constant #buf-size 81 | 82 | 0 Value handle 83 | 84 | $80000000 Constant GENERIC_READ 85 | $40000000 Constant GENERIC_WRITE 86 | 3 Constant OPEN_EXISTING 87 | 88 | : open-port ( addr u -- ) 89 | tuck pad swap move 0 swap pad + c! \ 0 terminated string 90 | pad GENERIC_READ GENERIC_WRITE or 0 0 OPEN_EXISTING 0 0 CreateFile 91 | dup -1 = abort" serial port not available" TO handle 92 | handle #buf-size dup SetupComm drop 93 | ; 94 | : close-port ( -- ) 95 | handle ?dup 0= ?EXIT 96 | CloseHandle 0= abort" can not close serial port" 97 | 0 TO handle 98 | ; 99 | &19200 Constant B19200 100 | &38400 Constant B38400 101 | &57600 Constant B57600 102 | &115200 Constant B115200 103 | 104 | : set-baud ( baud handle -- ) >r 105 | r@ timeouts GetCommTimeouts drop 106 | -1 timeouts ReadIntervalTimeout ! 107 | 0 timeouts ReadTotalTimeoutMultiplier ! 108 | 0 timeouts ReadTotalTimeoutConstant ! 109 | 0 timeouts WriteTotalTimeoutMultiplier ! 110 | 0 timeouts WriteTotalTimeoutConstant ! 111 | r@ timeouts SetCommTimeouts drop 112 | t_buf DCB %size erase 113 | DCB %size t_buf DCBlength ! 114 | $1011 t_buf flags ! 115 | t_buf BaudRate ! 116 | 8 t_buf ByteSize c! 117 | 2 t_buf StopBits c! \ 2 stop bits 118 | 0 t_buf Parity c! \ no parity 119 | r> t_buf SetCommState drop 120 | ; 121 | : reset-baud ( handle -- ) drop ; 122 | 123 | Create read-buf #buf-size 1+ chars allot \ 0-terminated string, therfore 1+ 124 | Variable read-len 125 | 126 | : term-read ( -- addr u ) 127 | handle read-buf #buf-size read-len 0 ReadFile drop 128 | read-buf read-len @ 129 | ; 130 | : term-key? ( -- flag ) 131 | read-len @ IF true EXIT THEN 132 | term-read dup read-len ! nip 0<> 133 | ; 134 | : term-key ( -- char ) 135 | BEGIN term-key? 0= WHILE $80000 FOR NEXT REPEAT \ some waiting on 0, it does not work reliably otherwise 136 | read-buf c@ -1 read-len +! 137 | read-buf char+ read-buf read-len @ cmove 138 | ; 139 | Variable write-buf 140 | Variable write-len 141 | 142 | : (term-type) ( addr u -- ) handle -rot write-len 0 WriteFile drop ; 143 | 144 | : term-emit ( char -- ) write-buf c! write-buf 1 (term-type) ; 145 | 146 | : term-flush ( -- ) ; 147 | 148 | : Umbilical: ( baud -- ) \ e.g. B115200 Umbilical: COM3 149 | name open-port handle set-baud 150 | ; 151 | -------------------------------------------------------------------------------- /software/sim.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 30.07.2022 23:00:10 3 | \ 4 | \ microCore load screen for simulation. 5 | \ It produces program.mem for initialization of the program memory during simulation. 6 | \ 7 | Only Forth also definitions hex 8 | 9 | [IFDEF] unpatch unpatch [ENDIF] 10 | [IFDEF] close-port close-port [ENDIF] 11 | [IFDEF] microcore microcore [ENDIF] Marker microcore 12 | 13 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 14 | include ../vhdl/architecture_pkg_sim.vhd 15 | include microcross.fs \ the cross-compiler 16 | 17 | Target new initialized \ go into target compilation mode and initialize target compiler 18 | 19 | 6 trap-addr code-origin 20 | 0 data-origin 21 | 22 | include constants.fs \ MicroCore Register addresses and bits 23 | library forth_lib.fs 24 | 25 | \ ---------------------------------------------------------------------- 26 | \ Booting and TRAPs 27 | \ ---------------------------------------------------------------------- 28 | 29 | : boot ( -- ) 30 | $332211 #extern st @ 31 | BEGIN REPEAT 32 | ; 33 | 34 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 35 | #isr TRAP: isr ( -- ) di IRET ; 36 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 37 | 38 | end 39 | 40 | MEM-file program.mem cr .( sim.fs written to program.mem ) 41 | -------------------------------------------------------------------------------- /software/sim_break.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 04.08.2022 18:36:56 3 | \ 4 | \ MicroCore load screen for simulating the umbilical's break function. 5 | \ Constant break has to be set to '1' in bench.vhd. 6 | \ Use wave signal script break.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | \ Verbose on 19 | 20 | Target new initialized \ go into target compilation mode and initialize target compiler 21 | 22 | 8 trap-addr code-origin 23 | 0 data-origin 24 | 25 | include constants.fs \ microCore Register addresses and bits 26 | include debugger.fs 27 | library forth_lib.fs 28 | include multitask.fs 29 | 30 | Task Background 31 | 32 | Variable Counter 33 | Variable Rerun 34 | 35 | : bg_task ( -- ) 0 Counter ! 0 Rerun ! 36 | BEGIN pause 1 Counter +! Dsu @ Rerun @ 37 | 2dup or 0= IF Rerun on THEN 38 | and IF #c-bitout Ctrl ! THEN 39 | REPEAT 40 | ; 41 | : boot ( -- ) 42 | 0 Rerun cell+ erase CALL INITIALIZATION 43 | Terminal Background ['] bg_task spawn 44 | BEGIN pause REPEAT 45 | ; 46 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 47 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 48 | #break TRAP: break ( -- ) debugger ; 49 | #data! TRAP: data! ( dp n -- dp+1 ) swap st cell+ ; \ Data memory initialization 50 | 51 | end 52 | 53 | MEM-file program.mem cr .( sim_break.fs written to program.mem ) 54 | -------------------------------------------------------------------------------- /software/sim_core.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 02.04.2022 19:08:42 3 | \ 4 | \ MicroCore load screen for coretest simulation. 5 | \ It produces program.mem for initialization of the program memory during simulation. 6 | \ Use wave signal script core.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | \ Verbose on 19 | 20 | Target new initialized \ go into target compilation mode and initialize target compiler 21 | 22 | 9 trap-addr code-origin 23 | 0 data-origin 24 | 25 | include constants.fs \ MicroCore Register addresses and bits 26 | library forth_lib.fs 27 | include coretest.fs 28 | 29 | : boot ( -- ) CALL INITIALIZATION coretest BEGIN REPEAT ; 30 | 31 | \ ---------------------------------------------------------------------- 32 | \ Booting and TRAPs 33 | \ ---------------------------------------------------------------------- 34 | 35 | #reset TRAP: rst ( -- ) boot ; \ compile branch to coretest at reset vector location 36 | #isr TRAP: isr ( -- ) interrupt IRET ; 37 | #psr TRAP: psr ( -- ) #f-sema release ; \ matches coretest's test_sema 38 | #data! TRAP: data! ( dp n -- dp+ ) swap st cell+ ; \ Data memory initialization operator 39 | 40 | end 41 | 42 | MEM-file program.mem cr .( sim_core.fs written to program.mem ) 43 | -------------------------------------------------------------------------------- /software/sim_debug.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 02.10.2022 16:34:23 3 | \ 4 | \ MicroCore load screen for simulating the debug umbilical. 5 | \ It produces program.mem for initialization of the program memory during simulation. 6 | \ Constant debug has to be set to '1' in bench.vhd. 7 | \ Use wave signal script debug.do in the simulator directory. 8 | \ 9 | Only Forth also definitions 10 | 11 | [IFDEF] unpatch unpatch [ENDIF] 12 | [IFDEF] close-port close-port [ENDIF] 13 | [IFDEF] microcore microcore [ENDIF] Marker microcore 14 | 15 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 16 | include ../vhdl/architecture_pkg_sim.vhd 17 | include microcross.fs \ the cross-compiler 18 | 19 | Target new \ go into target compilation mode and initialize target compiler 20 | 21 | 3 trap-addr code-origin 22 | 0 data-origin 23 | 24 | include constants.fs \ microCore Register addresses and bits 25 | 26 | : boot ( -- ) 27 | $6699 $1155 1 st cell+ ! 28 | Debug-reg ld st ld over swap ! 29 | BEGIN REPEAT 30 | ; 31 | 32 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 33 | #isr TRAP: isr ( -- ) di IRET ; 34 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 35 | 36 | end 37 | 38 | MEM-file program.mem cr .( sim_debug.fs written to program.mem ) 39 | -------------------------------------------------------------------------------- /software/sim_download.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 02.10.2022 18:31:25 3 | \ 4 | \ MicroCore load screen to simulate the umbilical download function. 5 | \ Either constant download or upload has to be set to '1' in bench.vhd. 6 | \ Use wave signal script download.do and upload.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | Target new \ go into target compilation mode and initialize target compiler 19 | 20 | 3 trap-addr code-origin 21 | 0 data-origin 22 | 23 | include constants.fs \ microCore Register addresses and bits 24 | 25 | : boot ( -- ) 26 | $2211 1 cells $20 FOR over swap st cell+ NEXT ! 27 | [ H data_addr_width cache_addr_width u> T ] [IF] 28 | $8877 $6655 #extern st cell+ ! 29 | [THEN] 30 | host@ 31 | #c-bitout Ctrl ! 32 | BEGIN REPEAT 33 | ; 34 | 35 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 36 | #isr TRAP: isr ( -- ) di IRET ; 37 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 38 | 39 | end 40 | 41 | MEM-file program.mem cr .( sim_download.fs written to program.mem ) 42 | -------------------------------------------------------------------------------- /software/sim_handshake.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 10.05.2023 21:41:20 3 | \ 4 | \ MicroCore load screen for simulating the host <-> target synchronization. 5 | \ Constant handshake has to be set to '1' in bench.vhd. 6 | \ Use wave signal script handshake.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | Target new \ go into target compilation mode and initialize target compiler 19 | 20 | 8 trap-addr code-origin 21 | 0 data-origin 22 | 23 | include constants.fs \ microCore Register addresses and bits 24 | library forth_lib.fs 25 | 26 | Variable extern 27 | 28 | : boot ( -- ) \ handshake protocol from monitor.fs 29 | 0 extern ! #i-ext int-enable ei 30 | host@ drop 31 | BEGIN #warmboot host! host@ $3F5 = UNTIL 32 | BEGIN $305 host! host@ 0= UNTIL \ synchronise Host <-> Target communication 33 | BEGIN 0 host! host@ execute REPEAT \ the "monitor" loop 34 | ; 35 | : interrupt ( -- ) 1 extern +! ; 36 | 37 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 38 | #isr TRAP: isr ( -- ) interrupt IRET ; 39 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 40 | 41 | end 42 | 43 | MEM-file program.mem cr .( sim_handshake.fs written to program.mem ) 44 | -------------------------------------------------------------------------------- /software/sim_progload.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 21.03.2021 18:57:11 3 | \ 4 | \ MicroCore load screen to simulate program loading via the umbilical. 5 | \ 6 | \ Constant progload has to be set to '1' in bench.vhd. 7 | \ CONSTANT MEM_file has to be set to "" in architecture_pkg_sim.vhd 8 | \ Use wave signal script progload.do in the simulator directory. 9 | \ 10 | Only Forth also definitions 11 | 12 | [IFDEF] unpatch unpatch [ENDIF] 13 | [IFDEF] close-port close-port [ENDIF] 14 | [IFDEF] microcore microcore [ENDIF] Marker microcore 15 | 16 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 17 | include ../vhdl/architecture_pkg_sim.vhd 18 | include microcross.fs \ the cross-compiler 19 | 20 | Target new \ go into target compilation mode and initialize target compiler 21 | 22 | 0 code-origin 23 | 0 data-origin 24 | 25 | include constants.fs \ microCore Register addresses and bits 26 | 27 | ] $5555 4 BEGIN st ld REPEAT [ 28 | 29 | end 30 | 31 | VHDL-file ../vhdl/program.vhd cr .( sim_progload.fs written to ../vhdl/program.vhd ) 32 | -------------------------------------------------------------------------------- /software/sim_template.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 02.10.2022 16:34:45 3 | \ 4 | \ MicroCore load screen for simulation. 5 | \ It produces program.mem for initialization of the program memory during simulation. 6 | \ Use wave signal script xxxxxxxxx.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | Target new initialized \ go into target compilation mode and initialize target compiler 19 | 20 | 8 trap-addr code-origin 21 | 0 data-origin 22 | 23 | include constants.fs \ microCore Register addresses and bits 24 | library forth_lib.fs 25 | 26 | \ ---------------------------------------------------------------------- 27 | \ Interrupt 28 | \ ---------------------------------------------------------------------- 29 | 30 | : interrupt ( -- ) Intflags @ drop ; 31 | 32 | \ ---------------------------------------------------------------------- 33 | \ Booting and TRAPs 34 | \ ---------------------------------------------------------------------- 35 | 36 | : boot ( -- ) 37 | BEGIN REPEAT 38 | ; 39 | 40 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 41 | #isr TRAP: isr ( -- ) interrupt IRET ; 42 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 43 | #does> TRAP: dodoes ( addr -- addr' ) ld cell+ swap BRANCH ; \ the DOES> runtime primitive 44 | #data! TRAP: data! ( dp n -- dp+1 ) swap st cell+ ; \ Data memory initialization 45 | 46 | end 47 | 48 | MEM-file program.mem cr .( written to program.mem ) 49 | -------------------------------------------------------------------------------- /software/sim_upload.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ Last change: KS 04.10.2022 22:34:44 3 | \ 4 | \ MicroCore load screen to simulate the umbilical upload function. 5 | \ Either constant download or upload has to be set to '1' in bench.vhd. 6 | \ Use wave signal script download.do and upload.do in the simulator directory. 7 | \ 8 | Only Forth also definitions 9 | 10 | [IFDEF] unpatch unpatch [ENDIF] 11 | [IFDEF] close-port close-port [ENDIF] 12 | [IFDEF] microcore microcore [ENDIF] Marker microcore 13 | 14 | include extensions.fs \ Some System word (re)definitions for a more sympathetic environment 15 | include ../vhdl/architecture_pkg_sim.vhd 16 | include microcross.fs \ the cross-compiler 17 | 18 | Target new \ go into target compilation mode and initialize target compiler 19 | 20 | 3 trap-addr code-origin 21 | 0 data-origin 22 | 23 | include constants.fs \ microCore Register addresses and bits 24 | 25 | WITH_BYTES [IF] 26 | 27 | : boot ( -- ) 8 cells \ mem-addr on uCore 28 | BEGIN cld swap $11 = UNTIL 1+ 29 | BEGIN cld swap $12 = UNTIL 1+ 30 | BEGIN cld swap $13 = UNTIL 1+ 31 | BEGIN cld swap $14 = UNTIL 1+ 32 | BEGIN cld swap $15 = UNTIL 1+ 33 | BEGIN cld swap $16 = UNTIL drop 34 | [ H data_addr_width cache_addr_width u> T ] [IF] 35 | #extern 36 | BEGIN cld swap $25 = UNTIL 1+ 37 | BEGIN cld swap $26 = UNTIL 1+ 38 | BEGIN cld swap $27 = UNTIL 1+ 39 | BEGIN cld swap $28 = UNTIL drop 40 | [THEN] 41 | #c-bitout Ctrl ! 42 | BEGIN REPEAT 43 | ; 44 | [ELSE] \ cell addressed 45 | 46 | : boot ( -- ) 8 cells \ mem-addr on uCore 47 | BEGIN ld swap $11 = UNTIL 1+ 48 | BEGIN ld swap $12 = UNTIL 1+ 49 | BEGIN ld swap $13 = UNTIL 1+ 50 | BEGIN ld swap $14 = UNTIL drop 51 | [ H data_addr_width cache_addr_width u> T ] [IF] 52 | #extern 53 | BEGIN ld swap $25 = UNTIL 1+ 54 | BEGIN ld swap $26 = UNTIL 1+ 55 | BEGIN ld swap $27 = UNTIL 1+ 56 | BEGIN ld swap $28 = UNTIL drop 57 | [THEN] 58 | #c-bitout Ctrl ! 59 | BEGIN REPEAT 60 | ; 61 | [THEN] 62 | 63 | #reset TRAP: rst ( -- ) boot ; \ compile branch to boot at reset vector location 64 | #isr TRAP: isr ( -- ) di IRET ; 65 | #psr TRAP: psr ( -- ) pause ; \ reexecute the previous instruction 66 | 67 | end 68 | 69 | MEM-file program.mem cr .( sim_upload.fs written to program.mem ) 70 | -------------------------------------------------------------------------------- /software/task_lib.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : task_lib.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 16.07.2022 17:46:29 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : A co-operative multitasker for microCore. 25 | \ It has been split up into two parts: multitask.fs and task_lib.fs 26 | \ To use the multitasker, tasks_addr_width must be > 0 in 27 | \ architecture_pkg.vhd 28 | \ 29 | \ Version Author Date Changes 30 | \ 210 ks 02-May-2020 initial version 31 | \ 2200 ks 19-Oct-2020 library version, some simplifications 32 | \ 2400 ks 06-Jul-2022 Split up into multitask.fs and task_lib.fs 33 | \ ---------------------------------------------------------------------- 34 | \ Semaphore methods 35 | \ ---------------------------------------------------------------------- 36 | Target 37 | 38 | ~ : lock ( sema -- ) 39 | BEGIN ld swap dup IF TCB - THEN 40 | WHILE dup #t-sema tcb! halt 41 | REPEAT 42 | TCB swap #s-task + st 43 | [ #s-count #s-task - ] Literal + inc 44 | ; 45 | ~ : stopped ( lfa -- lfa' ) [ H there 'stopped ! T ] go-next ; 46 | 47 | : message ( n -- ) \ redefine message 48 | TCB Terminal = IF message EXIT THEN 49 | #t-poll tcb! ['] stopped TCB ! halt \ msg# -> t-poll, stopped -> t-exec 50 | ; 51 | ~ : semaphore-available ( sema -- ) 52 | >r Priority 53 | BEGIN next-task? 54 | WHILE dup RoundRobin = IF #t-link + @ THEN 55 | dup #t-sema + @ r@ = 56 | IF dup wake 0 over #t-sema + ! THEN 57 | REPEAT drop 58 | 0 r> #s-task + ! 59 | ; 60 | ~ : force-unlock ( sema -- ) 61 | dup cell+ dup dec @ IF drop EXIT THEN 62 | semaphore-available pause 63 | ; 64 | ~ : unlock ( sema -- ) dup @ TCB - IF #not-my-semaphore message THEN force-unlock ; 65 | 66 | ~ : wait ( sema -- ) \ can be used with SIGNAL executed inside interrupt servers 67 | TCB over st #s-count + \ lock semaphor 68 | BEGIN ld swap \ count > 0? 69 | IF dec 0 swap ! EXIT THEN \ decrement count and release semaphor 70 | halt \ wait for signal event 71 | REPEAT 72 | ; 73 | : signal ( sema -- ) dup #s-count + inc @ ?dup IF wake THEN ; 74 | 75 | \ ---------------------------------------------------------------------- 76 | \ Task management 77 | \ ---------------------------------------------------------------------- 78 | 79 | ~ : task-used? ( task-number -- f ) 80 | >r Priority #t-link + @ 81 | BEGIN dup RoundRobin = IF #t-link + @ THEN 82 | #t-dsp + ld swap dsp>task r@ = IF rdrop EXIT THEN 83 | [ #t-link #t-dsp - ] Literal + @ dup RRLink @ = 84 | UNTIL drop rdrop False 85 | ; 86 | : get-task-number ( -- task-number ) 87 | #tasks BEGIN 1- dup task-used? 0= ?EXIT dup 0= UNTIL 88 | #all-tasks-busy message 89 | ; 90 | : schedule ( task newtask -- ) \ link newtask into task list after task 91 | ['] go-next over ! >r 92 | get-task-number task>dsp r@ #t-dsp + ! 93 | dup #t-link + @ r@ #t-link + ! r@ swap #t-link + ! 94 | 0 r> #t-sema + ! 95 | ; 96 | ~ : spawn ( task newtask xt -- ) >r tuck schedule r> activate ; 97 | 98 | ~ : unlock-semaphores ( task -- ) \ used by deactive to free semaphores owned by task 99 | >r Sema-link @ 100 | BEGIN ?dup 101 | WHILE dup #s-task + @ r@ = 102 | IF 1 over #s-count + ! dup force-unlock THEN 103 | #s-link + @ 104 | REPEAT rdrop 105 | ; 106 | : deactivate ( task -- ) 107 | ['] go-next over ! 108 | dup unlock-semaphores 109 | 0 over #t-sema + ! 110 | TCB - ?EXIT 111 | TCB #t-link + 112 | GOTO go-next 113 | ; 114 | ~ : previous-task ( task -- task-1 ) 115 | >r Priority 116 | BEGIN dup RRLink @ = IF drop rdrop #task-not-linked message EXIT THEN 117 | dup #t-link + @ 118 | over RoundRobin = IF nip dup #t-link + @ THEN 119 | r@ = IF rdrop EXIT THEN #t-link + @ 120 | REPEAT 121 | ; 122 | : cancel ( task -- ) 123 | dup previous-task 124 | over #t-link + @ swap #t-link + ! \ link task out of task list 125 | dup RRLink @ = IF dup #t-link + @ RRLink ! THEN \ Move RoundRobin Pointer as well 126 | deactivate 127 | ; 128 | \ ---------------------------------------------------------------------- 129 | \ Polling services without and with time limit. 130 | \ 131 | \ Polling services have been added for performance reasons, because 132 | \ a task does not need to be woken up in order to check for an event. 133 | \ 134 | \ xt ist the execution token of a word, that checks some condition 135 | \ returning True when the condition is met. 136 | \ ---------------------------------------------------------------------- 137 | 138 | ~ : poll-exec ( xt t-exec -- ) TCB st #t-poll + ! halt ; 139 | 140 | ~ : do-poll ( lfa -- lfa' ) [ H there 'do-poll ! T ] 141 | dup [ #t-poll #t-link - ] Literal + @ execute 142 | 0= ?GOTO go-next GOTO do-wake 143 | ; 144 | : poll ( xt -- ) ['] do-poll poll-exec ; 145 | 146 | ~ : do-time ( lfa -- lfa' ) [ H there 'do-time ! T ] 147 | dup [ #t-time #t-link - ] Literal + @ 148 | time? 0= ?GOTO go-next 149 | 0 over [ #t-time #t-link - ] Literal + ! \ reset #t-time field 150 | GOTO do-wake 151 | ; 152 | ~ : do-poll-tmax ( lfa -- lfa' ) [ H there 'do-poll-tmax ! T ] 153 | dup [ #t-poll #t-link - ] Literal + @ execute 154 | ?GOTO do-wake do-time 155 | ; 156 | : poll-tmax ( xt ticks -- f ) \ true when condition met, false when timeout 157 | time + #t-time tcb! ['] do-poll-tmax poll-exec #t-time tcb@ 0<> 158 | ; 159 | \ ---------------------------------------------------------------------- 160 | \ Redefining forth_lib.fs' Time-reg based delays for the multitasker 161 | \ ---------------------------------------------------------------------- 162 | 163 | : continue ( time -- ) #t-time tcb! ['] do-time TCB ! halt ; 164 | 165 | : sleep ( ticks -- ) ahead continue ; 166 | 167 | \ ---------------------------------------------------------------------- 168 | \ Catch and throw for a multitasking environment 169 | \ ---------------------------------------------------------------------- 170 | 171 | ~ : rstack> ( -- rsp ) Rsp @ ; \ A call in order to push TOR into the return stack memory 172 | 173 | ~ : catch ( xt -- error# | 0 ) \ Return address is already on rstack 174 | Dsp @ >r ( xt ) \ Save data stack pointer, xt fills NOS slot 175 | #t-catch tcb@ >r ( xt ) \ Save previous #t-catch 176 | rstack> #t-catch tcb! ( xt ) \ Fill TOR and set #t-catch to RSP 177 | execute ( ) \ Execute the word passed on the stack 178 | r> #t-catch tcb! ( ) \ Restore previous #t-catch 179 | rdrop ( ) \ Discard saved stack pointer 180 | 0 ( 0 ) \ Signify normal completion 181 | ; 182 | : throw ( error# -- ) \ Returns to context saved by CATCH 183 | ?dup 0= ?EXIT \ Don't throw 0 184 | #t-catch tcb@ ?dup 0= IF #catch-not-initialized message THEN 185 | >rstack ( err# ) \ Return to saved return stack context 186 | r> #t-catch tcb! ( err# ) \ Restore previous #t-catch 187 | r> swap >r ( saved-dsp ) \ save err# temporarily on rstack 188 | >dstack r> ( err# ) \ Change stack pointer 189 | ; \ The final EXIT will return to the caller of CATCH, because the return stack has 190 | \ been restored to the state that existed when CATCH was executed. 191 | 192 | -------------------------------------------------------------------------------- /software/umbilical.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : umbilical.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 10.04.2021 19:43:21 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : This is the top level configuration file for the rs232 interface. 25 | \ Depending on your host's OS you have to comment-in the 26 | \ appropriate driver and fill in the name of the actual 27 | \ rs232 interface used. 28 | \ 29 | \ Version Author Date Changes 30 | \ 210 ks 14-Jun-2020 initial version 31 | \ ---------------------------------------------------------------------- 32 | SIMULATION [NOTIF] 33 | 34 | include rs232_linux.fs B115200 Umbilical: /dev/ttyUSB0 35 | \ include rs232_windows.fs B115200 Umbilical: COM3 36 | \ include rs232_macosx.fs B115200 Umbilical: /dev/cu.usbserial 37 | 38 | [THEN] 39 | -------------------------------------------------------------------------------- /software/vhdl.fs: -------------------------------------------------------------------------------- 1 | \ ---------------------------------------------------------------------- 2 | \ @file : vhdl.fs 3 | \ ---------------------------------------------------------------------- 4 | \ 5 | \ Last change: KS 01.03.2022 18:48:14 6 | \ @project: microForth/microCore 7 | \ @language: gforth_0.6.2 8 | \ @copyright (c): Free Software Foundation 9 | \ @original author: ks - Klaus Schleisiek 10 | \ @contributor: 11 | \ 12 | \ @license: This file is part of microForth. 13 | \ microForth is free software for microCore that loads on top of Gforth; 14 | \ you can redistribute it and/or modify it under the terms of the 15 | \ GNU General Public License as published by the Free Software Foundation, 16 | \ either version 3 of the License, or (at your option) any later version. 17 | \ This program is distributed in the hope that it will be useful, 18 | \ but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | \ GNU General Public License for more details. 21 | \ You should have received a copy of the GNU General Public License 22 | \ along with this program. If not, see http://www.gnu.org/licenses/. 23 | \ 24 | \ @brief : A simplistic VHDL interpreter for importing microCore 25 | \ architecture parameters into the cross compiler environment 26 | \ including e.g. bus widths and opcodes. To this end 27 | \ architecture_pkg.vhd will be loaded during cross compilation. 28 | \ Architecture_pkg has been written in a peculiar way so that 29 | \ it can be interpreted by the VHDL simulator, the 30 | \ VHDL synthesizer as well as the Forth cross compiler. 31 | \ When loaded by the cross compiler, code between --~ up to 32 | \ --~-- will be skipped. 33 | \ 34 | \ Version Author Date Changes 35 | \ 210 ks 14-Jun-2020 initial version 36 | \ 2200 ks 15-Dec-2020 more literal number formats 37 | \ ---------------------------------------------------------------------- 38 | \ E.g. the following VHDL expressions will be interpreted by Forth: 39 | \ 40 | \ CONSTANT WITH_MULT : BOOLEAN := false; 41 | \ CONSTANT data_width : NATURAL := 16; 42 | \ CONSTANT addr_rstack : NATURAL := 16#C00#; 43 | \ CONSTANT flag_reg : INTEGER := -2; 44 | \ CONSTANT op_NOOP : byte := "00000000"; 45 | \ CONSTANT op_NOOP : byte := X"00"; 46 | \ CONSTANT video_rate : REAL := 55.0; 47 | \ ---------------------------------------------------------------------- 48 | Forth definitions 49 | 50 | ' \ Alias -- immediate 51 | 52 | : base>number ( addr len -- n ) over c@ 53 | [char] ' case? IF 1 /string drop c@ [char] 1 = EXIT THEN 54 | [char] " case? IF 1 /string [char] " token binary s>number drop EXIT THEN 55 | [char] O case? IF 1 /string [char] " token octal s>number drop EXIT THEN 56 | [char] X = IF 1 /string [char] " token hex s>number drop EXIT THEN 57 | 2dup [char] # scan dup \ is it a NATURAL with base prefix? 58 | IF 2>r [char] # token decimal s>number drop Base ! 59 | 2r> [char] # token s>number drop 60 | EXIT THEN 2drop \ its a decimal number 61 | BL token decimal s>number drop 62 | ; 63 | : VHDL-number ( -- n ) Base save BL skip-input [char] ; parse base>number ; 64 | 65 | : dec_parameter ( -- n ) Base save BL skip-input [char] ; parse decimal s>number drop ; 66 | 67 | Vocabulary --VHDL --VHDL definitions 68 | 69 | 1 Constant STD_LOGIC 70 | 1 Constant byte 71 | 1 Constant NATURAL 72 | 1 Constant INTEGER 73 | 2 Constant BOOLEAN 74 | 3 Constant REAL 75 | 76 | : STD_LOGIC_VECTOR ( -- type ) postpone ( byte ; \ ) 77 | : UNSIGNED ( -- type ) postpone ( byte ; \ ) 78 | 79 | : CONSTANT ( -- ) 0 Constant ; 80 | 81 | : vhdl-types ( type -- n ) 82 | 1 case? IF VHDL-number EXIT THEN 83 | 2 case? IF [char] ; word count evaluate EXIT THEN \ for conditional compilation 84 | 3 case? IF dec_parameter &10 / EXIT THEN 85 | abort" unknown type" 86 | ; 87 | : := ( type -- ) Base save vhdl-types here cell- ! ; \ patch constant created before 88 | 89 | : --~ ( ccc~ -- ) [char] ~ scan-input ; \ ~ 90 | 91 | : --Forth ( ccc~ -- ) Forth --~ ; 92 | 93 | ' \ Alias -- 94 | ' noop Alias ; 95 | ' noop Alias : 96 | 97 | Forth definitions 98 | -------------------------------------------------------------------------------- /synplify/get_version.tcl: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /synplify/microCore.fdc: -------------------------------------------------------------------------------- 1 | 2 | ###==== BEGIN Header 3 | 4 | # Synopsys, Inc. constraint file 5 | # by Synplify Pro (R), M-2017.03L-SP1-1 FDC Constraint Editor 6 | 7 | # Custom constraint commands may be added outside of the SCOPE tab sections bounded with BEGIN/END. 8 | # These sections are generated from SCOPE spreadsheet tabs. 9 | 10 | ###==== END Header 11 | 12 | ###==== BEGIN Collections - (Populated from tab in SCOPE, do not edit) 13 | ###==== END Collections 14 | 15 | ###==== BEGIN Clocks - (Populated from tab in SCOPE, do not edit) 16 | create_clock -name {clk} {p:clock} -period {100} 17 | 18 | ###==== END Clocks 19 | 20 | ###==== BEGIN "Generated Clocks" - (Populated from tab in SCOPE, do not edit) 21 | ###==== END "Generated Clocks" 22 | 23 | ###==== BEGIN Inputs/Outputs - (Populated from tab in SCOPE, do not edit) 24 | ###==== END Inputs/Outputs 25 | 26 | ###==== BEGIN Registers - (Populated from tab in SCOPE, do not edit) 27 | ###==== END Registers 28 | 29 | ###==== BEGIN "Delay Paths" - (Populated from tab in SCOPE, do not edit) 30 | ###==== END "Delay Paths" 31 | 32 | ###==== BEGIN Attributes - (Populated from tab in SCOPE, do not edit) 33 | ###==== END Attributes 34 | 35 | ###==== BEGIN "I/O Standards" - (Populated from tab in SCOPE, do not edit) 36 | ###==== END "I/O Standards" 37 | 38 | ###==== BEGIN "Compile Points" - (Populated from tab in SCOPE, do not edit) 39 | ###==== END "Compile Points" 40 | 41 | -------------------------------------------------------------------------------- /synplify/microCore.prj: -------------------------------------------------------------------------------- 1 | #-- Synopsys, Inc. 2 | #-- Version N-2018.03L-SP1-1 3 | #-- Project file D:\technik\microcore\microCore\synplify\microCore.prj 4 | #-- Written on Tue Mar 30 23:39:08 2021 5 | 6 | 7 | #project files 8 | add_file -vhdl -lib work "../vhdl/functions_pkg.vhd" 9 | add_file -vhdl -lib work "../vhdl/architecture_pkg.vhd" 10 | add_file -vhdl -lib work "../vhdl/uArithmetic.vhd" 11 | add_file -vhdl -lib work "../vhdl/uCntrl.vhd" 12 | add_file -vhdl -lib work "../vhdl/uart.vhd" 13 | add_file -vhdl -lib work "../vhdl/debugger.vhd" 14 | add_file -vhdl -lib work "../vhdl/bootload.vhd" 15 | add_file -vhdl -lib work "../vhdl/uProgmem.vhd" 16 | add_file -vhdl -lib work "../vhdl/uCore.vhd" 17 | add_file -vhdl -lib work "../vhdl/uDatacache.vhd" 18 | add_file -vhdl -lib work "../vhdl/external_SRAM.vhd" 19 | add_file -vhdl -lib work "../vhdl/fpga.vhd" 20 | add_file -fpga_constraint "microCore.fdc" 21 | 22 | #implementation: "synplify" 23 | impl -add synplify -type fpga 24 | 25 | #implementation attributes 26 | set_option -vlog_std sysv 27 | set_option -project_relative_includes 1 28 | 29 | #device options 30 | set_option -technology LATTICE-XP2 31 | set_option -part LFXP2_8E 32 | set_option -package QN208C 33 | set_option -speed_grade -5 34 | set_option -part_companion "" 35 | 36 | #compilation/mapping options 37 | set_option -top_module "fpga" 38 | 39 | # hdl_compiler_options 40 | set_option -distributed_compile 0 41 | 42 | # mapper_without_write_options 43 | set_option -frequency 25 44 | set_option -auto_constrain_io 1 45 | set_option -default_enum_encoding onehot 46 | set_option -srs_instrumentation 1 47 | 48 | # mapper_options 49 | set_option -write_verilog 0 50 | set_option -write_vhdl 0 51 | 52 | # Lattice XP 53 | set_option -maxfan 1000 54 | set_option -disable_io_insertion 0 55 | set_option -retiming 0 56 | set_option -pipe 0 57 | set_option -forcegsr auto 58 | set_option -fix_gated_and_generated_clocks 1 59 | set_option -rw_check_on_ram 1 60 | set_option -update_models_cp 0 61 | set_option -syn_edif_array_rename 1 62 | set_option -Write_declared_clocks_only 1 63 | 64 | # NFilter 65 | set_option -no_sequential_opt 0 66 | 67 | # sequential_optimization_options 68 | set_option -symbolic_fsm_compiler 0 69 | 70 | # Compiler Options 71 | set_option -compiler_compatible 0 72 | set_option -resource_sharing 0 73 | set_option -multi_file_compilation_unit 1 74 | 75 | # Compiler Options 76 | set_option -auto_infer_blackbox 1 77 | 78 | #automatic place and route (vendor) options 79 | set_option -write_apr_constraint 1 80 | 81 | #set result format/file last 82 | project -result_file "./microCore.edn" 83 | impl -active "synplify" 84 | -------------------------------------------------------------------------------- /vhdl/architectures/12/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_cell.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 01.11.2022 19:01:28 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 17-Jun-2022 byte addressing using byte_addr_width 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | make_sim_mem: IF SIMULATION GENERATE 70 | 71 | internal_data_mem: internal_dpram 72 | GENERIC MAP (data_width, cache_size, "no_rw_check", DMEM_file) 73 | PORT MAP ( 74 | clk => clk, 75 | ena => enable, 76 | wea => write, 77 | addra => addr(cache_addr_width-1 DOWNTO 0), 78 | dia => wdata, 79 | doa => rdata, 80 | -- dma port 81 | enb => dma_enable, 82 | web => dma_write, 83 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 84 | dib => dma_wdata, 85 | dob => dma_rdata 86 | ); 87 | 88 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 89 | -- instantiate FPGA specific IP for cell addressed memory here: 90 | 91 | internal_data_mem: internal_dpram 92 | GENERIC MAP (data_width, cache_size, "no_rw_check") 93 | PORT MAP ( 94 | clk => clk, 95 | ena => enable, 96 | wea => write, 97 | addra => addr(cache_addr_width-1 DOWNTO 0), 98 | dia => wdata, 99 | doa => rdata, 100 | -- dma port 101 | enb => dma_enable, 102 | web => dma_write, 103 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 104 | dib => dma_wdata, 105 | dob => dma_rdata 106 | ); 107 | 108 | END GENERATE make_syn_mem; 109 | 110 | END rtl; 111 | 112 | -- append FPGA specific IP for byte or cell addressed memory here 113 | -------------------------------------------------------------------------------- /vhdl/architectures/16/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_cell.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 12.06.2023 23:37:58 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 17-Jun-2022 byte addressing using byte_addr_width 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | make_sim_mem: IF SIMULATION GENERATE 70 | 71 | internal_data_mem: internal_dpram 72 | GENERIC MAP (data_width, cache_size, "no_rw_check", DMEM_file) 73 | PORT MAP ( 74 | clk => clk, 75 | ena => enable, 76 | wea => write, 77 | addra => addr(cache_addr_width-1 DOWNTO 0), 78 | dia => wdata, 79 | doa => rdata, 80 | -- dma port 81 | enb => dma_enable, 82 | web => dma_write, 83 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 84 | dib => dma_wdata, 85 | dob => dma_rdata 86 | ); 87 | 88 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 89 | -- instantiate FPGA specific IP for cell addressed memory here: 90 | 91 | internal_data_mem: internal_dpram 92 | GENERIC MAP (data_width, cache_size, "no_rw_check") 93 | PORT MAP ( 94 | clk => clk, 95 | ena => enable, 96 | wea => write, 97 | addra => addr(cache_addr_width-1 DOWNTO 0), 98 | dia => wdata, 99 | doa => rdata, 100 | -- dma port 101 | enb => dma_enable, 102 | web => dma_write, 103 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 104 | dib => dma_wdata, 105 | dob => dma_rdata 106 | ); 107 | 108 | END GENERATE make_syn_mem; 109 | 110 | END rtl; 111 | 112 | -- append FPGA specific IP for byte or cell addressed memory here 113 | -------------------------------------------------------------------------------- /vhdl/architectures/16b/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_16b.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 06.07.2023 17:35:15 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 03-Nov-2022 byte addressing using byte_addr_width > 0 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | byte_access_proc : PROCESS(uBus, mem_rdata, dma_mem, dma_mem_rdata) 70 | BEGIN 71 | 72 | mem_wdata <= wdata; 73 | rdata <= mem_rdata; 74 | bytes_en <= (OTHERS => '1'); 75 | 76 | dma_mem_wdata <= dma_wdata; 77 | dma_rdata <= dma_mem_rdata; 78 | dma_bytes_en <= (OTHERS => '1'); 79 | 80 | -- 16 bit system 81 | IF byte_addr_width = 1 THEN 82 | IF bytes = 1 THEN -- byte access 83 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 84 | bytes_en <= "01"; 85 | rdata <= resize(mem_rdata(07 DOWNTO 0), data_width); 86 | IF addr(0) = '1' THEN 87 | bytes_en <= "10"; 88 | rdata <= resize(mem_rdata(15 DOWNTO 8), data_width); 89 | END IF; 90 | dma_mem_wdata <= dma_wdata(7 DOWNTO 0) & dma_wdata(7 DOWNTO 0); 91 | dma_bytes_en <= "01"; 92 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 0), data_width); 93 | IF dma_addr(0) = '1' THEN 94 | dma_bytes_en <= "10"; 95 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 8), data_width); 96 | END IF; 97 | END IF; 98 | END IF; 99 | 100 | -- 32 bit system 101 | IF byte_addr_width = 2 THEN 102 | IF bytes = 1 THEN -- byte access 103 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 104 | CASE addr(1 DOWNTO 0) IS 105 | WHEN "00" => bytes_en <= "0001"; 106 | rdata <= resize(mem_rdata(07 DOWNTO 00), data_width); 107 | WHEN "01" => bytes_en <= "0010"; 108 | rdata <= resize(mem_rdata(15 DOWNTO 08), data_width); 109 | WHEN "10" => bytes_en <= "0100"; 110 | rdata <= resize(mem_rdata(23 DOWNTO 16), data_width); 111 | WHEN "11" => bytes_en <= "1000"; 112 | rdata <= resize(mem_rdata(31 DOWNTO 24), data_width); 113 | WHEN OTHERS => NULL; 114 | END CASE; 115 | dma_mem_wdata <= dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0); 116 | CASE dma_addr(1 DOWNTO 0) IS 117 | WHEN "00" => dma_bytes_en <= "0001"; 118 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 00), data_width); 119 | WHEN "01" => dma_bytes_en <= "0010"; 120 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 08), data_width); 121 | WHEN "10" => dma_bytes_en <= "0100"; 122 | dma_rdata <= resize(dma_mem_rdata(23 DOWNTO 16), data_width); 123 | WHEN "11" => dma_bytes_en <= "1000"; 124 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 24), data_width); 125 | WHEN OTHERS => NULL; 126 | END CASE; 127 | ELSIF bytes = 2 THEN -- word access 128 | mem_wdata <= wdata(15 DOWNTO 0) & wdata(15 DOWNTO 0); 129 | bytes_en <= "0011"; 130 | rdata <= resize(mem_rdata(15 DOWNTO 0), data_width); 131 | IF addr(1) = '1' THEN 132 | bytes_en <= "1100"; 133 | rdata <= resize(mem_rdata(31 DOWNTO 16), data_width); 134 | END IF; 135 | dma_mem_wdata <= dma_wdata(15 DOWNTO 0) & dma_wdata(15 DOWNTO 0); 136 | dma_bytes_en <= "0011"; 137 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 0), data_width); 138 | IF dma_addr(1) = '1' THEN 139 | dma_bytes_en <= "1100"; 140 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 16), data_width); 141 | END IF; 142 | END IF; 143 | END IF; 144 | 145 | END PROCESS byte_access_proc; 146 | 147 | make_sim_mem: IF SIMULATION GENERATE 148 | 149 | internal_data_mem: internal_dpbram 150 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check", DMEM_file) 151 | PORT MAP ( 152 | clk => clk, 153 | ena => enable, 154 | wea => write, 155 | bytea => bytes_en, 156 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 157 | dia => mem_wdata, 158 | doa => mem_rdata, 159 | -- dma port 160 | enb => dma_enable, 161 | web => dma_write, 162 | byteb => dma_bytes_en, 163 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 164 | dib => dma_mem_wdata, 165 | dob => dma_mem_rdata 166 | ); 167 | 168 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 169 | -- instantiate FPGA specific IP for byte addressed memory here: 170 | 171 | internal_data_mem: internal_dpbram 172 | GENERIC MAP (data_width, cache_size, byte_addr_width, "rw_check") 173 | PORT MAP ( 174 | clk => clk, 175 | ena => enable, 176 | wea => write, 177 | bytea => bytes_en, 178 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 179 | dia => mem_wdata, 180 | doa => mem_rdata, 181 | -- dma port 182 | enb => dma_enable, 183 | web => dma_write, 184 | byteb => dma_bytes_en, 185 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 186 | dib => dma_mem_wdata, 187 | dob => dma_mem_rdata 188 | ); 189 | 190 | END GENERATE make_syn_mem; 191 | 192 | END rtl; 193 | 194 | -- append FPGA specific IP for byte or cell addressed memory here 195 | -------------------------------------------------------------------------------- /vhdl/architectures/27/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_cell.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 15.07.2023 12:03:14 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 17-Jun-2022 byte addressing using byte_addr_width 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | make_sim_mem: IF SIMULATION GENERATE 70 | 71 | internal_data_mem: internal_dpram 72 | GENERIC MAP (data_width, cache_size, "no_rw_check", DMEM_file) 73 | PORT MAP ( 74 | clk => clk, 75 | ena => enable, 76 | wea => write, 77 | addra => addr(cache_addr_width-1 DOWNTO 0), 78 | dia => wdata, 79 | doa => rdata, 80 | -- dma port 81 | enb => dma_enable, 82 | web => dma_write, 83 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 84 | dib => dma_wdata, 85 | dob => dma_rdata 86 | ); 87 | 88 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 89 | -- instantiate FPGA specific IP for cell addressed memory here: 90 | 91 | internal_data_mem: internal_dpram 92 | GENERIC MAP (data_width, cache_size, "no_rw_check") 93 | PORT MAP ( 94 | clk => clk, 95 | ena => enable, 96 | wea => write, 97 | addra => addr(cache_addr_width-1 DOWNTO 0), 98 | dia => wdata, 99 | doa => rdata, 100 | -- dma port 101 | enb => dma_enable, 102 | web => dma_write, 103 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 104 | dib => dma_wdata, 105 | dob => dma_rdata 106 | ); 107 | 108 | END GENERATE make_syn_mem; 109 | 110 | END rtl; 111 | 112 | -- append FPGA specific IP for byte or cell addressed memory here 113 | -------------------------------------------------------------------------------- /vhdl/architectures/32/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_cell.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 12.06.2023 23:37:58 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 17-Jun-2022 byte addressing using byte_addr_width 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | make_sim_mem: IF SIMULATION GENERATE 70 | 71 | internal_data_mem: internal_dpram 72 | GENERIC MAP (data_width, cache_size, "no_rw_check", DMEM_file) 73 | PORT MAP ( 74 | clk => clk, 75 | ena => enable, 76 | wea => write, 77 | addra => addr(cache_addr_width-1 DOWNTO 0), 78 | dia => wdata, 79 | doa => rdata, 80 | -- dma port 81 | enb => dma_enable, 82 | web => dma_write, 83 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 84 | dib => dma_wdata, 85 | dob => dma_rdata 86 | ); 87 | 88 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 89 | -- instantiate FPGA specific IP for cell addressed memory here: 90 | 91 | internal_data_mem: internal_dpram 92 | GENERIC MAP (data_width, cache_size, "no_rw_check") 93 | PORT MAP ( 94 | clk => clk, 95 | ena => enable, 96 | wea => write, 97 | addra => addr(cache_addr_width-1 DOWNTO 0), 98 | dia => wdata, 99 | doa => rdata, 100 | -- dma port 101 | enb => dma_enable, 102 | web => dma_write, 103 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 104 | dib => dma_wdata, 105 | dob => dma_rdata 106 | ); 107 | 108 | END GENERATE make_syn_mem; 109 | 110 | END rtl; 111 | 112 | -- append FPGA specific IP for byte or cell addressed memory here 113 | -------------------------------------------------------------------------------- /vhdl/architectures/32b/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_byte.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 02.11.2022 23:17:05 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 03-Nov-2022 byte addressing using byte_addr_width > 0 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | byte_access_proc : PROCESS(uBus, mem_rdata, dma_mem, dma_mem_rdata) 70 | BEGIN 71 | 72 | mem_wdata <= wdata; 73 | rdata <= mem_rdata; 74 | bytes_en <= (OTHERS => '1'); 75 | 76 | dma_mem_wdata <= dma_wdata; 77 | dma_rdata <= dma_mem_rdata; 78 | dma_bytes_en <= (OTHERS => '1'); 79 | 80 | -- 16 bit system 81 | IF byte_addr_width = 1 THEN 82 | IF bytes = 1 THEN -- byte access 83 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 84 | bytes_en <= "01"; 85 | rdata <= resize(mem_rdata(07 DOWNTO 0), data_width); 86 | IF addr(0) = '1' THEN 87 | bytes_en <= "10"; 88 | rdata <= resize(mem_rdata(15 DOWNTO 8), data_width); 89 | END IF; 90 | dma_mem_wdata <= dma_wdata(7 DOWNTO 0) & dma_wdata(7 DOWNTO 0); 91 | dma_bytes_en <= "01"; 92 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 0), data_width); 93 | IF dma_addr(0) = '1' THEN 94 | dma_bytes_en <= "10"; 95 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 8), data_width); 96 | END IF; 97 | END IF; 98 | END IF; 99 | 100 | -- 32 bit system 101 | IF byte_addr_width = 2 THEN 102 | IF bytes = 1 THEN -- byte access 103 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 104 | CASE addr(1 DOWNTO 0) IS 105 | WHEN "00" => bytes_en <= "0001"; 106 | rdata <= resize(mem_rdata(07 DOWNTO 00), data_width); 107 | WHEN "01" => bytes_en <= "0010"; 108 | rdata <= resize(mem_rdata(15 DOWNTO 08), data_width); 109 | WHEN "10" => bytes_en <= "0100"; 110 | rdata <= resize(mem_rdata(23 DOWNTO 16), data_width); 111 | WHEN "11" => bytes_en <= "1000"; 112 | rdata <= resize(mem_rdata(31 DOWNTO 24), data_width); 113 | WHEN OTHERS => NULL; 114 | END CASE; 115 | dma_mem_wdata <= dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0); 116 | CASE dma_addr(1 DOWNTO 0) IS 117 | WHEN "00" => dma_bytes_en <= "0001"; 118 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 00), data_width); 119 | WHEN "01" => dma_bytes_en <= "0010"; 120 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 08), data_width); 121 | WHEN "10" => dma_bytes_en <= "0100"; 122 | dma_rdata <= resize(dma_mem_rdata(23 DOWNTO 16), data_width); 123 | WHEN "11" => dma_bytes_en <= "1000"; 124 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 24), data_width); 125 | WHEN OTHERS => NULL; 126 | END CASE; 127 | ELSIF bytes = 2 THEN -- word access 128 | mem_wdata <= wdata(15 DOWNTO 0) & wdata(15 DOWNTO 0); 129 | bytes_en <= "0011"; 130 | rdata <= resize(mem_rdata(15 DOWNTO 0), data_width); 131 | IF addr(1) = '1' THEN 132 | bytes_en <= "1100"; 133 | rdata <= resize(mem_rdata(31 DOWNTO 16), data_width); 134 | END IF; 135 | dma_mem_wdata <= dma_wdata(15 DOWNTO 0) & dma_wdata(15 DOWNTO 0); 136 | dma_bytes_en <= "0011"; 137 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 0), data_width); 138 | IF dma_addr(1) = '1' THEN 139 | dma_bytes_en <= "1100"; 140 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 16), data_width); 141 | END IF; 142 | END IF; 143 | END IF; 144 | 145 | END PROCESS byte_access_proc; 146 | 147 | make_sim_mem: IF SIMULATION GENERATE 148 | 149 | internal_data_mem: internal_dpbram 150 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check", DMEM_file) 151 | PORT MAP ( 152 | clk => clk, 153 | ena => enable, 154 | wea => write, 155 | bytea => bytes_en, 156 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 157 | dia => mem_wdata, 158 | doa => mem_rdata, 159 | -- dma port 160 | enb => dma_enable, 161 | web => dma_write, 162 | byteb => dma_bytes_en, 163 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 164 | dib => dma_mem_wdata, 165 | dob => dma_mem_rdata 166 | ); 167 | 168 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 169 | -- instantiate FPGA specific IP for byte addressed memory here: 170 | 171 | internal_data_mem: internal_dpbram 172 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check") 173 | PORT MAP ( 174 | clk => clk, 175 | ena => enable, 176 | wea => write, 177 | bytea => bytes_en, 178 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 179 | dia => mem_wdata, 180 | doa => mem_rdata, 181 | -- dma port 182 | enb => dma_enable, 183 | web => dma_write, 184 | byteb => dma_bytes_en, 185 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 186 | dib => dma_mem_wdata, 187 | dob => dma_mem_rdata 188 | ); 189 | 190 | END GENERATE make_syn_mem; 191 | 192 | END rtl; 193 | 194 | -- append FPGA specific IP for byte or cell addressed memory here 195 | -------------------------------------------------------------------------------- /vhdl/architectures/uDatacache_byte.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_byte.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 02.11.2022 23:17:05 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 03-Nov-2022 byte addressing using byte_addr_width > 0 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | byte_access_proc : PROCESS(uBus, mem_rdata, dma_mem, dma_mem_rdata) 70 | BEGIN 71 | 72 | mem_wdata <= wdata; 73 | rdata <= mem_rdata; 74 | bytes_en <= (OTHERS => '1'); 75 | 76 | dma_mem_wdata <= dma_wdata; 77 | dma_rdata <= dma_mem_rdata; 78 | dma_bytes_en <= (OTHERS => '1'); 79 | 80 | -- 16 bit system 81 | IF byte_addr_width = 1 THEN 82 | IF bytes = 1 THEN -- byte access 83 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 84 | bytes_en <= "01"; 85 | rdata <= resize(mem_rdata(07 DOWNTO 0), data_width); 86 | IF addr(0) = '1' THEN 87 | bytes_en <= "10"; 88 | rdata <= resize(mem_rdata(15 DOWNTO 8), data_width); 89 | END IF; 90 | dma_mem_wdata <= dma_wdata(7 DOWNTO 0) & dma_wdata(7 DOWNTO 0); 91 | dma_bytes_en <= "01"; 92 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 0), data_width); 93 | IF dma_addr(0) = '1' THEN 94 | dma_bytes_en <= "10"; 95 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 8), data_width); 96 | END IF; 97 | END IF; 98 | END IF; 99 | 100 | -- 32 bit system 101 | IF byte_addr_width = 2 THEN 102 | IF bytes = 1 THEN -- byte access 103 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 104 | CASE addr(1 DOWNTO 0) IS 105 | WHEN "00" => bytes_en <= "0001"; 106 | rdata <= resize(mem_rdata(07 DOWNTO 00), data_width); 107 | WHEN "01" => bytes_en <= "0010"; 108 | rdata <= resize(mem_rdata(15 DOWNTO 08), data_width); 109 | WHEN "10" => bytes_en <= "0100"; 110 | rdata <= resize(mem_rdata(23 DOWNTO 16), data_width); 111 | WHEN "11" => bytes_en <= "1000"; 112 | rdata <= resize(mem_rdata(31 DOWNTO 24), data_width); 113 | WHEN OTHERS => NULL; 114 | END CASE; 115 | dma_mem_wdata <= dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0); 116 | CASE dma_addr(1 DOWNTO 0) IS 117 | WHEN "00" => dma_bytes_en <= "0001"; 118 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 00), data_width); 119 | WHEN "01" => dma_bytes_en <= "0010"; 120 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 08), data_width); 121 | WHEN "10" => dma_bytes_en <= "0100"; 122 | dma_rdata <= resize(dma_mem_rdata(23 DOWNTO 16), data_width); 123 | WHEN "11" => dma_bytes_en <= "1000"; 124 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 24), data_width); 125 | WHEN OTHERS => NULL; 126 | END CASE; 127 | ELSIF bytes = 2 THEN -- word access 128 | mem_wdata <= wdata(15 DOWNTO 0) & wdata(15 DOWNTO 0); 129 | bytes_en <= "0011"; 130 | rdata <= resize(mem_rdata(15 DOWNTO 0), data_width); 131 | IF addr(1) = '1' THEN 132 | bytes_en <= "1100"; 133 | rdata <= resize(mem_rdata(31 DOWNTO 16), data_width); 134 | END IF; 135 | dma_mem_wdata <= dma_wdata(15 DOWNTO 0) & dma_wdata(15 DOWNTO 0); 136 | dma_bytes_en <= "0011"; 137 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 0), data_width); 138 | IF dma_addr(1) = '1' THEN 139 | dma_bytes_en <= "1100"; 140 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 16), data_width); 141 | END IF; 142 | END IF; 143 | END IF; 144 | 145 | END PROCESS byte_access_proc; 146 | 147 | make_sim_mem: IF SIMULATION GENERATE 148 | 149 | internal_data_mem: internal_dpbram 150 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check", DMEM_file) 151 | PORT MAP ( 152 | clk => clk, 153 | ena => enable, 154 | wea => write, 155 | bytea => bytes_en, 156 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 157 | dia => mem_wdata, 158 | doa => mem_rdata, 159 | -- dma port 160 | enb => dma_enable, 161 | web => dma_write, 162 | byteb => dma_bytes_en, 163 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 164 | dib => dma_mem_wdata, 165 | dob => dma_mem_rdata 166 | ); 167 | 168 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 169 | -- instantiate FPGA specific IP for byte addressed memory here: 170 | 171 | internal_data_mem: internal_dpbram 172 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check") 173 | PORT MAP ( 174 | clk => clk, 175 | ena => enable, 176 | wea => write, 177 | bytea => bytes_en, 178 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 179 | dia => mem_wdata, 180 | doa => mem_rdata, 181 | -- dma port 182 | enb => dma_enable, 183 | web => dma_write, 184 | byteb => dma_bytes_en, 185 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 186 | dib => dma_mem_wdata, 187 | dob => dma_mem_rdata 188 | ); 189 | 190 | END GENERATE make_syn_mem; 191 | 192 | END rtl; 193 | 194 | -- append FPGA specific IP for byte or cell addressed memory here 195 | -------------------------------------------------------------------------------- /vhdl/architectures/uDatacache_cell.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_cell.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 12.06.2023 23:37:58 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 17-Jun-2022 byte addressing using byte_addr_width 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | make_sim_mem: IF SIMULATION GENERATE 70 | 71 | internal_data_mem: internal_dpram 72 | GENERIC MAP (data_width, cache_size, "no_rw_check", DMEM_file) 73 | PORT MAP ( 74 | clk => clk, 75 | ena => enable, 76 | wea => write, 77 | addra => addr(cache_addr_width-1 DOWNTO 0), 78 | dia => wdata, 79 | doa => rdata, 80 | -- dma port 81 | enb => dma_enable, 82 | web => dma_write, 83 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 84 | dib => dma_wdata, 85 | dob => dma_rdata 86 | ); 87 | 88 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 89 | -- instantiate FPGA specific IP for cell addressed memory here: 90 | 91 | internal_data_mem: internal_dpram 92 | GENERIC MAP (data_width, cache_size, "no_rw_check") 93 | PORT MAP ( 94 | clk => clk, 95 | ena => enable, 96 | wea => write, 97 | addra => addr(cache_addr_width-1 DOWNTO 0), 98 | dia => wdata, 99 | doa => rdata, 100 | -- dma port 101 | enb => dma_enable, 102 | web => dma_write, 103 | addrb => dma_addr(cache_addr_width-1 DOWNTO 0), 104 | dib => dma_wdata, 105 | dob => dma_rdata 106 | ); 107 | 108 | END GENERATE make_syn_mem; 109 | 110 | END rtl; 111 | 112 | -- append FPGA specific IP for byte or cell addressed memory here 113 | -------------------------------------------------------------------------------- /vhdl/bootload.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Program memory ROM implemented using a case statement. 3 | -- Its content was generated by the microCore cross compiler. 4 | -- It will be statically synthesized into the design as cold bootrom. 5 | 6 | LIBRARY IEEE; 7 | USE IEEE.STD_LOGIC_1164.ALL; 8 | USE IEEE.NUMERIC_STD.ALL; 9 | USE work.architecture_pkg.ALL; 10 | 11 | ENTITY boot_rom IS PORT ( 12 | addr : IN boot_addr_bus; 13 | data : OUT inst_bus 14 | ); END boot_rom; 15 | 16 | ARCHITECTURE sim_model OF boot_rom IS 17 | 18 | SUBTYPE rom_address IS NATURAL RANGE 0 TO 2**boot_addr_width-1; 19 | 20 | FUNCTION program(addr : rom_address) RETURN UNSIGNED IS 21 | BEGIN 22 | CASE addr IS 23 | WHEN 16#0000# => RETURN "10000000"; 24 | WHEN 16#0001# => RETURN "00000000"; 25 | WHEN 16#0002# => RETURN "11111110"; 26 | WHEN 16#0003# => RETURN "00001001"; 27 | WHEN 16#0004# => RETURN "01011101"; 28 | WHEN OTHERS => RETURN "--------"; 29 | END CASE; 30 | END program; 31 | 32 | BEGIN 33 | 34 | data <= program(to_integer(addr)); 35 | 36 | END sim_model; -------------------------------------------------------------------------------- /vhdl/bootload_sim.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Program memory ROM implemented using a case statement. 3 | -- Its content was generated by the microCore cross compiler. 4 | -- It will be statically synthesized into the design as cold bootrom. 5 | 6 | LIBRARY IEEE; 7 | USE IEEE.STD_LOGIC_1164.ALL; 8 | USE IEEE.NUMERIC_STD.ALL; 9 | USE work.architecture_pkg.ALL; 10 | 11 | ENTITY boot_rom IS PORT ( 12 | addr : IN boot_addr_bus; 13 | data : OUT inst_bus 14 | ); END boot_rom; 15 | 16 | ARCHITECTURE sim_model OF boot_rom IS 17 | 18 | SUBTYPE rom_address IS NATURAL RANGE 0 TO 2**boot_addr_width-1; 19 | 20 | FUNCTION program(addr : rom_address) RETURN UNSIGNED IS 21 | BEGIN 22 | CASE addr IS 23 | WHEN 16#0000# => RETURN "10000000"; 24 | WHEN 16#0001# => RETURN "00000000"; 25 | WHEN 16#0002# => RETURN "00001001"; 26 | WHEN 16#0003# => RETURN "01011101"; 27 | WHEN OTHERS => RETURN "--------"; 28 | END CASE; 29 | END program; 30 | 31 | BEGIN 32 | 33 | data <= program(to_integer(addr)); 34 | 35 | END sim_model; -------------------------------------------------------------------------------- /vhdl/external_SRAM.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : external_SRAM.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 15.07.2023 19:35:08 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Connecting external SRAM memories to microCore. Scaled 20 | -- by the ram_... constants in architecture_pkg.vhd 21 | -- This version can only be used if byte_addr_width = 0. 22 | -- 23 | -- Version Author Date Changes 24 | -- 210 ks 8-Jun-2020 initial version 25 | -- 2300 ks 4-Mar-2021 converted to NUMERIC_STD 26 | -- 2310 ks 22-Mar-2021 Bugfix in data_mux_proc 27 | -- --------------------------------------------------------------------- 28 | LIBRARY IEEE; 29 | USE IEEE.STD_LOGIC_1164.ALL; 30 | USE IEEE.NUMERIC_STD.ALL; 31 | USE work.functions_pkg.ALL; 32 | USE work.architecture_pkg.ALL; 33 | 34 | ENTITY external_SRAM IS GENERIC ( 35 | ram_addr_width : NATURAL; -- addr width of the external SRAM 36 | ram_data_width : NATURAL; -- data width of the external SRAM 37 | delay_cnt : NATURAL -- delay_cnt+1 extra clock cycles for each memory access 38 | ); PORT ( 39 | uBus : IN uBus_port; 40 | ext_rdata : OUT data_bus; 41 | delay : OUT STD_LOGIC; 42 | -- external SRAM 43 | ce_n : OUT STD_LOGIC; 44 | oe_n : OUT STD_LOGIC; 45 | we_n : OUT STD_LOGIC; 46 | addr : OUT UNSIGNED(ram_addr_width-1 DOWNTO 0); 47 | data : INOUT UNSIGNED(ram_data_width-1 DOWNTO 0) 48 | ); END external_SRAM; 49 | 50 | ARCHITECTURE rtl OF external_SRAM IS 51 | 52 | ALIAS reset : STD_LOGIC IS uBus.reset; 53 | ALIAS clk : STD_LOGIC IS uBus.clk; 54 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 55 | ALIAS ext_en : STD_LOGIC IS uBus.ext_en; 56 | ALIAS write : STD_LOGIC IS uBus.write; 57 | ALIAS wdata : data_bus IS uBus.wdata; 58 | 59 | CONSTANT residue : NATURAL := data_width MOD ram_data_width; 60 | CONSTANT leader : NATURAL := (ram_data_width - residue) MOD ram_data_width; 61 | 62 | SIGNAL delay_ctr : NATURAL RANGE 0 TO umax(delay_cnt, cycles-1); 63 | SIGNAL ext_ce : STD_LOGIC; 64 | SIGNAL sub_addr : UNSIGNED(ram_subbits-1 DOWNTO 0); 65 | SIGNAL LSword : UNSIGNED((ram_data_width * (ram_chunks-1))-1 DOWNTO 0); 66 | 67 | -- defined in architecture_pkg.vhd 68 | -- CONSTANT ram_data_width : NATURAL := 8; -- external memory word width 69 | -- CONSTANT ram_chunks : NATURAL := ceiling(data_width, ram_data_width); 70 | -- CONSTANT ram_subbits : NATURAL := log2(ram_chunks); 71 | 72 | BEGIN 73 | 74 | -- --------------------------------------------------------------------- 75 | -- ram_data_width < data_width 76 | -- --------------------------------------------------------------------- 77 | 78 | if_wide_data: IF ram_data_width < data_width GENERATE 79 | 80 | delay <= '1' WHEN ext_en = '1' AND (ext_ce = '0' OR delay_ctr /= 0 OR sub_addr /= ram_chunks-1) ELSE '0'; 81 | 82 | rdata_proc : PROCESS (data, LSword) 83 | BEGIN 84 | IF residue = 0 THEN 85 | ext_rdata <= data & LSword; 86 | ELSE 87 | ext_rdata <= data(residue-1 DOWNTO 0) & LSword; 88 | END IF; 89 | END PROCESS rdata_proc; 90 | 91 | ce_n <= NOT ext_ce; 92 | addr <= resize(uBus.addr & sub_addr, addr'length); 93 | 94 | data_mux_proc: PROCESS (uBus, sub_addr, wdata, ext_ce) 95 | VARIABLE subaddr : NATURAL; 96 | VARIABLE maxdata : UNSIGNED((ram_data_width * ram_chunks)-1 DOWNTO 0); 97 | VARIABLE subdata : UNSIGNED(data'range); 98 | BEGIN 99 | subaddr := to_integer(sub_addr); 100 | maxdata := slice('0', leader) & wdata; 101 | subdata := maxdata((ram_data_width * (subaddr + 1))-1 DOWNTO ram_data_width * subaddr); 102 | data <= (OTHERS => 'Z'); 103 | IF uBus.write = '1' AND ext_ce = '1' THEN 104 | data <= subdata; 105 | END IF; 106 | END PROCESS data_mux_proc; 107 | 108 | SRAM_proc: PROCESS (clk) 109 | BEGIN 110 | IF reset = '1' AND ASYNC_RESET THEN 111 | delay_ctr <= cycles - 1; 112 | ext_ce <= '0'; 113 | we_n <= '1'; 114 | oe_n <= '1'; 115 | ELSIF rising_edge(clk) THEN 116 | IF delay_ctr = 0 THEN 117 | IF ext_ce = '0' AND ext_en = '1' THEN 118 | delay_ctr <= delay_cnt; 119 | sub_addr <= (OTHERS => '0'); 120 | ext_ce <= '1'; 121 | END IF; 122 | IF ext_ce = '1' AND sub_addr /= ram_chunks-1 THEN 123 | sub_addr <= sub_addr + 1; 124 | delay_ctr <= delay_cnt; 125 | LSword <= data & LSword(LSword'high DOWNTO ram_data_width); 126 | we_n <= '1'; 127 | END IF; 128 | IF clk_en = '1' AND sub_addr = ram_chunks-1 THEN 129 | sub_addr <= (OTHERS => '0'); 130 | delay_ctr <= cycles - 1; 131 | ext_ce <= '0'; 132 | we_n <= '1'; 133 | oe_n <= '1'; 134 | END IF; 135 | ELSIF ext_en = '1' THEN 136 | delay_ctr <= delay_ctr - 1; 137 | IF delay_ctr = delay_cnt AND ext_ce = '1' THEN 138 | IF uBus.write = '1' THEN 139 | we_n <= '0'; 140 | ELSE 141 | oe_n <= '0'; 142 | END IF; 143 | END IF; 144 | END IF; 145 | IF reset = '1' AND NOT ASYNC_RESET THEN 146 | delay_ctr <= cycles - 1; 147 | ext_ce <= '0'; 148 | we_n <= '1'; 149 | oe_n <= '1'; 150 | END IF; 151 | END IF; 152 | END PROCESS SRAM_proc; 153 | 154 | END GENERATE if_wide_data; 155 | 156 | -- --------------------------------------------------------------------- 157 | -- ram_data_width >= data_width 158 | -- --------------------------------------------------------------------- 159 | 160 | else_wide_data: IF ram_data_width >= data_width GENERATE 161 | 162 | delay <= '1' WHEN ext_en = '1' AND (ext_ce = '0' OR delay_ctr /= 0) ELSE '0'; 163 | 164 | ce_n <= NOT ext_ce; 165 | addr <= resize(uBus.addr, addr'length); 166 | 167 | data_mux_proc: PROCESS (uBus, ext_ce, wdata) 168 | BEGIN 169 | data <= (OTHERS => 'Z'); 170 | IF uBus.write = '1' AND ext_ce = '1' THEN 171 | data(data_width-1 DOWNTO 0) <= wdata; 172 | IF residue /= 0 THEN 173 | data(ram_data_width-1 DOWNTO data_width) <= (OTHERS => '0'); 174 | END IF; 175 | END IF; 176 | END PROCESS data_mux_proc; 177 | 178 | ext_rdata <= data(data_width-1 DOWNTO 0); 179 | 180 | SRAM_proc: PROCESS (clk) 181 | BEGIN 182 | IF reset = '1' AND ASYNC_RESET THEN 183 | delay_ctr <= 0; 184 | ext_ce <= '0'; 185 | we_n <= '1'; 186 | oe_n <= '1'; 187 | ELSIF rising_edge(clk) THEN 188 | IF delay_ctr = 0 THEN 189 | IF ext_ce = '0' AND ext_en = '1' THEN 190 | delay_ctr <= delay_cnt; 191 | ext_ce <= '1'; 192 | END IF; 193 | IF ext_ce = '1' THEN 194 | delay_ctr <= delay_cnt; 195 | we_n <= '1'; 196 | END IF; 197 | IF clk_en = '1' THEN 198 | delay_ctr <= cycles - 1; 199 | ext_ce <= '0'; 200 | we_n <= '1'; 201 | oe_n <= '1'; 202 | END IF; 203 | ELSIF ext_en = '1' THEN 204 | delay_ctr <= delay_ctr - 1; 205 | IF delay_ctr = delay_cnt AND ext_ce = '1' THEN 206 | IF uBus.write = '1' THEN 207 | we_n <= '0'; 208 | ELSE 209 | oe_n <= '0'; 210 | END IF; 211 | END IF; 212 | END IF; 213 | IF reset = '1' AND NOT ASYNC_RESET THEN 214 | delay_ctr <= 0; 215 | ext_ce <= '0'; 216 | we_n <= '1'; 217 | oe_n <= '1'; 218 | END IF; 219 | END IF; 220 | END PROCESS SRAM_proc; 221 | 222 | END GENERATE else_wide_data; 223 | 224 | END rtl; 225 | -------------------------------------------------------------------------------- /vhdl/header.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : .vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 05.04.2021 16:53:00 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: 20 | -- 21 | -- Version Author Date Changes 22 | -- ks 8-Jun-2020 initial version 23 | -- --------------------------------------------------------------------- 24 | 25 | -------------------------------------------------------------------------------- /vhdl/program.vhd: -------------------------------------------------------------------------------- 1 | -- 2 | -- Program memory ROM implemented using a case statement. 3 | -- It is generated by the microCore cross compiler. 4 | 5 | LIBRARY IEEE; 6 | USE IEEE.STD_LOGIC_1164.ALL; 7 | USE IEEE.NUMERIC_STD.ALL; 8 | USE work.architecture_pkg.ALL; 9 | 10 | ENTITY program_rom IS PORT ( 11 | addr : IN program_addr; 12 | data : OUT inst_bus 13 | ); END program_rom; 14 | 15 | ARCHITECTURE sim_model OF program_rom IS 16 | 17 | SUBTYPE rom_address IS NATURAL RANGE 0 TO 2**prog_addr_width-1; 18 | 19 | FUNCTION program(addr : rom_address) RETURN UNSIGNED IS 20 | BEGIN 21 | CASE addr IS 22 | WHEN 16#0000# => RETURN "10000001"; 23 | WHEN 16#0001# => RETURN "10101010"; 24 | WHEN 16#0002# => RETURN "11010101"; 25 | WHEN 16#0003# => RETURN "00000000"; 26 | WHEN 16#0004# => RETURN "10000100"; 27 | WHEN 16#0005# => RETURN "00000000"; 28 | WHEN 16#0006# => RETURN "01001000"; 29 | WHEN 16#0007# => RETURN "01010000"; 30 | WHEN 16#0008# => RETURN "11111100"; 31 | WHEN 16#0009# => RETURN "00001001"; 32 | WHEN 16#000A# => RETURN "01011101"; 33 | WHEN OTHERS => RETURN "--------"; 34 | END CASE; 35 | END program; 36 | 37 | BEGIN 38 | 39 | data <= program(to_integer(addr)); 40 | 41 | END sim_model; -------------------------------------------------------------------------------- /vhdl/uArithmetic.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uArithmetic.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 02.04.2021 11:59:11 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Application specific adder and multiplier should the 20 | -- inferred one be too slow. 21 | -- 22 | -- Version Author Date Changes 23 | -- 2300 ks 8-Mar-2021 Converted to NUMERIC_STD 24 | -- Former uAdd.vhd and uMult.vhd merged. 25 | -- --------------------------------------------------------------------- 26 | LIBRARY IEEE; 27 | USE IEEE.STD_LOGIC_1164.ALL; 28 | USE IEEE.NUMERIC_STD.ALL; 29 | USE work.architecture_pkg.ALL; 30 | USE work.functions_pkg.ALL; 31 | 32 | ENTITY uArithmetic IS PORT ( 33 | -- add 34 | cin : IN STD_LOGIC; 35 | ladd_x : IN UNSIGNED(data_width DOWNTO 0); 36 | ladd_y : IN UNSIGNED(data_width DOWNTO 0); 37 | ladd_out : OUT UNSIGNED(data_width+1 DOWNTO 0); 38 | -- multiply 39 | multiplicand : IN UNSIGNED(data_width DOWNTO 0); 40 | multiplier : IN UNSIGNED(data_width DOWNTO 0); 41 | product : OUT UNSIGNED(data_width*2+1 DOWNTO 0) 42 | ); END uArithmetic; 43 | 44 | ARCHITECTURE inference OF uArithmetic IS 45 | 46 | BEGIN 47 | 48 | sim_arith: IF SIMULATION GENERATE 49 | 50 | ladd_out <= ('0' & ladd_x) + ('0' & ladd_y) + ("" & cin); 51 | 52 | product <= unsigned(signed(multiplicand) * signed(multiplier)); 53 | 54 | END GENERATE sim_arith; syn_arith: IF NOT SIMULATION GENERATE 55 | 56 | ladd_out <= ('0' & ladd_x) + ('0' & ladd_y) + ("" & cin); 57 | 58 | product <= unsigned(signed(multiplicand) * signed(multiplier)); 59 | 60 | END GENERATE syn_arith; 61 | 62 | END inference; 63 | -------------------------------------------------------------------------------- /vhdl/uCore.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uCore.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 12.07.2023 23:58:06 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: The microCore processor kernel. 20 | -- 21 | -- Version Author Date Changes 22 | -- 210 ks 8-Jun-2020 initial version 23 | -- 2300 ks 8-Mar-2021 compiler switch WITH_PROG_RW eliminated 24 | -- Conversion to NUMERIC_STD 25 | -- 2332 ks 13-Apr-2022 enable_proc moved to fpga.vhd 26 | -- 2400 ks 03-Nov-2022 bugfix of deb_denable 27 | -- --------------------------------------------------------------------- 28 | LIBRARY IEEE; 29 | USE IEEE.STD_LOGIC_1164.ALL; 30 | USE IEEE.NUMERIC_STD.ALL; 31 | USE work.functions_pkg.ALL; 32 | USE work.architecture_pkg.ALL; 33 | 34 | ENTITY microcore IS PORT ( 35 | uBus : IN uBus_port; 36 | core : OUT core_signals; 37 | memory : OUT datamem_port; 38 | -- umbilical uart interface 39 | rxd : IN STD_LOGIC; 40 | break : OUT STD_LOGIC; 41 | txd : OUT STD_LOGIC 42 | ); END microcore; 43 | 44 | ARCHITECTURE rtl OF microcore IS 45 | 46 | ATTRIBUTE syn_keep : BOOLEAN; 47 | 48 | ALIAS reset : STD_LOGIC IS uBus.reset; 49 | ALIAS clk : STD_LOGIC IS uBus.clk; 50 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 51 | ALIAS pause : STD_LOGIC IS uBus.pause; 52 | ALIAS mem_rdata : data_bus IS uBus.rdata; 53 | 54 | COMPONENT microcontrol PORT ( 55 | uBus : IN uBus_port; 56 | deb_reset : IN STD_LOGIC; -- reset issued by debugger 57 | deb_pause : IN STD_LOGIC; -- pause issued by debugger 58 | deb_penable : IN STD_LOGIC; -- program memory ready for write by debugger 59 | uCtrl : OUT core_signals; 60 | progmem : OUT progmem_port; 61 | prog_rdata : IN inst_bus; 62 | datamem : OUT datamem_port; 63 | mem_rdata : IN data_bus -- data memory read data 64 | ); END COMPONENT microcontrol; 65 | 66 | SIGNAL uCtrl : core_signals; 67 | SIGNAL progmem : progmem_port; 68 | SIGNAL prog_rdata : inst_bus; 69 | SIGNAL datamem : datamem_port; 70 | 71 | COMPONENT debugger PORT ( 72 | uBus : IN uBus_port; 73 | deb_reset : OUT STD_LOGIC; -- reset generated by debugger 74 | deb_pause : OUT STD_LOGIC; 75 | deb_prequest : OUT STD_LOGIC; -- request program memory write cycle 76 | deb_penable : IN STD_LOGIC; -- execute program memory write 77 | deb_drequest : OUT STD_LOGIC; -- request data memory for a read/write cycle 78 | deb_denable : IN STD_LOGIC; -- execute data memory read/write 79 | umbilical : OUT progmem_port; -- interface to the program memory 80 | debugmem : OUT datamem_port; -- interface to the data memory 81 | debugmem_rdata : IN data_bus; 82 | -- umbilical uart 83 | rxd : IN STD_LOGIC; 84 | break : OUT STD_LOGIC; 85 | txd : OUT STD_LOGIC 86 | ); END COMPONENT debugger; 87 | 88 | SIGNAL umbilical : progmem_port; 89 | SIGNAL debugmem : datamem_port; 90 | SIGNAL deb_pause : STD_LOGIC; 91 | SIGNAL deb_reset : STD_LOGIC; 92 | SIGNAL deb_prequest : STD_LOGIC; 93 | SIGNAL deb_drequest : STD_LOGIC; 94 | SIGNAL deb_penable : STD_LOGIC; 95 | SIGNAL deb_denable : STD_LOGIC; 96 | SIGNAL deb_ext_en : STD_LOGIC; 97 | SIGNAL deb_mem_en : STD_LOGIC; 98 | 99 | SIGNAL warmboot : STD_LOGIC := '0'; ATTRIBUTE syn_keep OF warmboot : SIGNAL IS true; 100 | 101 | -- cold boot loader 102 | COMPONENT boot_rom PORT ( 103 | addr : IN boot_addr_bus; 104 | data : OUT inst_bus 105 | ); END COMPONENT boot_rom; 106 | 107 | SIGNAL boot_addr : boot_addr_bus; 108 | SIGNAL boot_rdata : inst_bus; 109 | 110 | -- program memory 111 | COMPONENT uProgmem PORT ( 112 | clk : IN STD_LOGIC; 113 | penable : IN STD_LOGIC; 114 | pwrite : IN STD_LOGIC; 115 | paddr : IN program_addr; 116 | pwdata : IN inst_bus; 117 | prdata : OUT inst_bus 118 | ); END COMPONENT uProgmem; 119 | 120 | SIGNAL pcache_rdata : inst_bus; 121 | SIGNAL pcache_wdata : inst_bus; 122 | SIGNAL pwrite : STD_LOGIC; 123 | SIGNAL paddr : program_addr; 124 | 125 | BEGIN 126 | 127 | -- make sure reg_addr_width is large enough for all registers 128 | ASSERT (abs(min_registers) <= (2 ** reg_addr_width)) 129 | REPORT "reg_addr_width too small" 130 | SEVERITY error; 131 | 132 | -- --------------------------------------------------------------------- 133 | -- internal program memory 134 | -- --------------------------------------------------------------------- 135 | 136 | paddr <= umbilical.addr WHEN deb_penable = '1' ELSE progmem.addr; 137 | 138 | pwrite <= umbilical.write WHEN deb_penable = '1' ELSE 139 | progmem.write WHEN warmboot = '0' OR SIMULATION ELSE '0'; -- only during boot phase 140 | 141 | pcache_wdata <= umbilical.wdata WHEN deb_penable = '1' ELSE progmem.wdata; 142 | 143 | internal_prog_mem: uProgmem PORT MAP ( 144 | clk => clk, 145 | penable => clk_en, 146 | pwrite => pwrite, 147 | paddr => paddr, 148 | pwdata => pcache_wdata, 149 | prdata => pcache_rdata 150 | ); 151 | 152 | prog_rdata <= pcache_rdata WHEN warmboot = '1' ELSE boot_rdata; 153 | 154 | -- --------------------------------------------------------------------- 155 | -- boot loader, reads from program memory after branch to zero (reboot) 156 | -- --------------------------------------------------------------------- 157 | 158 | cold_boot_proc: PROCESS (reset, clk) 159 | BEGIN 160 | IF reset = '1' AND ASYNC_RESET THEN 161 | IF COLDBOOT THEN warmboot <= '0'; END IF; -- go into boot loading on reset? 162 | boot_addr <= (OTHERS => '0'); 163 | ELSIF rising_edge(clk) THEN 164 | IF clk_en = '1' AND warmboot = '0' THEN 165 | boot_addr <= progmem.addr(boot_addr_width-1 DOWNTO 0); 166 | IF (prog_rdata = op_BRANCH AND progmem.addr = 0 AND progmem.write = '0') OR deb_penable = '1' THEN 167 | warmboot <= '1'; 168 | END IF; 169 | END IF; 170 | IF reset = '1' AND NOT ASYNC_RESET THEN 171 | IF COLDBOOT THEN warmboot <= '0'; END IF; -- go into boot loading on reset? 172 | boot_addr <= (OTHERS => '0'); 173 | END IF; 174 | END IF; 175 | END PROCESS cold_boot_proc; 176 | 177 | boot_loader: boot_rom PORT MAP(boot_addr, boot_rdata); 178 | 179 | -- --------------------------------------------------------------------- 180 | -- instruction execution engine 181 | -- --------------------------------------------------------------------- 182 | 183 | uCntrl: microcontrol PORT MAP ( 184 | uBus => uBus, 185 | deb_reset => deb_reset, -- reset issued by debugger 186 | deb_pause => deb_pause, -- pause issued by debugger 187 | deb_penable => deb_penable, -- program memory ready for write by debugger 188 | uCtrl => uCtrl, 189 | progmem => progmem, 190 | prog_rdata => prog_rdata, 191 | datamem => datamem, 192 | mem_rdata => mem_rdata 193 | ); 194 | 195 | core.reg_en <= uCtrl.reg_en; 196 | core.mem_en <= uCtrl.mem_en OR deb_mem_en; 197 | core.ext_en <= uCtrl.ext_en OR deb_ext_en; 198 | core.tick <= uCtrl.tick; 199 | core.chain <= uCtrl.chain; 200 | core.status <= uCtrl.status; 201 | core.dsp <= uCtrl.dsp; 202 | core.rsp <= uCtrl.rsp; 203 | core.int <= uCtrl.int; 204 | core.time <= uCtrl.time; 205 | core.debug <= debugmem.wdata; 206 | memory <= debugmem WHEN deb_denable = '1' ELSE datamem; 207 | 208 | -- --------------------------------------------------------------------- 209 | -- umbilical uart debug interface 210 | -- --------------------------------------------------------------------- 211 | 212 | deb_penable <= deb_prequest AND (NOT uCtrl.chain OR deb_reset); 213 | 214 | deb_denable_proc : PROCESS(deb_drequest, deb_denable, debugmem, uCtrl) 215 | BEGIN 216 | deb_mem_en <= '0'; 217 | deb_ext_en <= '0'; 218 | deb_denable <= deb_drequest AND NOT (uCtrl.chain OR uCtrl.mem_en OR uCtrl.ext_en OR uCtrl.reg_en); 219 | IF deb_denable = '1' THEN 220 | deb_mem_en <= '1'; 221 | IF WITH_EXTMEM AND debugmem.addr(data_addr_width-1 DOWNTO cache_addr_width) /= 0 THEN 222 | deb_mem_en <= '0'; 223 | deb_ext_en <= '1'; 224 | END IF; 225 | END IF; 226 | END PROCESS deb_denable_proc; 227 | 228 | debug_unit: debugger PORT MAP ( 229 | uBus => uBus, 230 | deb_reset => deb_reset, 231 | deb_pause => deb_pause, 232 | deb_prequest => deb_prequest, 233 | deb_penable => deb_penable, 234 | deb_drequest => deb_drequest, 235 | deb_denable => deb_denable, 236 | umbilical => umbilical, 237 | debugmem => debugmem, 238 | debugmem_rdata => mem_rdata, 239 | -- umbilical 240 | rxd => rxd, 241 | break => break, 242 | txd => txd 243 | ); 244 | 245 | END rtl; -------------------------------------------------------------------------------- /vhdl/uDatacache.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uDatacache_byte.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 02.11.2022 23:17:05 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal data memory. 20 | -- Here fpga specific dual port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- 2300 ks 8-Mar-2021 Conversion to NUMERIC_STD 25 | -- 2400 ks 03-Nov-2022 byte addressing using byte_addr_width > 0 26 | -- --------------------------------------------------------------------- 27 | LIBRARY IEEE; 28 | USE IEEE.STD_LOGIC_1164.ALL; 29 | USE IEEE.NUMERIC_STD.ALL; 30 | USE work.functions_pkg.ALL; 31 | USE work.architecture_pkg.ALL; 32 | 33 | ENTITY uDatacache IS PORT ( 34 | uBus : IN uBus_port; 35 | rdata : OUT data_bus; 36 | dma_mem : IN datamem_port; 37 | dma_rdata : OUT data_bus 38 | ); END uDatacache; 39 | 40 | ARCHITECTURE rtl OF uDatacache IS 41 | 42 | ALIAS clk : STD_LOGIC IS uBus.clk; 43 | ALIAS clk_en : STD_LOGIC IS uBus.clk_en; 44 | ALIAS mem_en : STD_LOGIC IS uBus.mem_en; 45 | ALIAS bytes : byte_type IS uBus.bytes; 46 | ALIAS write : STD_LOGIC IS uBus.write; 47 | ALIAS addr : data_addr IS uBus.addr; 48 | ALIAS wdata : data_bus IS uBus.wdata; 49 | ALIAS dma_enable : STD_LOGIC IS dma_mem.enable; 50 | ALIAS dma_bytes : byte_type IS dma_mem.bytes; 51 | ALIAS dma_write : STD_LOGIC IS dma_mem.write; 52 | ALIAS dma_addr : data_addr IS dma_mem.addr; 53 | ALIAS dma_wdata : data_bus IS dma_mem.wdata; 54 | 55 | SIGNAL enable : STD_LOGIC; 56 | 57 | SIGNAL bytes_en : byte_addr; 58 | SIGNAL mem_wdata : data_bus; 59 | SIGNAL mem_rdata : data_bus; 60 | 61 | SIGNAL dma_bytes_en : byte_addr; 62 | SIGNAL dma_mem_wdata : data_bus; 63 | SIGNAL dma_mem_rdata : data_bus; 64 | 65 | BEGIN 66 | 67 | enable <= clk_en AND mem_en; 68 | 69 | byte_access_proc : PROCESS(uBus, mem_rdata, dma_mem, dma_mem_rdata) 70 | BEGIN 71 | 72 | mem_wdata <= wdata; 73 | rdata <= mem_rdata; 74 | bytes_en <= (OTHERS => '1'); 75 | 76 | dma_mem_wdata <= dma_wdata; 77 | dma_rdata <= dma_mem_rdata; 78 | dma_bytes_en <= (OTHERS => '1'); 79 | 80 | -- 16 bit system 81 | IF byte_addr_width = 1 THEN 82 | IF bytes = 1 THEN -- byte access 83 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 84 | bytes_en <= "01"; 85 | rdata <= resize(mem_rdata(07 DOWNTO 0), data_width); 86 | IF addr(0) = '1' THEN 87 | bytes_en <= "10"; 88 | rdata <= resize(mem_rdata(15 DOWNTO 8), data_width); 89 | END IF; 90 | dma_mem_wdata <= dma_wdata(7 DOWNTO 0) & dma_wdata(7 DOWNTO 0); 91 | dma_bytes_en <= "01"; 92 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 0), data_width); 93 | IF dma_addr(0) = '1' THEN 94 | dma_bytes_en <= "10"; 95 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 8), data_width); 96 | END IF; 97 | END IF; 98 | END IF; 99 | 100 | -- 32 bit system 101 | IF byte_addr_width = 2 THEN 102 | IF bytes = 1 THEN -- byte access 103 | mem_wdata <= wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0) & wdata(7 DOWNTO 0); 104 | CASE addr(1 DOWNTO 0) IS 105 | WHEN "00" => bytes_en <= "0001"; 106 | rdata <= resize(mem_rdata(07 DOWNTO 00), data_width); 107 | WHEN "01" => bytes_en <= "0010"; 108 | rdata <= resize(mem_rdata(15 DOWNTO 08), data_width); 109 | WHEN "10" => bytes_en <= "0100"; 110 | rdata <= resize(mem_rdata(23 DOWNTO 16), data_width); 111 | WHEN "11" => bytes_en <= "1000"; 112 | rdata <= resize(mem_rdata(31 DOWNTO 24), data_width); 113 | WHEN OTHERS => NULL; 114 | END CASE; 115 | dma_mem_wdata <= dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0) & dma_wdata( 7 DOWNTO 0); 116 | CASE dma_addr(1 DOWNTO 0) IS 117 | WHEN "00" => dma_bytes_en <= "0001"; 118 | dma_rdata <= resize(dma_mem_rdata(07 DOWNTO 00), data_width); 119 | WHEN "01" => dma_bytes_en <= "0010"; 120 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 08), data_width); 121 | WHEN "10" => dma_bytes_en <= "0100"; 122 | dma_rdata <= resize(dma_mem_rdata(23 DOWNTO 16), data_width); 123 | WHEN "11" => dma_bytes_en <= "1000"; 124 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 24), data_width); 125 | WHEN OTHERS => NULL; 126 | END CASE; 127 | ELSIF bytes = 2 THEN -- word access 128 | mem_wdata <= wdata(15 DOWNTO 0) & wdata(15 DOWNTO 0); 129 | bytes_en <= "0011"; 130 | rdata <= resize(mem_rdata(15 DOWNTO 0), data_width); 131 | IF addr(1) = '1' THEN 132 | bytes_en <= "1100"; 133 | rdata <= resize(mem_rdata(31 DOWNTO 16), data_width); 134 | END IF; 135 | dma_mem_wdata <= dma_wdata(15 DOWNTO 0) & dma_wdata(15 DOWNTO 0); 136 | dma_bytes_en <= "0011"; 137 | dma_rdata <= resize(dma_mem_rdata(15 DOWNTO 0), data_width); 138 | IF dma_addr(1) = '1' THEN 139 | dma_bytes_en <= "1100"; 140 | dma_rdata <= resize(dma_mem_rdata(31 DOWNTO 16), data_width); 141 | END IF; 142 | END IF; 143 | END IF; 144 | 145 | END PROCESS byte_access_proc; 146 | 147 | make_sim_mem: IF SIMULATION GENERATE 148 | 149 | internal_data_mem: internal_dpbram 150 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check", DMEM_file) 151 | PORT MAP ( 152 | clk => clk, 153 | ena => enable, 154 | wea => write, 155 | bytea => bytes_en, 156 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 157 | dia => mem_wdata, 158 | doa => mem_rdata, 159 | -- dma port 160 | enb => dma_enable, 161 | web => dma_write, 162 | byteb => dma_bytes_en, 163 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 164 | dib => dma_mem_wdata, 165 | dob => dma_mem_rdata 166 | ); 167 | 168 | END GENERATE make_sim_mem; make_syn_mem: IF NOT SIMULATION GENERATE 169 | -- instantiate FPGA specific IP for byte addressed memory here: 170 | 171 | internal_data_mem: internal_dpbram 172 | GENERIC MAP (data_width, cache_size, byte_addr_width, "no_rw_check") 173 | PORT MAP ( 174 | clk => clk, 175 | ena => enable, 176 | wea => write, 177 | bytea => bytes_en, 178 | addra => addr(cache_addr_width-1 DOWNTO byte_addr_width), 179 | dia => mem_wdata, 180 | doa => mem_rdata, 181 | -- dma port 182 | enb => dma_enable, 183 | web => dma_write, 184 | byteb => dma_bytes_en, 185 | addrb => dma_addr(cache_addr_width-1 DOWNTO byte_addr_width), 186 | dib => dma_mem_wdata, 187 | dob => dma_mem_rdata 188 | ); 189 | 190 | END GENERATE make_syn_mem; 191 | 192 | END rtl; 193 | 194 | -- append FPGA specific IP for byte or cell addressed memory here 195 | -------------------------------------------------------------------------------- /vhdl/uProgmem.vhd: -------------------------------------------------------------------------------- 1 | -- --------------------------------------------------------------------- 2 | -- @file : uProgmem.vhd 3 | -- --------------------------------------------------------------------- 4 | -- 5 | -- Last change: KS 10.04.2021 17:24:58 6 | -- @project: microCore 7 | -- @language: VHDL-93 8 | -- @copyright (c): Klaus Schleisiek, All Rights Reserved. 9 | -- @contributors: 10 | -- 11 | -- @license: Do not use this file except in compliance with the License. 12 | -- You may obtain a copy of the Public License at 13 | -- https://github.com/microCore-VHDL/microCore/tree/master/documents 14 | -- Software distributed under the License is distributed on an "AS IS" 15 | -- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing rights and 17 | -- limitations under the License. 18 | -- 19 | -- @brief: Definition of the internal program memory. 20 | -- Here fpga specific single port memory IP can be included. 21 | -- 22 | -- Version Author Date Changes 23 | -- 210 ks 8-Jun-2020 initial version 24 | -- --------------------------------------------------------------------- 25 | LIBRARY IEEE; 26 | USE IEEE.STD_LOGIC_1164.ALL; 27 | USE work.functions_pkg.ALL; 28 | USE work.architecture_pkg.ALL; 29 | 30 | ENTITY uProgmem IS PORT ( 31 | clk : IN STD_LOGIC; 32 | penable : IN STD_LOGIC; 33 | pwrite : IN STD_LOGIC; 34 | paddr : IN program_addr; 35 | pwdata : IN inst_bus; 36 | prdata : OUT inst_bus 37 | ); END uProgmem; 38 | 39 | ARCHITECTURE rtl OF uProgmem IS 40 | 41 | BEGIN 42 | 43 | internal_prog_mem: internal_ram 44 | GENERIC MAP (inst_width, prog_size, "no_rw_check", MEM_file) 45 | PORT MAP ( 46 | clk => clk, 47 | en => penable, 48 | we => pwrite, 49 | addr => paddr, 50 | di => pwdata, 51 | do => prdata 52 | ); 53 | 54 | END rtl; 55 | --------------------------------------------------------------------------------