Skip to content

Picosoc fusesoc #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/picosoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ firmware.elf: sections.lds start.S firmware.c
firmware.bin: firmware.elf
riscv32-unknown-elf-objcopy -O binary firmware.elf /dev/stdout > firmware.bin

firmware.hex: firmware.elf
riscv32-unknown-elf-objcopy -O verilog firmware.elf firmware.hex

clean:
rm -f firmware.elf firmware.hex firmware.bin firmware.o firmware.map \
Expand Down
1 change: 1 addition & 0 deletions examples/picosoc/hardware.v
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ module hardware (
end

picosoc #(
.ENABLE_IRQ_QREGS(1),
.PROGADDR_RESET(32'h0005_0000), // beginning of user space in SPI flash
.PROGADDR_IRQ(32'h0005_0010),
.MEM_WORDS(2048) // use 2KBytes of block RAM by default
Expand Down
56 changes: 56 additions & 0 deletions examples/picosoc/hardware_tb.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module hardware_tb;

vlog_tb_utils vtu();

reg clk = 1'b1;
always #31 clk = !clk; //~16 MHz clock

wire user_led;

wire flash_csb;
wire flash_clk;
wire flash_io0;
wire flash_io1;
wire flash_io2;
wire flash_io3;

initial begin
repeat (2) begin
@(posedge user_led);
$display("LED is on");
@(posedge user_led);
$display("LED is off");
end
$finish;
end

hardware dut
(.clk_16mhz (clk),
// onboard USB interface
.pin_pu (),
.pin_usbp (),
.pin_usbn (),
// hardware UART
.pin_1 (),
.pin_2 (1'b1),
// onboard LED
.user_led (user_led),
// onboard SPI flash interface
.flash_csb (flash_csb),
.flash_clk (flash_clk),
.flash_io0 (flash_io0),
.flash_io1 (flash_io1),
.flash_io2 (flash_io2),
.flash_io3 (flash_io3));

AT25SF081
#(.tVSL (1000)) //Ensure flash is ready when reset is released
spiflash
(.SCLK (flash_clk),
.CS_N (flash_csb),
.SI (flash_io0),
.HOLD_N (flash_io3),
.WP_N (flash_io2),
.SO (flash_io1));

endmodule
33 changes: 33 additions & 0 deletions examples/picosoc/picosoc.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CAPI=2:
name : tinyfpga:bx:picosoc:0

filesets:
rtl:
files:
- hardware.v : {file_type : verilogSource}
depend : [picosoc]
constraints:
files:
- hardware.pcf : {file_type : PCF}
tb:
files:
- hardware_tb.v : {file_type : verilogSource}
depend : [at25sf081, vlog_tb_utils, "yosys:techlibs:ice40"]

targets:
synth:
default_tool : icestorm
filesets: [rtl, constraints]
tools:
icestorm:
arachne_pnr_options : [-d, 8k, -P, cm81]
nextpnr_options : [--lp8k, --package, cm81]
pnr: next
toplevel : hardware
sim:
default_tool: icarus
filesets: [rtl, tb]
tools:
modelsim:
vlog_options: [-timescale=1ns/100ps]
toplevel: hardware_tb
3 changes: 2 additions & 1 deletion examples/picosoc/picosoc.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module picosoc (
input flash_io2_di,
input flash_io3_di
);
parameter [0:0] ENABLE_IRQ_QREGS = 0;
parameter integer MEM_WORDS = 256;
parameter [31:0] STACKADDR = (4*MEM_WORDS); // end of memory
parameter [31:0] PROGADDR_RESET = 32'h 0005_0000; // 1 MB into flash
Expand Down Expand Up @@ -122,7 +123,7 @@ module picosoc (
.ENABLE_MUL(1),
.ENABLE_DIV(1),
.ENABLE_IRQ(1),
.ENABLE_IRQ_QREGS(1)
.ENABLE_IRQ_QREGS(ENABLE_IRQ_QREGS)
) cpu (
.clk (clk ),
.resetn (resetn ),
Expand Down