ci: Add attosoc smoketest for ice40
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
98d2fc6b10
commit
51155ec6a7
@ -8,4 +8,5 @@ task:
|
||||
build_script: mkdir build && cd build && cmake .. -DARCH=all -DTRELLIS_ROOT=/usr/local/src/prjtrellis -DBUILD_TESTS=on && make -j $(nproc)
|
||||
test_generic_script: cd build && ./nextpnr-generic-test
|
||||
test_ice40_script: cd build && ./nextpnr-ice40-test
|
||||
test_ecp5_script: cd build && ./nextpnr-ecp5-test
|
||||
smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh
|
||||
test_ecp5_script: cd build && ./nextpnr-ecp5-test
|
@ -6,11 +6,21 @@ RUN set -e -x ;\
|
||||
apt-get -y update ;\
|
||||
apt-get -y upgrade ;\
|
||||
apt-get -y install \
|
||||
build-essential cmake clang python3-dev libboost-all-dev qt5-default git
|
||||
build-essential autoconf cmake clang bison wget flex gperf \
|
||||
libreadline-dev gawk tcl-dev libffi-dev graphviz xdot python3-dev \
|
||||
libboost-all-dev qt5-default git libftdi-dev pkg-config
|
||||
|
||||
RUN set -e -x ;\
|
||||
apt-get -y install \
|
||||
libftdi-dev pkg-config
|
||||
mkdir -p /usr/local/src ;\
|
||||
cd /usr/local/src ;\
|
||||
git clone --recursive https://github.com/steveicarus/iverilog.git ;\
|
||||
cd iverilog ;\
|
||||
git reset --hard 172d7eb0a3665f89b91d601b5912c33acedc81e5 ;\
|
||||
sh autoconf.sh ;\
|
||||
./configure ;\
|
||||
make -j $(nproc) ;\
|
||||
make install ;\
|
||||
rm -rf /usr/local/src/iverilog
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir -p /usr/local/src ;\
|
||||
@ -21,6 +31,16 @@ RUN set -e -x ;\
|
||||
make -j $(nproc) ;\
|
||||
make install
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir -p /usr/local/src ;\
|
||||
cd /usr/local/src ;\
|
||||
git clone --recursive https://github.com/YosysHQ/yosys.git ;\
|
||||
cd yosys ;\
|
||||
git reset --hard 47a5dfdaa4bd7d400c6e3d58476de80904df460d ;\
|
||||
make -j $(nproc) ;\
|
||||
make install ;\
|
||||
rm -rf /usr/local/src/yosys
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir -p /usr/local/src ;\
|
||||
cd /usr/local/src ;\
|
||||
@ -31,3 +51,5 @@ RUN set -e -x ;\
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr . ;\
|
||||
make -j $(nproc) ;\
|
||||
make install
|
||||
|
||||
|
||||
|
6
ice40/smoketest/attosoc/.gitignore
vendored
Normal file
6
ice40/smoketest/attosoc/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
attosoc_pnr.v
|
||||
attosoc.asc
|
||||
attosoc.json
|
||||
attosoc_pnr_tb
|
||||
testbench.vcd
|
||||
output.txt
|
10
ice40/smoketest/attosoc/attosoc.pcf
Normal file
10
ice40/smoketest/attosoc/attosoc.pcf
Normal file
@ -0,0 +1,10 @@
|
||||
set_io clk E4
|
||||
set_io led[0] B2
|
||||
set_io led[1] F5
|
||||
set_io led[2] B1
|
||||
set_io led[3] C1
|
||||
set_io led[4] C2
|
||||
set_io led[5] F4
|
||||
set_io led[6] D2
|
||||
set_io led[7] G5
|
||||
|
127
ice40/smoketest/attosoc/attosoc.v
Normal file
127
ice40/smoketest/attosoc/attosoc.v
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* ECP5 PicoRV32 demo
|
||||
*
|
||||
* Copyright (C) 2017 Clifford Wolf <clifford@clifford.at>
|
||||
* Copyright (C) 2018 David Shah <dave@ds0.me>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
`ifdef PICORV32_V
|
||||
`error "attosoc.v must be read before picorv32.v!"
|
||||
`endif
|
||||
|
||||
`define PICORV32_REGS picosoc_regs
|
||||
|
||||
module attosoc (
|
||||
input clk,
|
||||
output reg [7:0] led
|
||||
);
|
||||
|
||||
reg [5:0] reset_cnt = 0;
|
||||
wire resetn = &reset_cnt;
|
||||
|
||||
always @(posedge clk) begin
|
||||
reset_cnt <= reset_cnt + !resetn;
|
||||
end
|
||||
|
||||
parameter integer MEM_WORDS = 256;
|
||||
parameter [31:0] STACKADDR = (4*MEM_WORDS); // end of memory
|
||||
parameter [31:0] PROGADDR_RESET = 32'h 0000_0000; // ROM at 0x0
|
||||
parameter integer ROM_BYTES = 256;
|
||||
|
||||
reg [7:0] rom [0:ROM_BYTES-1];
|
||||
wire [31:0] rom_rdata = {rom[mem_addr+3], rom[mem_addr+2], rom[mem_addr+1], rom[mem_addr+0]};
|
||||
initial $readmemh("firmware.hex", rom);
|
||||
|
||||
wire mem_valid;
|
||||
wire mem_instr;
|
||||
wire mem_ready;
|
||||
wire [31:0] mem_addr;
|
||||
wire [31:0] mem_wdata;
|
||||
wire [3:0] mem_wstrb;
|
||||
wire [31:0] mem_rdata;
|
||||
|
||||
wire rom_ready = mem_valid && mem_addr[31:24] == 8'h00;
|
||||
|
||||
wire iomem_valid;
|
||||
wire iomem_ready;
|
||||
wire [31:0] iomem_addr;
|
||||
wire [31:0] iomem_wdata;
|
||||
wire [3:0] iomem_wstrb;
|
||||
wire [31:0] iomem_rdata;
|
||||
|
||||
assign iomem_valid = mem_valid && (mem_addr[31:24] > 8'h 01);
|
||||
assign iomem_ready = 1'b1;
|
||||
assign iomem_wstrb = mem_wstrb;
|
||||
assign iomem_addr = mem_addr;
|
||||
assign iomem_wdata = mem_wdata;
|
||||
|
||||
wire [31:0] spimemio_cfgreg_do;
|
||||
|
||||
|
||||
always @(posedge clk)
|
||||
if (iomem_valid && iomem_wstrb[0])
|
||||
led <= iomem_wdata[7:0];
|
||||
|
||||
assign mem_ready = (iomem_valid && iomem_ready) || rom_ready;
|
||||
|
||||
assign mem_rdata = rom_rdata;
|
||||
|
||||
picorv32 #(
|
||||
.STACKADDR(STACKADDR),
|
||||
.PROGADDR_RESET(PROGADDR_RESET),
|
||||
.PROGADDR_IRQ(32'h 0000_0000),
|
||||
.BARREL_SHIFTER(0),
|
||||
.COMPRESSED_ISA(0),
|
||||
.ENABLE_MUL(0),
|
||||
.ENABLE_DIV(0),
|
||||
.ENABLE_IRQ(0),
|
||||
.ENABLE_IRQ_QREGS(0)
|
||||
) cpu (
|
||||
.clk (clk ),
|
||||
.resetn (resetn ),
|
||||
.mem_valid (mem_valid ),
|
||||
.mem_instr (mem_instr ),
|
||||
.mem_ready (mem_ready ),
|
||||
.mem_addr (mem_addr ),
|
||||
.mem_wdata (mem_wdata ),
|
||||
.mem_wstrb (mem_wstrb ),
|
||||
.mem_rdata (mem_rdata )
|
||||
);
|
||||
|
||||
|
||||
|
||||
endmodule
|
||||
|
||||
// Implementation note:
|
||||
// Replace the following two modules with wrappers for your SRAM cells.
|
||||
|
||||
module picosoc_regs (
|
||||
input clk, wen,
|
||||
input [5:0] waddr,
|
||||
input [5:0] raddr1,
|
||||
input [5:0] raddr2,
|
||||
input [31:0] wdata,
|
||||
output [31:0] rdata1,
|
||||
output [31:0] rdata2
|
||||
);
|
||||
reg [31:0] regs [0:31];
|
||||
|
||||
always @(posedge clk)
|
||||
if (wen) regs[waddr[4:0]] <= wdata;
|
||||
|
||||
assign rdata1 = regs[raddr1[4:0]];
|
||||
assign rdata2 = regs[raddr2[4:0]];
|
||||
endmodule
|
32
ice40/smoketest/attosoc/attosoc_tb.v
Normal file
32
ice40/smoketest/attosoc/attosoc_tb.v
Normal file
@ -0,0 +1,32 @@
|
||||
module testbench();
|
||||
integer out;
|
||||
reg clk;
|
||||
|
||||
always #5 clk = (clk === 1'b0);
|
||||
|
||||
initial begin
|
||||
out = $fopen("output.txt","w");
|
||||
$dumpfile("testbench.vcd");
|
||||
$dumpvars(0, testbench);
|
||||
|
||||
repeat (100) begin
|
||||
repeat (256) @(posedge clk);
|
||||
$display("+256 cycles");
|
||||
end
|
||||
$fclose(out);
|
||||
#100;
|
||||
$finish;
|
||||
end
|
||||
|
||||
wire [7:0] led;
|
||||
|
||||
always @(led) begin
|
||||
#1 $display("%b", led);
|
||||
$fwrite(out, "%b\n", led);
|
||||
end
|
||||
|
||||
attosoc uut (
|
||||
.clk (clk ),
|
||||
.led (led )
|
||||
);
|
||||
endmodule
|
6
ice40/smoketest/attosoc/firmware.hex
Normal file
6
ice40/smoketest/attosoc/firmware.hex
Normal file
@ -0,0 +1,6 @@
|
||||
@00000000
|
||||
13 04 10 00 B7 04 00 02 93 09 00 10 13 04 14 00
|
||||
63 44 34 01 13 04 20 00 13 09 20 00 63 5E 89 00
|
||||
13 05 04 00 93 05 09 00 EF 00 80 01 63 08 05 00
|
||||
13 09 19 00 6F F0 9F FE 23 A0 84 00 6F F0 1F FD
|
||||
93 02 10 00 33 05 B5 40 E3 5E 55 FE 67 80 00 00
|
16
ice40/smoketest/attosoc/golden.txt
Normal file
16
ice40/smoketest/attosoc/golden.txt
Normal file
@ -0,0 +1,16 @@
|
||||
00000000
|
||||
00000010
|
||||
00000011
|
||||
00000101
|
||||
00000111
|
||||
00001011
|
||||
00001101
|
||||
00010001
|
||||
00010011
|
||||
00010111
|
||||
00011101
|
||||
00011111
|
||||
00100101
|
||||
00101001
|
||||
00101011
|
||||
00101111
|
2979
ice40/smoketest/attosoc/picorv32.v
Normal file
2979
ice40/smoketest/attosoc/picorv32.v
Normal file
File diff suppressed because it is too large
Load Diff
9
ice40/smoketest/attosoc/smoketest.sh
Executable file
9
ice40/smoketest/attosoc/smoketest.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
yosys -q -p 'synth_ice40 -json attosoc.json -top attosoc' attosoc.v picorv32.v
|
||||
$NEXTPNR --hx8k --json attosoc.json --pcf attosoc.pcf --asc attosoc.asc --freq 50
|
||||
icetime -tmd hx8k -c 50 attosoc.asc
|
||||
icebox_vlog -L -l -p attosoc.pcf -c -n attosoc attosoc.asc > attosoc_pnr.v
|
||||
iverilog -o attosoc_pnr_tb attosoc_pnr.v attosoc_tb.v `yosys-config --datdir/ice40/cells_sim.v`
|
||||
vvp attosoc_pnr_tb
|
||||
diff output.txt golden.txt
|
Loading…
Reference in New Issue
Block a user