-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'verilator' into masterMerge
- Loading branch information
Showing
10 changed files
with
397 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
ROOT_DIR:=../../.. | ||
|
||
defmacro:=-D | ||
incdir:=-I | ||
|
||
SIM_SERVER=$(VSIM_SERVER) | ||
SIM_USER=$(VSIM_USER) | ||
SIM_PROC=Vsystem | ||
|
||
|
||
include ../simulation.mk | ||
|
||
# remove space between -I and directory for verilator | ||
INCLUDE_VERI=$(subst -I ,-I,$(INCLUDE)) | ||
|
||
VSRC_VERI=$(subst system_tb.v,,$(VSRC)) | ||
|
||
#simulator flags | ||
VLOG = verilator +1800-2005ext+v --error-limit 1000 -cc $(INCLUDE_VERI) $(DEFINE) | ||
#VLOG = verilator +1800-2005ext+v --error-limit 1000 -Wall -cc $(INCLUDE2) $(DEFINE) | ||
|
||
# Add system wrapper to the sources list to be verilated | ||
VSRC+=sim_system_top.v | ||
|
||
#run the simulator | ||
run: $(VSRC) $(VHDR) firmware boot.hex | ||
$(VLOG) $(VSRC_VERI) --trace --top-module sim_system_top -Wno-WIDTH -Wno-PINMISSING -Wno-fatal --exe sim_xtop.cpp | ||
make -C obj_dir -j -f Vsim_system_top.mk Vsim_system_top | ||
cp obj_dir/Vsim_system_top Vsim_system_top | ||
./Vsim_system_top | ||
|
||
|
||
clean: hw-clean | ||
mv sim_system_top.v sim_system_top.ver | ||
@rm -f *.v *.cpp *.hex Vsim_system_top | ||
|
||
sim-clean: hw-clean | ||
@rm -f *.cpp Vsystem | ||
@rm -rf obj_dir | ||
mv sim_system_top.ver sim_system_top.v | ||
|
||
#@rm -f *.v *.cpp *.hex Vsystem !("sim_system_top.v") | ||
|
||
|
||
.PHONY: run clean | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
`timescale 1ns / 1ps | ||
`include "system.vh" | ||
//`include "cpu_nat_s_if.v" | ||
|
||
/* | ||
This is a wrapper module for verilator simulation | ||
that will communicate with the console and get things | ||
done | ||
Therefore it will be a module with inout unlike system_tb.v | ||
*/ | ||
|
||
module sim_system_top( | ||
//cpu and uart related stuff | ||
input clk, | ||
input reset, | ||
output trap, | ||
|
||
// Interface from cpu i.e. parallel data | ||
input valid, | ||
input [`UART_ADDR_W-1:0] addr, | ||
input [`DATA_W-1:0] wdata, | ||
input [3:0] wstrb, | ||
output [`DATA_W-1:0] rdata, | ||
output ready | ||
); | ||
|
||
// Wires that will connect both units | ||
wire iob_txd; | ||
wire iob_rxd; | ||
wire iob_rts; // pin with rts on iob_soc | ||
wire iob_cts; // pin with cts on iob_soc | ||
|
||
|
||
|
||
system system ( | ||
.clk (clk), | ||
.reset (reset), | ||
.trap (trap), | ||
//UART | ||
.uart_txd (iob_txd), | ||
.uart_rxd (iob_rxd), | ||
.uart_rts (iob_rts), | ||
.uart_cts (iob_cts) | ||
); | ||
|
||
|
||
iob_uart #( | ||
.ADDR_W(`UART_ADDR_W), | ||
.DATA_W(`DATA_W), | ||
.WDATA_W(`DATA_W) | ||
) testbench_uart | ||
( | ||
.clk (clk), | ||
.rst (reset), | ||
.valid (valid), | ||
.address (addr), | ||
.wdata (wdata), | ||
.wstrb (wstrb), | ||
.rdata (rdata), | ||
.ready (ready), | ||
.txd (iob_rxd), | ||
.rxd (iob_txd), | ||
.rts (iob_cts), | ||
.cts (iob_rts) | ||
); | ||
|
||
initial begin | ||
|
||
// configure uart | ||
cpu_inituart(); | ||
|
||
|
||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
|
||
mode = 0o600 | ||
|
||
class FifoFile: | ||
def __init__(self, path): | ||
self.path = path | ||
if not os.path.exists(path): | ||
os.mkfifo(path, mode) | ||
print('FIFO named ' + str(path) + 'is created successfully.') | ||
|
||
def read(self, number_of_bytes = 1): | ||
i = 0 | ||
data = b'' | ||
# print(number_of_bytes) | ||
with open(self.path) as fifo: | ||
print("FIFO opened") | ||
while(i<number_of_bytes): | ||
data += bytes(fifo.read(1), 'ascii') | ||
if len(data) == b'': | ||
print("Writer closed") | ||
break | ||
print('Read: "{0}"'.format(data)) | ||
i += 1 | ||
return data | ||
|
||
def read_until(self, end = b'\x00'): | ||
i = 0 | ||
data = b'' | ||
# print(number_of_bytes) | ||
with open(self.path) as fifo: | ||
print("FIFO opened") | ||
while(True): | ||
data += bytes(fifo.read(1), 'ascii') | ||
if len(data) == b'': | ||
print("Writer closed") | ||
break | ||
print('Read: "{0}"'.format(data)) | ||
if (data == b'\x00'): | ||
break | ||
return data | ||
|
||
def write(self, data): | ||
with open(self.path, 'wb') as fifo: | ||
fifo.write(data) | ||
|
||
def close(self): | ||
os.remove(self.path) | ||
print('Removed file: "{0}"'.format(self.path)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.