Skip to content

Commit 857149c

Browse files
committed
Merge commit 'a3237779e53281929fc874c114d5b1e4268f1c84'
2 parents 5296f55 + a323777 commit 857149c

File tree

7 files changed

+250
-34
lines changed

7 files changed

+250
-34
lines changed

glip/configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ AS_IF([test "x$enable_cypressfx2" = "xyes"], [
108108

109109

110110
AC_ARG_ENABLE([tcp],
111-
AS_HELP_STRING([--enable-tcp], [enable TCP backend @<:@default=disabled@:>@]),
111+
AS_HELP_STRING([--enable-tcp], [enable TCP backend @<:@default=enabled@:>@]),
112112
[],
113-
[enable_tcp=no])
113+
[enable_tcp=yes])
114114
AM_CONDITIONAL([BACKEND_TCP], [test "x$enable_tcp" = "xyes"])
115115

116116
GLIP_CONFIG_BACKEND(tcp, TCP)

glip/src/backend_uart/logic/demo/nexys4ddr/nexys4ddr.v

+12-9
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,20 @@ module nexys4ddr
5555
output reg redled
5656
);
5757

58+
parameter WIDTH = 8;
59+
5860
localparam FREQ = 100000000;
5961
localparam BAUD = 3000000;
6062

6163
wire rst;
6264
assign rst = ~rstn;
6365

64-
wire [7:0] in_data;
65-
wire in_valid;
66-
reg in_ready;
67-
reg [7:0] out_data;
68-
reg out_valid;
69-
wire out_ready;
66+
wire [WIDTH-1:0] in_data;
67+
wire in_valid;
68+
reg in_ready;
69+
reg [WIDTH-1:0] out_data;
70+
reg out_valid;
71+
wire out_ready;
7072

7173
always @(*) begin
7274
casez(switch[1:0])
@@ -108,7 +110,8 @@ module nexys4ddr
108110

109111
glip_uart_toplevel
110112
#(.FREQ(FREQ),
111-
.BAUD(BAUD))
113+
.BAUD(BAUD),
114+
.WIDTH(WIDTH))
112115
u_uart(.clk_io (clk),
113116
.clk_logic (clk),
114117
.rst (rst),
@@ -128,9 +131,9 @@ module nexys4ddr
128131

129132
wire [8*7-1:0] digits;
130133
wire overflow;
131-
134+
132135
glip_measure_sevensegment
133-
#(.FREQ(FREQ), .DIGITS(8), .OFFSET(0), .STEP(4'd1))
136+
#(.FREQ(FREQ), .DIGITS(8), .OFFSET(0), .STEP(WIDTH/8))
134137
u_measure(.clk (clk),
135138
.rst (logic_rst),
136139
.trigger ((in_valid & in_ready) | (out_valid & out_ready)),

glip/src/backend_uart/logic/demo/nexys4ddr/vivado.tcl

+26
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ set files [list \
103103
"[file normalize "$origin_dir/../../../../common/logic/sevensegment/sevensegment.v"]"\
104104
"[file normalize "$origin_dir/../../../../common/logic/measure/glip_measure_sevensegment.v"]"\
105105
"[file normalize "$origin_dir/../../../../common/logic/measure/glip_measure.v"]"\
106+
"[file normalize "$origin_dir/../../../../common/logic/scaler/verilog/glip_downscale.v"]"\
107+
"[file normalize "$origin_dir/../../../../common/logic/scaler/verilog/glip_upscale.v"]"\
106108
]
107109
add_files -norecurse -fileset $obj $files
108110

@@ -160,6 +162,18 @@ if {[string equal [get_runs -quiet synth_1] ""]} {
160162
}
161163
set obj [get_runs synth_1]
162164
set_property "part" "xc7a100tcsg324-1" $obj
165+
set_property -name {steps.synth_design.args.more options} -value {-generic WIDTH=8} -objects $obj
166+
167+
# Create 'synth_2' run (if not found)
168+
if {[string equal [get_runs -quiet synth_2] ""]} {
169+
create_run -name synth_2 -part xc7a100tcsg324-1 -flow {Vivado Synthesis 2015} -strategy "Vivado Synthesis Defaults" -constrset constrs_1
170+
} else {
171+
set_property strategy "Vivado Synthesis Defaults" [get_runs synth_2]
172+
set_property flow "Vivado Synthesis 2015" [get_runs synth_2]
173+
}
174+
set obj [get_runs synth_2]
175+
set_property "part" "xc7a100tcsg324-1" $obj
176+
set_property -name {steps.synth_design.args.more options} -value {-generic WIDTH=16} -objects $obj
163177

164178
# set the current synth run
165179
current_run -synthesis [get_runs synth_1]
@@ -176,6 +190,18 @@ set_property "part" "xc7a100tcsg324-1" $obj
176190
set_property "steps.write_bitstream.args.readback_file" "0" $obj
177191
set_property "steps.write_bitstream.args.verbose" "0" $obj
178192

193+
# Create 'impl_2' run (if not found)
194+
if {[string equal [get_runs -quiet impl_2] ""]} {
195+
create_run -name impl_2 -part xc7a100tcsg324-1 -flow {Vivado Implementation 2015} -strategy "Vivado Implementation Defaults" -constrset constrs_1 -parent_run synth_2
196+
} else {
197+
set_property strategy "Vivado Implementation Defaults" [get_runs impl_2]
198+
set_property flow "Vivado Implementation 2015" [get_runs impl_2]
199+
}
200+
set obj [get_runs impl_2]
201+
set_property "part" "xc7a100tcsg324-1" $obj
202+
set_property "steps.write_bitstream.args.readback_file" "0" $obj
203+
set_property "steps.write_bitstream.args.verbose" "0" $obj
204+
179205
# set the current impl run
180206
current_run -implementation [get_runs impl_1]
181207

glip/src/backend_uart/logic/verilog/glip_uart_toplevel.v

+64-22
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,43 @@
4141
module glip_uart_toplevel
4242
#(parameter FREQ = 32'hx,
4343
parameter BAUD = 115200,
44+
parameter WIDTH = 8,
4445
parameter XILINX_TARGET_DEVICE = "7SERIES")
4546
(
4647
// Clock & Reset
47-
input clk_io,
48-
input clk_logic,
49-
input rst,
48+
input clk_io,
49+
input clk_logic,
50+
input rst,
5051

5152
// GLIP FIFO Interface
52-
input [7:0] fifo_out_data,
53-
input fifo_out_valid,
54-
output fifo_out_ready,
55-
output [7:0] fifo_in_data,
56-
output fifo_in_valid,
57-
input fifo_in_ready,
53+
input [WIDTH-1:0] fifo_out_data,
54+
input fifo_out_valid,
55+
output fifo_out_ready,
56+
output [WIDTH-1:0] fifo_in_data,
57+
output fifo_in_valid,
58+
input fifo_in_ready,
5859

5960
// GLIP Control Interface
60-
output logic_rst,
61-
output com_rst,
61+
output logic_rst,
62+
output com_rst,
6263

6364
// UART Interface
64-
input uart_rx,
65-
output uart_tx,
66-
input uart_cts,
67-
output uart_rts,
65+
input uart_rx,
66+
output uart_tx,
67+
input uart_cts,
68+
output uart_rts,
6869

6970
// Error signal if failure on the line
70-
output reg error
71+
output reg error
7172
);
7273

74+
wire [7:0] fifo_out_data_scale;
75+
wire fifo_out_valid_scale;
76+
wire fifo_out_ready_scale;
77+
wire [7:0] fifo_in_data_scale;
78+
wire fifo_in_valid_scale;
79+
wire fifo_in_ready_scale;
80+
7381
wire [7:0] ingress_in_data;
7482
wire ingress_in_valid;
7583
wire ingress_in_ready;
@@ -99,9 +107,9 @@ module glip_uart_toplevel
99107
assign ingress_out_ready = ~in_buffer_almost_full;
100108
assign ingress_buffer_valid = ~in_buffer_empty;
101109
assign ingress_buffer_ready = ~in_fifo_full;
102-
assign fifo_in_valid = ~in_fifo_empty;
110+
assign fifo_in_valid_scale = ~in_fifo_empty;
103111
assign egress_in_valid = ~out_fifo_empty;
104-
assign fifo_out_ready = ~out_fifo_full;
112+
assign fifo_out_ready_scale = ~out_fifo_full;
105113

106114
assign uart_rts = 0;
107115

@@ -116,6 +124,40 @@ module glip_uart_toplevel
116124
end
117125
end
118126

127+
generate
128+
if (WIDTH == 8) begin
129+
assign fifo_out_data_scale = fifo_out_data;
130+
assign fifo_out_valid_scale = fifo_out_valid;
131+
assign fifo_out_ready = fifo_out_ready_scale;
132+
assign fifo_in_data = fifo_in_data_scale;
133+
assign fifo_in_valid = fifo_in_valid_scale;
134+
assign fifo_in_ready_scale = fifo_in_ready;
135+
end else if (WIDTH == 16) begin
136+
glip_upscale
137+
#(.IN_SIZE(8))
138+
u_upscale(.clk (clk_io),
139+
.rst (com_rst),
140+
.in_data (fifo_in_data_scale),
141+
.in_valid (fifo_in_valid_scale),
142+
.in_ready (fifo_in_ready_scale),
143+
.out_data (fifo_in_data),
144+
.out_valid (fifo_in_valid),
145+
.out_ready (fifo_in_ready));
146+
147+
glip_downscale
148+
#(.OUT_SIZE(8))
149+
u_downscale(.clk (clk_io),
150+
.rst (com_rst),
151+
.in_data (fifo_out_data),
152+
.in_valid (fifo_out_valid),
153+
.in_ready (fifo_out_ready),
154+
.out_data (fifo_out_data_scale),
155+
.out_valid (fifo_out_valid_scale),
156+
.out_ready (fifo_out_ready_scale));
157+
158+
end
159+
endgenerate
160+
119161
/* glip_uart_control AUTO_TEMPLATE(
120162
.clk (clk_io),
121163
.error (control_error),
@@ -224,7 +266,7 @@ module glip_uart_toplevel
224266
in_fifo
225267
(.ALMOSTEMPTY (),
226268
.ALMOSTFULL (),
227-
.DO (fifo_in_data[7:0]),
269+
.DO (fifo_in_data_scale[7:0]),
228270
.EMPTY (in_fifo_empty),
229271
.FULL (in_fifo_full),
230272
.RDCOUNT (),
@@ -233,7 +275,7 @@ module glip_uart_toplevel
233275
.WRERR (),
234276
.DI (ingress_buffer_data[7:0]),
235277
.RDCLK (clk_logic),
236-
.RDEN (fifo_in_ready),
278+
.RDEN (fifo_in_ready_scale),
237279
.RST (com_rst),
238280
.WRCLK (clk_io),
239281
.WREN (ingress_buffer_valid)
@@ -258,12 +300,12 @@ module glip_uart_toplevel
258300
.RDERR (),
259301
.WRCOUNT (),
260302
.WRERR (),
261-
.DI (fifo_out_data[7:0]),
303+
.DI (fifo_out_data_scale[7:0]),
262304
.RDCLK (clk_io),
263305
.RDEN (egress_in_ready),
264306
.RST (com_rst),
265307
.WRCLK (clk_logic),
266-
.WREN (fifo_out_valid)
308+
.WREN (fifo_out_valid_scale)
267309
);
268310

269311
endmodule // glip_uart_toplevel

glip/src/backend_uart/sw/backend_uart.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int gb_uart_open(struct glip_ctx *ctx, unsigned int num_channels)
394394
do {
395395
uint8_t buffer[128];
396396
rv = read(bctx->fd, buffer, 128);
397-
} while ((rv > 0) || ((rv == -1) && (errno == EAGAIN)));
397+
} while (rv > 0);
398398

399399
/* - De-assert reset */
400400
rv = reset_com(bctx->fd, 0);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Copyright (c) 2015-2016 by the author(s)
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
* THE SOFTWARE.
20+
*
21+
* =============================================================================
22+
*
23+
* Sownscale a FIFO interface
24+
*
25+
* parameter:
26+
* - OUT_SIZE: Output width in bits. The input will have the double width.
27+
*
28+
* Author(s):
29+
* Stefan Wallentowitz <[email protected]>
30+
*/
31+
32+
module glip_downscale
33+
#(parameter OUT_SIZE=16)
34+
(input clk, rst,
35+
36+
input [OUT_SIZE*2-1:0] in_data,
37+
input in_valid,
38+
output in_ready,
39+
40+
output [OUT_SIZE-1:0] out_data,
41+
output out_valid,
42+
input out_ready);
43+
44+
/* 0 when passthrough and 1 when emitting upper part */
45+
reg scale;
46+
/* Store upper part for emitting in second transfer */
47+
reg [OUT_SIZE-1:0] upper;
48+
49+
/* Ready during passthrough */
50+
assign in_ready = !scale & out_ready;
51+
/* Valid during passthrough or second transfer */
52+
assign out_valid = scale ? 1 : in_valid;
53+
/* Passthrough in first and stored upper in second transfer */
54+
assign out_data = !scale ? in_data[OUT_SIZE-1:0] : upper;
55+
56+
always @(posedge clk) begin
57+
if (rst) begin
58+
scale <= 0;
59+
end else if (scale & out_valid & out_ready) begin
60+
scale <= 0;
61+
end else if (!scale & in_valid & in_ready) begin
62+
scale <= 1;
63+
end
64+
end
65+
66+
always @(posedge clk) begin
67+
if (in_valid & in_ready) begin
68+
upper <= in_data[OUT_SIZE*2-1:OUT_SIZE];
69+
end
70+
end
71+
72+
endmodule // glip_downscale
73+

0 commit comments

Comments
 (0)