YOSYS_INCLUDE = $(shell yosys-config --datdir)/include
all: tb
- ./tb
tb: main.cpp ls180.cpp
clang++ -g -O3 -std=c++14 -I $(YOSYS_INCLUDE) $< -o $@
./tb
tb: main.cpp add.cpp
- clang++ -g -O3 -std=c++14 -I $(YOSYS_INCLUDE) $< -o $@
+ clang++ \
+ -DDESIGN=cxxrtl_design::p_add \
+ -DCXX_FILE=\"add.cpp\" \
+ -g -O3 -std=c++14 -I $(YOSYS_INCLUDE) $< -o $@
add.cpp: add.v
$(YOSYS) -p "read_verilog $<; write_cxxrtl $@"
# generate add.il ilang file with: python3 add.py
#
-from nmigen import Elaboratable, Signal, Module, Const
+from nmigen import Elaboratable, Signal, Module, Const, DomainRenamer
from nmigen.cli import verilog
# to get c4m-jtag
# set up JTAG
self.jtag = TAP(ir_width=4)
- self.jtag.bus.tck.name = 'tck'
- self.jtag.bus.tms.name = 'tms'
- self.jtag.bus.tdo.name = 'tdo'
- self.jtag.bus.tdi.name = 'tdi'
+ self.jtag.bus.tck.name = 'jtag_tck'
+ self.jtag.bus.tms.name = 'jtag_tms'
+ self.jtag.bus.tdo.name = 'jtag_tdo'
+ self.jtag.bus.tdi.name = 'jtag_tdi'
# have to create at least one shift register
self.sr = self.jtag.add_shiftreg(ircode=4, length=3)
return m
-def create_ilang(dut, ports, test_name):
+def create_verilog(dut, ports, test_name):
vl = verilog.convert(dut, name=test_name, ports=ports)
with open("%s.v" % test_name, "w") as f:
f.write(vl)
if __name__ == "__main__":
- alu = ADD(width=4)
- create_ilang(alu, [alu.a, alu.b, alu.f,
+ alu = DomainRenamer("sys")(ADD(width=4))
+ create_verilog(alu, [alu.a, alu.b, alu.f,
alu.jtag.bus.tck,
alu.jtag.bus.tms,
alu.jtag.bus.tdo,
#include <iostream>
#include <fstream>
-#include "add.cpp"
+#include CXX_FILE
#define VCD
indicates that receiver wants to know the status of TDO.
"Q" means "quit socket".
*/
-int read_openocd_jtagremote(cxxrtl_design::p_add &top, int sock)
+int read_openocd_jtagremote(DESIGN &top, int sock)
{
char c;
if (read_handler(sock, &c) != 1) {
printf ("read %c\n", c);
if ((c >= '0') && (c <= '7'))
{
- top.p_tck.set<bool>(((c - '0') >> 2) & 1);
- top.p_tms.set<bool>(((c - '0') >> 1) & 1);
- top.p_tdi.set<bool>((c - '0') & 1);
+ top.p_jtag__tck.set<bool>(((c - '0') >> 2) & 1);
+ top.p_jtag__tms.set<bool>(((c - '0') >> 1) & 1);
+ top.p_jtag__tdi.set<bool>((c - '0') & 1);
}
if (c == 'R')
{
- uint8_t val = top.p_tdo.get<uint8_t>() + '0';
+ uint8_t val = top.p_jtag__tdo.get<uint8_t>() + '0';
if(-1 == write(sock, &val, 1))
{
printf("Error writing on socket\n");
int main()
{
- cxxrtl_design::p_add top;
+ DESIGN top;
int steps = 0;
#ifdef VCD
#endif
while (true) {
- top.p_clk.set<bool>(false);
+ top.p_sys__clk.set<bool>(false);
top.step();
#ifdef VCD
vcd.sample(steps*2 + 0);
#endif
- top.p_clk.set<bool>(true);
+ top.p_sys__clk.set<bool>(true);
top.step();
#ifdef VCD
vcd.sample(steps*2 + 1);
/* read and process incoming jtag. sock set to -1 if disconnected */
sock = read_openocd_jtagremote(top, sock);
- // quick check that the output is correct (it's an adder: go figure)
- /*
- top.p_a.set<uint8_t>(5);
- top.p_b.set<uint8_t>(3);
- uint32_t f = top.p_f.get<uint32_t>();
-
- cout << "f " << f << endl;
- */
-
waves << vcd.buffer;
vcd.buffer.clear();
}