diff --git a/scripts/icestorm/Makefile b/scripts/icestorm/Makefile index a6a4b4f..bd20a41 100644 --- a/scripts/icestorm/Makefile +++ b/scripts/icestorm/Makefile @@ -28,16 +28,47 @@ example_tb.exe: example_tb.v example.v firmware.hex iverilog -o example_tb.exe -s testbench example.v example_tb.v ../../picorv32.v chmod -x example_tb.exe -sim: example_tb.exe - vvp -N example_tb.exe # +vcd +example_sim: example_tb.exe + vvp -N example_tb.exe + +example_sim_vcd: example_tb.exe + vvp -N example_tb.exe +vcd + +synth_tb.exe: example_tb.v synth.blif + iverilog -o synth_tb.exe -s testbench synth.v example_tb.v /usr/local/share/yosys/ice40/cells_sim.v + chmod -x synth_tb.exe + +synth_sim: synth_tb.exe + vvp -N synth_tb.exe + +synth_sim_vcd: synth_tb.exe + vvp -N synth_tb.exe +vcd + +route.v: example.txt + icebox_vlog -L -n top -sp example.pcf example.txt > route.v + +route_tb.exe: example_tb.v route.v + iverilog -o route_tb.exe -s testbench route.v example_tb.v /usr/local/share/yosys/ice40/cells_sim.v + chmod -x route_tb.exe + +route_sim: route_tb.exe + vvp -N route_tb.exe + +route_sim_vcd: route_tb.exe + vvp -N route_tb.exe +vcd prog_sram: iceprog -S example.bin +view: + gtkwave example.vcd example.gtkw + clean: rm -f firmware.elf firmware.map firmware.bin firmware.hex - rm -f synth.log synth.v synth.blif example.txt example.bin - rm -f example_tb.exe example.vcd + rm -f synth.log synth.v synth.blif route.v example.txt example.bin + rm -f example_tb.exe synth_tb.exe route_tb.exe example.vcd -.PHONY: all sim prog_sram clean +.PHONY: all prog_sram view clean +.PHONY: example_sim synth_sim route_sim +.PHONY: example_sim_vcd synth_sim_vcd route_sim_vcd diff --git a/scripts/icestorm/example_tb.v b/scripts/icestorm/example_tb.v index 7fda120..db14aa9 100644 --- a/scripts/icestorm/example_tb.v +++ b/scripts/icestorm/example_tb.v @@ -24,7 +24,7 @@ module testbench; end $monitor(LED7, LED6, LED5, LED4, LED3, LED2, LED1, LED0); - repeat (10000000) @(posedge clk_pin); + repeat (10000) @(posedge clk_pin); $finish; end endmodule diff --git a/scripts/icestorm/firmware.c b/scripts/icestorm/firmware.c index b400ba0..df893cc 100644 --- a/scripts/icestorm/firmware.c +++ b/scripts/icestorm/firmware.c @@ -1,5 +1,6 @@ #include +// use SHIFT_COUNTER_BITS=4 for simulation #define SHIFT_COUNTER_BITS 16 void output(uint8_t c)