Populate instr_mem with a test assembly program
This commit is contained in:
parent
9de9955ad0
commit
eb053503f7
4 changed files with 29 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,5 +3,7 @@
|
|||
*.asc
|
||||
*.bin
|
||||
*.blif
|
||||
*.hex
|
||||
*.o
|
||||
!.git*
|
||||
!.mailmap
|
||||
|
|
|
|||
26
Makefile
26
Makefile
|
|
@ -3,6 +3,7 @@ SRC = $(wildcard *.sv)
|
|||
TOP = top
|
||||
YS = $(TOP).ys
|
||||
BLIF = $(TOP).blif
|
||||
ASC_SYN = $(TOP)_syn.asc
|
||||
ASC = $(TOP).asc
|
||||
BIN = $(TOP).bin
|
||||
SPEED = hx
|
||||
|
|
@ -10,27 +11,42 @@ DEVICE = 8k
|
|||
PACKAGE = ct256
|
||||
PCF = ice40hx8k-b-evn.pcf
|
||||
FREQ_OSC = 12
|
||||
TARGET = riscv64-unknown-elf
|
||||
AS = $(TARGET)-as
|
||||
ASFLAGS = -march=rv32i -mabi=ilp32
|
||||
OBJCOPY = $(TARGET)-objcopy
|
||||
|
||||
.PHONY: all clean time stat flash
|
||||
|
||||
all: $(TOP).bin
|
||||
|
||||
clean:
|
||||
$(RM) $(BLIF) $(ASC) $(BIN)
|
||||
$(RM) $(BLIF) $(ASC_SYN) $(ASC) $(BIN) progmem_syn.hex progmem.hex progmem.o
|
||||
|
||||
$(BLIF): $(YS) $(SRC)
|
||||
progmem.hex: progmem.o
|
||||
$(OBJCOPY) -O srec $< /dev/stdout \
|
||||
| srec_cat - -byte-swap 4 -output - -binary \
|
||||
| xxd -p -c 4 > $@
|
||||
|
||||
progmem_syn.hex:
|
||||
icebram -g 32 256 > $@
|
||||
|
||||
$(BLIF): $(YS) $(SRC) progmem_syn.hex
|
||||
yosys $(QUIET) -s $<
|
||||
|
||||
$(ASC): $(BLIF) $(PCF)
|
||||
$(ASC_SYN): $(BLIF) $(PCF)
|
||||
arachne-pnr $(QUIET) -d $(DEVICE) -P $(PACKAGE) -o $@ -p $(PCF) $<
|
||||
|
||||
$(ASC): $(ASC_SYN) progmem_syn.hex progmem.hex
|
||||
icebram progmem_syn.hex progmem.hex < $< > $@
|
||||
|
||||
$(BIN): $(ASC)
|
||||
icepack $< $@
|
||||
|
||||
time: $(ASC) $(PCF)
|
||||
time: $(ASC_SYN) $(PCF)
|
||||
icetime -t -m -d $(SPEED)$(DEVICE) -P $(PACKAGE) -p $(PCF) -c $(FREQ_OSC) $<
|
||||
|
||||
stat: $(ASC)
|
||||
stat: $(ASC_SYN)
|
||||
icebox_stat $<
|
||||
|
||||
flash: $(BIN)
|
||||
|
|
|
|||
3
progmem.s
Normal file
3
progmem.s
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
start:
|
||||
addi x31, x31, 1
|
||||
j start
|
||||
|
|
@ -19,6 +19,9 @@ module rv32_fetch (
|
|||
|
||||
logic [31:0] pc = branch_taken_in ? branch_pc_in : next_pc;
|
||||
|
||||
initial
|
||||
$readmemh("progmem_syn.hex", instr_mem);
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
instr_out <= instr_mem[pc[31:2]];
|
||||
next_pc <= pc + 4;
|
||||
|
|
|
|||
Loading…
Reference in a new issue