loom
27 строк · 502.0 Байт
1module rk(
2input logic clk,
3input logic rst,
4input logic cs,
5input logic inc,
6input logic [7:0] d_in,
7output logic data_valid,
8output logic [7:0] d_out
9);
10always_ff @(posedge clk, posedge rst)
11begin
12if (rst)
13begin
14data_valid <= 1;
15d_out <= 'b00000000;
16end
17else if (clk)
18begin
19data_valid <= cs;
20if (!cs)
21if (inc)
22d_out <= d_in + 1;
23else
24d_out <= d_in - 1;
25end
26end
27endmodule
28