Skip to content
Snippets Groups Projects
Commit b1bdc0c0 authored by Florian Zaruba's avatar Florian Zaruba
Browse files

Add System Verilog FPU (#163)

* Change reset strategy in ariane_verilog_wrap.sv, remove unneeded sigs in serpent_peripherals.

* saving...

* :arrow_up: Updates for new FPU

* Add sv fpu to FPGA flow

* Use multi-threading capabilities of verilator

- Deactivate non-standard floating point arguments
- Make multi-threading conditional on the availability of verilator 4

* Remove DPI threadsafety

* Reduce FPGA clock frequency

- Remove couple of -v- tests to reduce test-time

* Fix documentation and fpga flow

- Fix cycle time to accommodate FPU
- Fix FPGA constraints

* Change UART frequency
parent 90cebe6e
No related branches found
No related tags found
No related merge requests found
Showing
with 1147 additions and 1062 deletions
...@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ...@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed ### Changed
- Rerouted the JTAG from PMOD to second channel of FTDI 2232 chip on Genesys 2 board - Rerouted the JTAG from PMOD to second channel of FTDI 2232 chip on Genesys 2 board
- Increase available RAM size on Genesys II board to 1 GiB
- Fixed problem which decoded compressed hints as illegal instructions
- Reduce clock frequency of FPGA to 30 MHz to accomodate FPU
- Official support for floating point unit
### 4.0.0 ### 4.0.0
......
This diff is collapsed.
...@@ -15,7 +15,6 @@ Table of Contents ...@@ -15,7 +15,6 @@ Table of Contents
* [Table of Contents](#table-of-contents) * [Table of Contents](#table-of-contents)
* [Getting Started](#getting-started) * [Getting Started](#getting-started)
* [Running User-Space Applications](#running-user-space-applications) * [Running User-Space Applications](#running-user-space-applications)
* [FPU Support](#fpu-support)
* [FPGA Emulation](#fpga-emulation) * [FPGA Emulation](#fpga-emulation)
* [Programming the Memory Configuration File](#programming-the-memory-configuration-file) * [Programming the Memory Configuration File](#programming-the-memory-configuration-file)
* [Preparing the SD Card](#preparing-the-sd-card) * [Preparing the SD Card](#preparing-the-sd-card)
...@@ -102,10 +101,6 @@ $ make sim elf-bin=$RISCV/riscv64-unknown-elf/bin/pk target-options=hello.elf b ...@@ -102,10 +101,6 @@ $ make sim elf-bin=$RISCV/riscv64-unknown-elf/bin/pk target-options=hello.elf b
> Be patient! RTL simulation is way slower than Spike. If you think that you ran into problems you can inspect the trace files. > Be patient! RTL simulation is way slower than Spike. If you think that you ran into problems you can inspect the trace files.
### FPU Support
> There is preliminary support for floating point extensions F and D. At the moment floating point support will only be available in QuestaSim as the FPU is written in VHDL. This is likely to change. The floating point extensions can be enabled by setting `RVF` and `RVD` to `1'b1` in the `include/ariane_pkg.sv` file.
## FPGA Emulation ## FPGA Emulation
We currently only provide support for the [Genesys 2 board](https://reference.digilentinc.com/reference/programmable-logic/genesys-2/reference-manual). We provide pre-build bitstream and memory configuration files for the Genesys 2 [here](https://github.com/pulp-platform/ariane/releases). We currently only provide support for the [Genesys 2 board](https://reference.digilentinc.com/reference/programmable-logic/genesys-2/reference-manual). We provide pre-build bitstream and memory configuration files for the Genesys 2 [here](https://github.com/pulp-platform/ariane/releases).
...@@ -168,7 +163,6 @@ To get started, connect the micro USB port that is labeled with JTAG to your mac ...@@ -168,7 +163,6 @@ To get started, connect the micro USB port that is labeled with JTAG to your mac
Once attached to your system, the FTDI chip should be listed when you type `lsusb` Once attached to your system, the FTDI chip should be listed when you type `lsusb`
```
Bus 005 Device 019: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC Bus 005 Device 019: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC
``` ```
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
reg = <0>; reg = <0>;
status = "okay"; status = "okay";
compatible = "eth, ariane", "riscv"; compatible = "eth, ariane", "riscv";
riscv,isa = "rv64imacsu"; riscv,isa = "rv64imafdc";
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
tlb-split; tlb-split;
// HLIC - hart local interrupt controller // HLIC - hart local interrupt controller
......
...@@ -12,7 +12,7 @@ cd $ROOT ...@@ -12,7 +12,7 @@ cd $ROOT
if [[ -z "$-" ]]; then if [[ -z "$-" ]]; then
GREEN='' GREEN=''
RED='' RED=''
NC='' NC=''
else else
GREEN='\033[0;32m' GREEN='\033[0;32m'
RED='\033[0;31m' RED='\033[0;31m'
...@@ -28,7 +28,7 @@ fi ...@@ -28,7 +28,7 @@ fi
# get NUM_TOTAL number of tests # get NUM_TOTAL number of tests
NUM_TOTAL=$2 NUM_TOTAL=$2
echo "list containint tests: $2" echo "list containing tests: $2"
echo "checking files:" echo "checking files:"
ls "${1}"*.log ls "${1}"*.log
...@@ -45,7 +45,7 @@ echo "NUM_FAILED: $NUM_FAILED" ...@@ -45,7 +45,7 @@ echo "NUM_FAILED: $NUM_FAILED"
echo "NUM_FATAL: $NUM_FATAL" echo "NUM_FATAL: $NUM_FATAL"
echo "NUM_ERROR: $NUM_ERROR" echo "NUM_ERROR: $NUM_ERROR"
if [[ $(($NUM_FAILED)) -gt 0 ]]; then if [[ $(($NUM_FAILED)) -gt 0 ]]; then
echo -e "${RED}FAILED $NUM_FAILED of $NUM_TOTAL tests ${NC}" echo -e "${RED}FAILED $NUM_FAILED of $NUM_TOTAL tests ${NC}"
exit 1; exit 1;
elif [[ $(($NUM_FATAL)) -ne 0 ]]; then elif [[ $(($NUM_FATAL)) -ne 0 ]]; then
...@@ -60,4 +60,4 @@ elif [[ $(($NUM_PASSED)) -ne $(($NUM_TOTAL)) ]]; then ...@@ -60,4 +60,4 @@ elif [[ $(($NUM_PASSED)) -ne $(($NUM_TOTAL)) ]]; then
else else
echo -e "${GREEN}PASSED all $NUM_TOTAL tests ${NC}" echo -e "${GREEN}PASSED all $NUM_TOTAL tests ${NC}"
exit 0; exit 0;
fi fi
torture.generator.nseqs 1000
torture.generator.memsize 1024
torture.generator.fprnd 0
torture.generator.amo false
torture.generator.mul true
torture.generator.divider true
torture.generator.segment true
torture.generator.loop true
torture.generator.loop_size 64
torture.generator.mix.xmem 15
torture.generator.mix.xbranch 25
torture.generator.mix.xalu 15
torture.generator.mix.fgen 20
torture.generator.mix.fpmem 10
torture.generator.mix.fax 10
torture.generator.mix.fdiv 5
torture.generator.mix.vec 0
torture.generator.vec.vf 1
torture.generator.vec.seq 20
torture.generator.vec.memsize 128
torture.generator.vec.numsregs 64
torture.generator.vec.mul false
torture.generator.vec.div false
torture.generator.vec.mix true
torture.generator.vec.fpu false
torture.generator.vec.fma false
torture.generator.vec.fcvt false
torture.generator.vec.fdiv false
torture.generator.vec.amo false
torture.generator.vec.seg false
torture.generator.vec.stride false
torture.generator.vec.pred_alu true
torture.generator.vec.pred_mem true
torture.generator.vec.mix.valu 20
torture.generator.vec.mix.vpop 60
torture.generator.vec.mix.vmem 20
torture.generator.vec.mix.vonly 0
torture.testrun.maxcycles 10000000
torture.testrun.virtual false
torture.testrun.seek true
torture.testrun.dump false
torture.testrun.vec false
torture.overnight.errors 1
torture.overnight.minutes 1
torture.overnight.outdir output/failedtests
torture.overnight.email your@email.address
...@@ -9,14 +9,15 @@ fi ...@@ -9,14 +9,15 @@ fi
if [ ! -e "$VERILATOR_ROOT/bin/verilator" ]; then if [ ! -e "$VERILATOR_ROOT/bin/verilator" ]; then
echo "Installing Verilator" echo "Installing Verilator"
wget https://www.veripool.org/ftp/verilator-3.924.tgz rm verilator*.t*gz
tar xzf verilator*.t*gz wget https://www.veripool.org/ftp/verilator-4.008.tgz
rm verilator*.t*gz tar xzf verilator*.t*gz
rm verilator*.t*gz
cd verilator-* cd verilator-*
mkdir -p $VERILATOR_ROOT mkdir -p $VERILATOR_ROOT
# copy scripts # copy scripts
autoconf && ./configure --prefix="$VERILATOR_ROOT" && make -j${NUM_JOBS} autoconf && ./configure --prefix="$VERILATOR_ROOT" && make -j${NUM_JOBS}
cp -r * $VERILATOR_ROOT/ cp -r * $VERILATOR_ROOT/
make test make test
else else
echo "Using Verilator from cached directory." echo "Using Verilator from cached directory."
......
...@@ -5,12 +5,12 @@ export CI_BUILD_DIR=$TOP/ariane-repo ...@@ -5,12 +5,12 @@ export CI_BUILD_DIR=$TOP/ariane-repo
#customize this to your setup #customize this to your setup
export QUESTASIM_HOME= export QUESTASIM_HOME=
export QUESTASIM_VERSION= export QUESTASIM_VERSION=
export QUESTASIM_FLAGS=-noautoldlibpath export QUESTASIM_FLAGS=
export CXX=g++-7 CC=gcc-7 export CXX=g++-7 CC=gcc-7
# where to install the tools # where to install the tools
export RISCV=$TOP/riscv_install export RISCV=$TOP/riscv_install
export VERILATOR_ROOT=$TOP/verilator-3.924/ export VERILATOR_ROOT=$TOP/verilator-4.008/
export PATH=$RISCV/bin:$VERILATOR_ROOT/bin:$PATH export PATH=$RISCV/bin:$VERILATOR_ROOT/bin:$PATH
export LIBRARY_PATH=$RISCV/lib export LIBRARY_PATH=$RISCV/lib
...@@ -19,4 +19,4 @@ export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include ...@@ -19,4 +19,4 @@ export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include
export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include
# number of parallel jobs to use for make commands and simulation # number of parallel jobs to use for make commands and simulation
export NUM_JOBS=8 export NUM_JOBS=8
\ No newline at end of file
...@@ -78,26 +78,6 @@ rv64ui-v-or ...@@ -78,26 +78,6 @@ rv64ui-v-or
rv64ui-v-ori rv64ui-v-ori
rv64ui-v-sub rv64ui-v-sub
rv64ui-v-subw rv64ui-v-subw
rv64ui-v-xor
rv64ui-v-xori
rv64ui-v-sll rv64ui-v-sll
rv64ui-v-slli rv64ui-v-slli
rv64ui-v-slliw
rv64ui-v-slt
rv64ui-v-slti
rv64ui-v-sltiu
rv64ui-v-sltu
rv64ui-v-sra
rv64ui-v-srai
rv64ui-v-sraiw
rv64ui-v-sraw
rv64ui-v-srl
rv64ui-v-srli
rv64ui-v-srliw
rv64ui-v-srlw
rv64ui-v-lb rv64ui-v-lb
rv64ui-v-lbu
rv64ui-v-ld
rv64ui-v-lh
rv64ui-v-lhu
rv64ui-v-lui
rv64uf-p-fadd
rv64uf-p-fclass
rv64uf-p-fcmp
rv64uf-p-fcvt
rv64uf-p-fcvt_w
rv64uf-p-fdiv
rv64uf-p-fmadd
rv64uf-p-fmin
rv64uf-p-ldst
rv64uf-p-move
rv64uf-p-recoding
rv64uf-v-fadd
rv64uf-v-fclass
rv64uf-v-fcmp
rv64uf-v-fcvt
rv64uf-v-fcvt_w
rv64uf-v-fdiv
rv64uf-v-fmadd
rv64uf-v-fmin
rv64uf-v-ldst
rv64uf-v-move
rv64uf-v-recoding
rv64ud-p-fadd
rv64ud-p-fclass
rv64ud-p-fcmp
rv64ud-p-fcvt
rv64ud-p-fcvt_w
rv64ud-p-fdiv
rv64ud-p-fmadd
rv64ud-p-fmin
rv64ud-v-fadd
rv64ud-v-fclass
rv64ud-v-fcmp
rv64ud-v-fcvt
rv64ud-v-fcvt_w
rv64ud-v-fdiv
rv64ud-v-fmadd
rv64ud-v-fmin
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
create_clock -period 100.000 -name tck -waveform {0.000 50.000} [get_ports tck] create_clock -period 100.000 -name tck -waveform {0.000 50.000} [get_ports tck]
set_input_jitter tck 1.000 set_input_jitter tck 1.000
set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_src/data_src_q_reg*/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_dst/data_dst_q_reg*/D] 10.000 set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_src/data_src_q_reg*/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_dst/data_dst_q_reg*/D] 20.000
set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_src/req_src_q_reg/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_dst/req_dst_q_reg/D] 10.000 set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_src/req_src_q_reg/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_resp/i_dst/req_dst_q_reg/D] 20.000
set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_req/i_dst/ack_dst_q_reg/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_req/i_src/ack_src_q_reg/D] 10.000 set_max_delay -datapath_only -from [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_req/i_dst/ack_dst_q_reg/C] -to [get_pins i_dmi_jtag/i_dmi_cdc/i_cdc_req/i_src/ack_src_q_reg/D] 20.000
# set multicycle path on reset, on the FPGA we do not care about the reset anyway
set_multicycle_path -from [get_pins i_rstgen_main/i_rstgen_bypass/synch_regs_q_reg[3]/C] 4
set_multicycle_path -from [get_pins i_rstgen_main/i_rstgen_bypass/synch_regs_q_reg[3]/C] 3 -hold
## Buttons ## Buttons
set_property -dict {PACKAGE_PIN R19 IOSTANDARD LVCMOS33} [get_ports cpu_resetn] set_property -dict {PACKAGE_PIN R19 IOSTANDARD LVCMOS33} [get_ports cpu_resetn]
## PMOD Header JC
# set_property -dict {PACKAGE_PIN AC26 IOSTANDARD LVCMOS33} [get_ports tck]
# set_property -dict {PACKAGE_PIN AJ27 IOSTANDARD LVCMOS33} [get_ports tdi]
# set_property -dict {PACKAGE_PIN AH30 IOSTANDARD LVCMOS33} [get_ports tdo]
# set_property -dict {PACKAGE_PIN AK29 IOSTANDARD LVCMOS33} [get_ports tms]
# set_property -dict {PACKAGE_PIN AD26 IOSTANDARD LVCMOS33} [get_ports trst_n]
# accept sub-optimal placement
# set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets tck_IBUF]
## To use FTDI FT2232 JTAG ## To use FTDI FT2232 JTAG
set_property -dict { PACKAGE_PIN Y29 IOSTANDARD LVCMOS33 } [get_ports { trst_n }]; set_property -dict { PACKAGE_PIN Y29 IOSTANDARD LVCMOS33 } [get_ports { trst_n }];
set_property -dict { PACKAGE_PIN AD27 IOSTANDARD LVCMOS33 } [get_ports { tck }]; set_property -dict { PACKAGE_PIN AD27 IOSTANDARD LVCMOS33 } [get_ports { tck }];
set_property -dict { PACKAGE_PIN W27 IOSTANDARD LVCMOS33 } [get_ports { tdi }]; set_property -dict { PACKAGE_PIN W27 IOSTANDARD LVCMOS33 } [get_ports { tdi }];
set_property -dict { PACKAGE_PIN W28 IOSTANDARD LVCMOS33 } [get_ports { tdo }]; set_property -dict { PACKAGE_PIN W28 IOSTANDARD LVCMOS33 } [get_ports { tdo }];
set_property -dict { PACKAGE_PIN W29 IOSTANDARD LVCMOS33 } [get_ports { tms }]; set_property -dict { PACKAGE_PIN W29 IOSTANDARD LVCMOS33 } [get_ports { tms }];
## UART ## UART
set_property -dict {PACKAGE_PIN Y23 IOSTANDARD LVCMOS33} [get_ports tx] set_property -dict {PACKAGE_PIN Y23 IOSTANDARD LVCMOS33} [get_ports tx]
...@@ -72,7 +62,8 @@ set_property -dict {PACKAGE_PIN AG12 IOSTANDARD LVCMOS15} [get_ports { eth_mdio ...@@ -72,7 +62,8 @@ set_property -dict {PACKAGE_PIN AG12 IOSTANDARD LVCMOS15} [get_ports { eth_mdio
############################################# #############################################
# Modified for 125MHz receive clock # Modified for 125MHz receive clock
create_clock -period 8.000 -name eth_rxck [get_ports eth_rxck] create_clock -period 8.000 -name eth_rxck [get_ports eth_rxck]
set_clock_groups -asynchronous -group [get_clocks eth_rxclk -include_generated_clocks] set_clock_groups -asynchronous -group [get_clocks eth_rxck -include_generated_clocks]
set_clock_groups -asynchronous -group [get_clocks clk_out2_xlnx_clk_gen]
## SD Card ## SD Card
set_property -dict {PACKAGE_PIN R28 IOSTANDARD LVCMOS33} [get_ports spi_clk_o] set_property -dict {PACKAGE_PIN R28 IOSTANDARD LVCMOS33} [get_ports spi_clk_o]
...@@ -85,13 +76,12 @@ set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design] ...@@ -85,13 +76,12 @@ set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
## JTAG ## JTAG
# minimize routing delay # minimize routing delay
set_max_delay -to [get_ports { td } ] 5
set_max_delay -from [get_ports { tms } ] 5
set_max_delay -from [get_ports { trst_n } ] 5
# reset signal set_max_delay -to [get_ports { tdo } ] 20
set_false_path -from [get_ports { trst_n } ] set_max_delay -from [get_ports { tms } ] 20
set_max_delay -from [get_ports { tdi } ] 20
set_max_delay -from [get_ports { trst_n } ] 20
# constrain clock domain crossing # reset signal
set_false_path -from [get_clocks tck] -to [get_clocks clk_out1] set_false_path -from [get_ports { trst_n } ]
set_max_delay -from [get_clocks tck] -to [get_clocks clk_out1] 5 set_false_path -from [get_pins i_ddr/u_xlnx_mig_7_ddr3_mig/u_ddr3_infrastructure/rstdiv0_sync_r1_reg_rep/C]
...@@ -22,4 +22,6 @@ set_property board_part $::env(XILINX_BOARD) [current_project] ...@@ -22,4 +22,6 @@ set_property board_part $::env(XILINX_BOARD) [current_project]
# set number of threads to 8 (maximum, unfortunately) # set number of threads to 8 (maximum, unfortunately)
set_param general.maxThreads 8 set_param general.maxThreads 8
set_msg_config -id {[Synth 8-5858]} -new_severity "info" set_msg_config -id {[Synth 8-5858]} -new_severity "info"
set_msg_config -id {[Synth 8-4480]} -limit 1000
\ No newline at end of file
...@@ -29,13 +29,14 @@ source scripts/add_sources.tcl ...@@ -29,13 +29,14 @@ source scripts/add_sources.tcl
set_property top ${project}_xilinx [current_fileset] set_property top ${project}_xilinx [current_fileset]
if {$::env(BOARD) eq "genesys2"} { if {$::env(BOARD) eq "genesys2"} {
read_verilog -sv {src/genesysii.svh} read_verilog -sv {src/genesysii.svh ../src/common_cells/include/common_cells/registers.svh}
set file "src/genesysii.svh" set file "src/genesysii.svh"
set registers "../src/common_cells/include/common_cells/registers.svh"
} else { } else {
exit 1 exit 1
} }
set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file"]] set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file" "*$registers"]]
set_property -dict { file_type {Verilog Header} is_global_include 1} -objects $file_obj set_property -dict { file_type {Verilog Header} is_global_include 1} -objects $file_obj
update_compile_order -fileset sources_1 update_compile_order -fileset sources_1
...@@ -46,6 +47,8 @@ add_files -fileset constrs_1 -norecurse constraints/$project.xdc ...@@ -46,6 +47,8 @@ add_files -fileset constrs_1 -norecurse constraints/$project.xdc
# synth_design -retiming -rtl -name rtl_1 -verilog_define SYNTHESIS -verilog_define # synth_design -retiming -rtl -name rtl_1 -verilog_define SYNTHESIS -verilog_define
synth_design -rtl -name rtl_1 synth_design -rtl -name rtl_1
set_property STEPS.SYNTH_DESIGN.ARGS.RETIMING true [get_runs synth_1]
launch_runs synth_1 launch_runs synth_1
wait_on_run synth_1 wait_on_run synth_1
open_run synth_1 open_run synth_1
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#size-cells = <0>; #size-cells = <0>;
timebase-frequency = <25000000>; // 25 MHz timebase-frequency = <25000000>; // 25 MHz
CPU0: cpu@0 { CPU0: cpu@0 {
clock-frequency = <50000000>; // 50 MHz clock-frequency = <30000000>; // 30 MHz
device_type = "cpu"; device_type = "cpu";
reg = <0>; reg = <0>;
status = "okay"; status = "okay";
compatible = "eth, ariane", "riscv"; compatible = "eth, ariane", "riscv";
riscv,isa = "rv64imacsu"; riscv,isa = "rv64imafdc";
mmu-type = "riscv,sv39"; mmu-type = "riscv,sv39";
tlb-split; tlb-split;
// HLIC - hart local interrupt controller // HLIC - hart local interrupt controller
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
uart@10000000 { uart@10000000 {
compatible = "ns16750"; compatible = "ns16750";
reg = <0x0 0x10000000 0x0 0x1000>; reg = <0x0 0x10000000 0x0 0x1000>;
clock-frequency = <50000000>; clock-frequency = <30000000>;
current-speed = <115200>; current-speed = <115200>;
interrupt-parent = <&PLIC0>; interrupt-parent = <&PLIC0>;
interrupts = <1>; interrupts = <1>;
......
This diff is collapsed.
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int main() int main()
{ {
init_uart(); init_uart(30000000, 115200);
print_uart("Hello World!\r\n"); print_uart("Hello World!\r\n");
int res = gpt_find_boot_partition((uint8_t *)0x80000000UL, 2 * 16384); int res = gpt_find_boot_partition((uint8_t *)0x80000000UL, 2 * 16384);
......
...@@ -23,12 +23,14 @@ void write_serial(char a) ...@@ -23,12 +23,14 @@ void write_serial(char a)
write_reg_u8(UART_THR, a); write_reg_u8(UART_THR, a);
} }
void init_uart() void init_uart(uint32_t freq, uint32_t baud)
{ {
uint32_t divisor = freq / (baud << 4);
write_reg_u8(UART_INTERRUPT_ENABLE, 0x00); // Disable all interrupts write_reg_u8(UART_INTERRUPT_ENABLE, 0x00); // Disable all interrupts
write_reg_u8(UART_LINE_CONTROL, 0x80); // Enable DLAB (set baud rate divisor) write_reg_u8(UART_LINE_CONTROL, 0x80); // Enable DLAB (set baud rate divisor)
write_reg_u8(UART_DLAB_LSB, 0x1B); // Set divisor to 27 (lo byte) 115200 baud write_reg_u8(UART_DLAB_LSB, divisor); // divisor (lo byte)
write_reg_u8(UART_DLAB_MSB, 0x00); // (hi byte) write_reg_u8(UART_DLAB_MSB, (divisor >> 8) & 0xFF); // divisor (hi byte)
write_reg_u8(UART_LINE_CONTROL, 0x03); // 8 bits, no parity, one stop bit write_reg_u8(UART_LINE_CONTROL, 0x03); // 8 bits, no parity, one stop bit
write_reg_u8(UART_FIFO_CONTROL, 0xC7); // Enable FIFO, clear them, with 14-byte threshold write_reg_u8(UART_FIFO_CONTROL, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
write_reg_u8(UART_MODEM_CONTROL, 0x20); // Autoflow mode write_reg_u8(UART_MODEM_CONTROL, 0x20); // Autoflow mode
......
...@@ -13,7 +13,7 @@ set_property -dict [list CONFIG.PRIM_IN_FREQ {200.000} \ ...@@ -13,7 +13,7 @@ set_property -dict [list CONFIG.PRIM_IN_FREQ {200.000} \
CONFIG.CLKOUT2_USED {true} \ CONFIG.CLKOUT2_USED {true} \
CONFIG.CLKOUT3_USED {true} \ CONFIG.CLKOUT3_USED {true} \
CONFIG.CLKOUT4_USED {true} \ CONFIG.CLKOUT4_USED {true} \
CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {50} \ CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {30} \
CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {125} \ CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {125} \
CONFIG.CLKOUT3_REQUESTED_OUT_FREQ {125} \ CONFIG.CLKOUT3_REQUESTED_OUT_FREQ {125} \
CONFIG.CLKOUT3_REQUESTED_PHASE {90.000} \ CONFIG.CLKOUT3_REQUESTED_PHASE {90.000} \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment