File tree Expand file tree Collapse file tree 5 files changed +56
-13
lines changed
Expand file tree Collapse file tree 5 files changed +56
-13
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ module bootloader (
7979 wire usb_n_tx;
8080 wire usb_p_rx;
8181 wire usb_n_rx;
82+ wire usb_p_rx_io;
83+ wire usb_n_rx_io;
8284 wire usb_tx_en;
8385
8486 tinyfpga_bootloader tinyfpga_bootloader_inst (
@@ -98,10 +100,44 @@ module bootloader (
98100 );
99101
100102 assign pin_pu = 1'b1 ;
101- assign pin_usbp = usb_tx_en ? usb_p_tx : 1'bz ;
102- assign pin_usbn = usb_tx_en ? usb_n_tx : 1'bz ;
103- assign usb_p_rx = usb_tx_en ? 1'b1 : pin_usbp;
104- assign usb_n_rx = usb_tx_en ? 1'b0 : pin_usbn;
103+ assign usb_p_rx = usb_tx_en ? 1'b1 : usb_p_rx_io;
104+ assign usb_n_rx = usb_tx_en ? 1'b0 : usb_n_rx_io;
105+
106+ SB_IO #(
107+ .PIN_TYPE(6'b101001 ),
108+ .PULLUP(1'b0 ),
109+ .NEG_TRIGGER(1'b0 ),
110+ .IO_STANDARD("SB_LVCMOS" )
111+ ) io_dp_I (
112+ .PACKAGE_PIN(pin_usbp),
113+ .LATCH_INPUT_VALUE(1'b0 ),
114+ .CLOCK_ENABLE(1'b1 ),
115+ .INPUT_CLK(1'b0 ),
116+ .OUTPUT_CLK(1'b0 ),
117+ .OUTPUT_ENABLE(usb_tx_en),
118+ .D_OUT_0(usb_p_tx),
119+ .D_OUT_1(1'b0 ),
120+ .D_IN_0(usb_p_rx_io),
121+ .D_IN_1()
122+ );
123+
124+ SB_IO #(
125+ .PIN_TYPE(6'b101001 ),
126+ .PULLUP(1'b0 ),
127+ .NEG_TRIGGER(1'b0 ),
128+ .IO_STANDARD("SB_LVCMOS" )
129+ ) io_dn_I (
130+ .PACKAGE_PIN(pin_usbn),
131+ .LATCH_INPUT_VALUE(1'b0 ),
132+ .CLOCK_ENABLE(1'b1 ),
133+ .INPUT_CLK(1'b0 ),
134+ .OUTPUT_CLK(1'b0 ),
135+ .OUTPUT_ENABLE(usb_tx_en),
136+ .D_OUT_0(usb_n_tx),
137+ .D_OUT_1(1'b0 ),
138+ .D_IN_0(usb_n_rx_io),
139+ .D_IN_1()
140+ );
105141
106142 assign reset = 1'b0 ;
107143endmodule
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module width_adapter #(
1111
1212 output data_out_put,
1313 input data_out_free,
14- output [OUTPUT_WIDTH- 1 :0 ] data_out,
14+ output [OUTPUT_WIDTH- 1 :0 ] data_out
1515);
1616
1717 generate
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ module usb_fs_in_arb #(
2020 always @* begin
2121 grant = 0 ;
2222
23+ arb_in_ep_data <= 0 ;
24+
2325 for (i = 0 ; i < NUM_IN_EPS; i = i + 1 ) begin
2426 in_ep_grant[i] <= 0 ;
2527
@@ -29,9 +31,5 @@ module usb_fs_in_arb #(
2931 grant = 1 ;
3032 end
3133 end
32-
33- if (! grant) begin
34- arb_in_ep_data <= 0 ;
35- end
3634 end
3735endmodule
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ module usb_fs_in_pe #(
5151 // Data payload to send if any
5252 output tx_data_avail,
5353 input tx_data_get,
54- output reg [7 :0 ] tx_data = 0
54+ output reg [7 :0 ] tx_data
5555);
5656
5757 // //////////////////////////////////////////////////////////////////////////////
@@ -166,6 +166,8 @@ module usb_fs_in_pe #(
166166 always @* begin
167167 in_ep_acked[ep_num] <= 0 ;
168168
169+ ep_state_next[ep_num] <= ep_state[ep_num];
170+
169171 if (in_ep_stall[ep_num]) begin
170172 ep_state_next[ep_num] <= STALL;
171173
@@ -277,9 +279,11 @@ module usb_fs_in_pe #(
277279 reg rollback_in_xfr;
278280
279281 always @* begin
282+ in_xfr_state_next <= in_xfr_state;
280283 in_xfr_start <= 0 ;
281284 in_xfr_end <= 0 ;
282285 tx_pkt_start <= 0 ;
286+ tx_pid <= 4'b0000 ;
283287 rollback_in_xfr <= 0 ;
284288
285289 case (in_xfr_state)
@@ -344,6 +348,9 @@ module usb_fs_in_pe #(
344348 endcase
345349 end
346350
351+ always @(posedge clk)
352+ tx_data <= in_data_buffer[buffer_get_addr];
353+
347354 integer j;
348355 always @(posedge clk) begin
349356 if (reset) begin
@@ -352,8 +359,6 @@ module usb_fs_in_pe #(
352359 end else begin
353360 in_xfr_state <= in_xfr_state_next;
354361
355- tx_data <= in_data_buffer[buffer_get_addr];
356-
357362 if (setup_token_received) begin
358363 data_toggle[rx_endp] <= 1 ;
359364 end
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ module usb_fs_out_pe #(
1414 output [NUM_OUT_EPS- 1 :0 ] out_ep_data_avail,
1515 output reg [NUM_OUT_EPS- 1 :0 ] out_ep_setup = 0 ,
1616 input [NUM_OUT_EPS- 1 :0 ] out_ep_data_get,
17- output reg [7 :0 ] out_ep_data = 0 ,
17+ output reg [7 :0 ] out_ep_data,
1818 input [NUM_OUT_EPS- 1 :0 ] out_ep_stall,
1919 output reg [NUM_OUT_EPS- 1 :0 ] out_ep_acked = 0 ,
2020
@@ -154,6 +154,8 @@ module usb_fs_out_pe #(
154154 for (ep_num = 0 ; ep_num < NUM_OUT_EPS; ep_num = ep_num + 1 ) begin
155155 always @* begin
156156
157+ ep_state_next[ep_num] <= ep_state[ep_num];
158+
157159 if (out_ep_stall[ep_num]) begin
158160 ep_state_next[ep_num] <= STALL;
159161
@@ -272,7 +274,9 @@ module usb_fs_out_pe #(
272274 // //////////////////////////////////////////////////////////////////////////////
273275
274276 always @* begin
277+ out_ep_acked <= 0 ;
275278 out_xfr_start <= 0 ;
279+ out_xfr_state_next <= out_xfr_state;
276280 tx_pkt_start <= 0 ;
277281 tx_pid <= 0 ;
278282 new_pkt_end <= 0 ;
You can’t perform that action at this time.
0 commit comments