Skip to content

Various FPGA fixes for yosys synthesis #21

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

Merged
merged 4 commits into from
Jan 25, 2019
Merged
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
44 changes: 40 additions & 4 deletions boards/TinyFPGA_BX/bootloader.v
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ module bootloader (
wire usb_n_tx;
wire usb_p_rx;
wire usb_n_rx;
wire usb_p_rx_io;
wire usb_n_rx_io;
wire usb_tx_en;

tinyfpga_bootloader tinyfpga_bootloader_inst (
Expand All @@ -98,10 +100,44 @@ module bootloader (
);

assign pin_pu = 1'b1;
assign pin_usbp = usb_tx_en ? usb_p_tx : 1'bz;
assign pin_usbn = usb_tx_en ? usb_n_tx : 1'bz;
assign usb_p_rx = usb_tx_en ? 1'b1 : pin_usbp;
assign usb_n_rx = usb_tx_en ? 1'b0 : pin_usbn;
assign usb_p_rx = usb_tx_en ? 1'b1 : usb_p_rx_io;
assign usb_n_rx = usb_tx_en ? 1'b0 : usb_n_rx_io;

SB_IO #(
.PIN_TYPE(6'b101001),
.PULLUP(1'b0),
.NEG_TRIGGER(1'b0),
.IO_STANDARD("SB_LVCMOS")
) io_dp_I (
.PACKAGE_PIN(pin_usbp),
.LATCH_INPUT_VALUE(1'b0),
.CLOCK_ENABLE(1'b1),
.INPUT_CLK(1'b0),
.OUTPUT_CLK(1'b0),
.OUTPUT_ENABLE(usb_tx_en),
.D_OUT_0(usb_p_tx),
.D_OUT_1(1'b0),
.D_IN_0(usb_p_rx_io),
.D_IN_1()
);

SB_IO #(
.PIN_TYPE(6'b101001),
.PULLUP(1'b0),
.NEG_TRIGGER(1'b0),
.IO_STANDARD("SB_LVCMOS")
) io_dn_I (
.PACKAGE_PIN(pin_usbn),
.LATCH_INPUT_VALUE(1'b0),
.CLOCK_ENABLE(1'b1),
.INPUT_CLK(1'b0),
.OUTPUT_CLK(1'b0),
.OUTPUT_ENABLE(usb_tx_en),
.D_OUT_0(usb_n_tx),
.D_OUT_1(1'b0),
.D_IN_0(usb_n_rx_io),
.D_IN_1()
);

assign reset = 1'b0;
endmodule
2 changes: 1 addition & 1 deletion common/serial.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module width_adapter #(

output data_out_put,
input data_out_free,
output [OUTPUT_WIDTH-1:0] data_out,
output [OUTPUT_WIDTH-1:0] data_out
);

generate
Expand Down
6 changes: 2 additions & 4 deletions common/usb_fs_in_arb.v
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module usb_fs_in_arb #(
always @* begin
grant = 0;

arb_in_ep_data <= 0;

for (i = 0; i < NUM_IN_EPS; i = i + 1) begin
in_ep_grant[i] <= 0;

Expand All @@ -29,9 +31,5 @@ module usb_fs_in_arb #(
grant = 1;
end
end

if (!grant) begin
arb_in_ep_data <= 0;
end
end
endmodule
11 changes: 8 additions & 3 deletions common/usb_fs_in_pe.v
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module usb_fs_in_pe #(
// Data payload to send if any
output tx_data_avail,
input tx_data_get,
output reg [7:0] tx_data = 0
output reg [7:0] tx_data
);

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -166,6 +166,8 @@ module usb_fs_in_pe #(
always @* begin
in_ep_acked[ep_num] <= 0;

ep_state_next[ep_num] <= ep_state[ep_num];

if (in_ep_stall[ep_num]) begin
ep_state_next[ep_num] <= STALL;

Expand Down Expand Up @@ -277,9 +279,11 @@ module usb_fs_in_pe #(
reg rollback_in_xfr;

always @* begin
in_xfr_state_next <= in_xfr_state;
in_xfr_start <= 0;
in_xfr_end <= 0;
tx_pkt_start <= 0;
tx_pid <= 4'b0000;
rollback_in_xfr <= 0;

case (in_xfr_state)
Expand Down Expand Up @@ -344,6 +348,9 @@ module usb_fs_in_pe #(
endcase
end

always @(posedge clk)
tx_data <= in_data_buffer[buffer_get_addr];

integer j;
always @(posedge clk) begin
if (reset) begin
Expand All @@ -352,8 +359,6 @@ module usb_fs_in_pe #(
end else begin
in_xfr_state <= in_xfr_state_next;

tx_data <= in_data_buffer[buffer_get_addr];

if (setup_token_received) begin
data_toggle[rx_endp] <= 1;
end
Expand Down
6 changes: 5 additions & 1 deletion common/usb_fs_out_pe.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module usb_fs_out_pe #(
output [NUM_OUT_EPS-1:0] out_ep_data_avail,
output reg [NUM_OUT_EPS-1:0] out_ep_setup = 0,
input [NUM_OUT_EPS-1:0] out_ep_data_get,
output reg [7:0] out_ep_data = 0,
output reg [7:0] out_ep_data,
input [NUM_OUT_EPS-1:0] out_ep_stall,
output reg [NUM_OUT_EPS-1:0] out_ep_acked = 0,

Expand Down Expand Up @@ -154,6 +154,8 @@ module usb_fs_out_pe #(
for (ep_num = 0; ep_num < NUM_OUT_EPS; ep_num = ep_num + 1) begin
always @* begin

ep_state_next[ep_num] <= ep_state[ep_num];

if (out_ep_stall[ep_num]) begin
ep_state_next[ep_num] <= STALL;

Expand Down Expand Up @@ -272,7 +274,9 @@ module usb_fs_out_pe #(
////////////////////////////////////////////////////////////////////////////////

always @* begin
out_ep_acked <= 0;
out_xfr_start <= 0;
out_xfr_state_next <= out_xfr_state;
tx_pkt_start <= 0;
tx_pid <= 0;
new_pkt_end <= 0;
Expand Down