-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholed_command_buffer.sv
49 lines (40 loc) · 1.35 KB
/
oled_command_buffer.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
`timescale 1ns / 1ns
// Discards commands if the buffer is full (violates handshake)
module oled_command_buffer #(
parameter BUFFER_MAX = 1024, // maximum number of serial commands that can be buffered
parameter COMMAND_W = 8 // bit width of serial commands
)
(
input wire rst_n,
input wire clk,
input wire write_en,
input wire [COMMAND_W-1:0] write_command,
input wire read_en,
output wire [COMMAND_W-1:0] read_command,
output wire commands_empty,
output wire commands_full
);
logic full;
logic empty;
logic read_en_b;
logic write_en_b;
assign commands_empty = empty;
assign commands_full = full;
assign write_en_b = write_en && !full;
assign read_en_b = read_en && !empty;
fifo #(COMMAND_W, BUFFER_MAX) fifo_I
(
.rst_n(rst_n),
.clk(clk),
.write_en(write_en_b),
.data_in(write_command),
.read_en(read_en_b),
.data_out(read_command),
.full(full),
.empty(empty),
/* verilator lint_off PINCONNECTEMPTY */
.almost_full(),
.almost_empty()
/* verilator lint_on PINCONNECTEMPTY */
);
endmodule : oled_command_buffer