Skip to content

Commit 15bf66e

Browse files
committed
Add SW folder to compile the program
1 parent fe96843 commit 15bf66e

File tree

8 files changed

+378
-4
lines changed

8 files changed

+378
-4
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ tools/datagen/src/imgs/*_sobel_*
234234
test
235235
*.zst
236236
.vscode
237+
*.hex
238+
*.bin
239+
modules/VirtualPrototype/sw/dump
240+
modules/VirtualPrototype/sw/sw
241+
modules/VirtualPrototype/Log.txt
237242
VirtualPrototype/Log.txt
238243
VirtualPrototype/log.txt
239244
VirtualPrototype/sw/dump

modules/VirtualPrototype/include/img_receiver_tlm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct img_receiver_tlm: public img_receiver, public img_target
1010
{
11-
SC_CTOR(img_receiver_tlm): img_receiver(img_receiver::name()), img_target(img_target::name()) {
11+
img_receiver_tlm(sc_module_name name) : img_receiver((std::string(name) + "_receiver").c_str()), img_target((std::string(name) + "_target").c_str()) {
1212
set_mem_attributes(IMG_INPUT_ADDRESS_LO, IMG_INPUT_SIZE);
1313
}
1414

modules/VirtualPrototype/include/img_transmiter_tlm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct img_transmiter_tlm: public img_transmiter, public img_target
1010
{
11-
SC_CTOR(img_transmiter_tlm): img_transmiter(img_transmiter::name()), img_target(img_target::name()) {
11+
img_transmiter_tlm(sc_module_name name) : img_transmiter((std::string(name) + "_transmiter").c_str()), img_target((std::string(name) + "_target").c_str()) {
1212
set_mem_attributes(IMG_OUTPUT_ADDRESS_LO, IMG_OUTPUT_SIZE);
1313
}
1414

modules/VirtualPrototype/include/ips_filter_tlm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using namespace std;
1919
struct ips_filter_tlm : public Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>, public img_target
2020
{
2121

22-
SC_CTOR(ips_filter_tlm): Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>(Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>::name()), img_target(img_target::name()) {
22+
ips_filter_tlm(sc_module_name name) : Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
2323
}
2424

2525
//Override do_when_transaction functions

modules/VirtualPrototype/include/sobel_edge_detector_tlm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using namespace std;
1212
struct sobel_edge_detector_tlm : public Edge_Detector, public img_target
1313
{
1414

15-
SC_CTOR(sobel_edge_detector_tlm): Edge_Detector(Edge_Detector::name()), img_target(img_target::name()) {
15+
sobel_edge_detector_tlm(sc_module_name name) : Edge_Detector((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
1616
sobel_input = new sc_uint<8>[9];
1717
set_mem_attributes(SOBEL_INPUT_0_ADDRESS_LO, SOBEL_INPUT_0_SIZE+SOBEL_INPUT_1_SIZE);
1818
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
TARGET = sw
2+
3+
TARGET_ARCH = riscv32
4+
5+
CC = riscv32-unknown-elf-g++
6+
7+
# compiling flags here
8+
CFLAGS = -Wall -I. -O0 -static -march=rv32gc -mabi=ilp32 --specs=nosys.specs
9+
10+
LINKER = riscv32-unknown-elf-g++
11+
# linking flags here
12+
LDFLAGS = -I. -static
13+
LIBS = $(EXTRA_LIBS)
14+
15+
16+
# change these to proper directories where each file should be
17+
SRCDIR = ./
18+
OBJDIR = .
19+
BINDIR = ./
20+
INCDIR = -I. -I../../edge-detector/include
21+
LIBDIR = -L.
22+
23+
24+
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
25+
INCLUDES := $(wildcard $(INCDIR)/*.h)
26+
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
27+
28+
rm = rm -f
29+
30+
31+
$(BINDIR)/$(TARGET): $(OBJECTS)
32+
$(LINKER) $(CFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) $(OBJECTS) -o $@
33+
riscv32-unknown-elf-objdump -d $@ > dump
34+
riscv32-unknown-elf-objcopy -Oihex $@ $(TARGET).hex
35+
@echo "Linking complete!"
36+
37+
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
38+
@echo "Compiling "$<" ..."
39+
$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
40+
@echo "Done!"
41+
42+
.PHONY: clean
43+
clean:
44+
@$(rm) $(OBJECTS) *.hex dump
45+
@echo "Cleanup complete!"
46+
47+
.PHONY: remove
48+
remove: clean
49+
@$(rm) $(BINDIR)/$(TARGET)
50+
@echo "Executable removed!"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <string.h>
2+
#include <stdio.h>
3+
4+
5+
#define TRACE (*(unsigned char *)0x40000000)
6+
extern "C" {
7+
8+
int _read(int file, char* ptr, int len) {
9+
return 0;
10+
}
11+
12+
int _open(int fd) {
13+
return 0;
14+
}
15+
16+
int _close(int fd){
17+
return 0;
18+
}
19+
20+
int _fstat_r(int fd) {
21+
return 0;
22+
}
23+
24+
int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){
25+
return 0;
26+
}
27+
28+
int _isatty_r(struct _reent *ptr, int fd) {
29+
return 0;
30+
}
31+
32+
33+
int _write(int file, const char *ptr, int len) {
34+
int x;
35+
36+
for (x = 0; x < len; x++) {
37+
TRACE = *ptr++;
38+
}
39+
40+
return (len);
41+
}
42+
43+
int _getpid(void) {
44+
return 0;
45+
}
46+
47+
void _kill(int pid) {
48+
return;
49+
}
50+
51+
void print(char *msg) {
52+
int i = 0;
53+
while (msg[i] != '\0') {
54+
TRACE = msg[i];
55+
i++;
56+
}
57+
}
58+
59+
}

0 commit comments

Comments
 (0)