Skip to content
Snippets Groups Projects
Commit c15cf716 authored by Pavel Pisa's avatar Pavel Pisa
Browse files

seminaries/qtmips/fibo-hazard: provided template for your Fibonacci series implementation.


The directory contain
  seminaries/qtmips/fibo-hazards/fibo-hazards-template.S
files. The whole directory or only above files should be copied
in the directory work/fibo-nazards of your repository.
The template files  should be renamed to fibo-hazards.S.

Signed-off-by: default avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
parent 4ab820aa
No related branches found
No related tags found
No related merge requests found
*.o
depend
fibo-hazards
fibo_limit.in
fibo_series.out
ARCH=mips-elf
#ARCH=mips-linux-gnu
SOURCES = fibo-hazards.S
TARGET_EXE = fibo-hazards
CC=$(ARCH)-gcc
CXX=$(ARCH)-g++
AS=$(ARCH)-as
LD=$(ARCH)-ld
OBJCOPY=$(ARCH)-objcopy
ARCHFLAGS += -march=mips32
#ARCHFLAGS += -fno-lto
#ARCHFLAGS += -mno-shared
CFLAGS += -ggdb -Os -Wall
CXXFLAGS+= -ggdb -Os -Wall
AFLAGS += -ggdb
LDFLAGS += -ggdb
LDFLAGS += -nostartfiles
LDFLAGS += -static
#LDFLAGS += -specs=/opt/musl/mips-linux-gnu/lib/musl-gcc.specs
CFLAGS += $(ARCHFLAGS)
CXXFLAGS+= $(ARCHFLAGS)
AFLAGS += $(ARCHFLAGS)
LDFLAGS += $(ARCHFLAGS)
OBJECTS += $(filter %.o,$(SOURCES:%.S=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.c=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.cpp=%.o))
all : default
.PHONY : default clean dep all run_test
%.o:%.S
$(CC) -D__ASSEMBLY__ $(AFLAGS) -c $< -o $@
%.o:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o:%.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
%.s:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
#default : $(TARGET_EXE)
default : run_test
$(TARGET_EXE) : $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@
dep: depend
depend: $(SOURCES) $(glob *.h)
echo '# autogenerated dependencies' > depend
ifneq ($(filter %.S,$(SOURCES)),)
$(CC) -D__ASSEMBLY__ $(AFLAGS) -w -E -M $(filter %.S,$(SOURCES)) \
>> depend
endif
ifneq ($(filter %.c,$(SOURCES)),)
$(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M $(filter %.c,$(SOURCES)) \
>> depend
endif
ifneq ($(filter %.cpp,$(SOURCES)),)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -w -E -M $(filter %.cpp,$(SOURCES)) \
>> depend
endif
clean:
rm -f *.o *.a $(OBJECTS) $(TARGET_EXE) depend fibo_series.out fibo_limit.in
#mips-elf-objdump --source -M no-aliases,reg-names=numeric qtmips_binrep
FIBO_SERIES_REF_FILE=fibo_series.ref
fibo_limit:=$(words $(filter-out 0x00000000,$(shell cat $(FIBO_SERIES_REF_FILE))))
FIBO_SERIES_BYTES:=$(words $(shell seq 1 8) $(shell seq 1 $(fibo_limit)) $(shell seq 1 $(fibo_limit)) $(shell seq 1 $(fibo_limit)) $(shell seq 1 $(fibo_limit)))
run_test: $(TARGET_EXE)
echo $(fibo_limit) >fibo_limit.in
qtmips_cli --dump-cycles $< \
--load-range fibo_limit,fibo_limit.in \
--dump-range fibo_series,$(FIBO_SERIES_BYTES),fibo_series.out
diff -u -B -b fibo_series.out $(FIBO_SERIES_REF_FILE)
-include depend
// fibo-hazards.S file template, rename and implement the algorithm
// Test algorithm in qtmips_gui program
// Select the CPU core configuration to
// Pipelined without hazard unit and cache
// This option select version where RAW dependencies which leads
// to hazards are not resolved in hardware, you need to schedule
// instruction execution according to the pipeline structure
// (classical 5-stage MIPS) such way, that no dependency results
// in a hazard
// copy directory with the project to your repository to
// the directory work/fibo-hazards
// critical is location of the file work/fibo-hazards/fibo-hazards.S
// which is checked by the scripts
// The script loads number of the last Fibonacci series element to compute
// into fibo_limit variable and expects computed series in memory starting
// at address fibo_series, the series has to be followed by at least
// one zero element
// When tested by actual qtmips_cli version, the variant without hazard
// unit cannot be selected (this is WIP for the test script), use qtmips_gui
// which is fully configurable
// Directives to make interesting windows visible
#pragma qtmips show registers
#pragma qtmips show memory
.set noreorder
.set noat
.globl fibo_limit
.globl fibo_series
.text
.globl _start
.ent _start
_start:
la $a0, fibo_series
la $a1, fibo_limit
lw $a1, 0($a1) // number of elements in the array
//Insert your code there
//Final infinite loop
end_loop:
cache 9, 0($0) // flush cache memory
break // stop the simulator
j end_loop
nop
.end _start
.data
// .align 2 // not supported by QtMips yet
fibo_limit:
.word 15
fibo_series:
.skip 1000*4
// Specify location to show in memory window
#pragma qtmips focus memory fibo_limit
0x00000000
0x00000001
0x00000001
0x00000002
0x00000003
0x00000005
0x00000008
0x0000000d
0x00000015
0x00000022
0x00000037
0x00000059
0x00000000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment