-
Notifications
You must be signed in to change notification settings - Fork 1
/
spi_regmap_top.sv
70 lines (61 loc) · 2.38 KB
/
spi_regmap_top.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module spi_regmap_top
( input logic clk, // 12MHz clock
input logic reset, // button
input logic sclk, // SPI CLK
input logic ss_n, // SPI CS_N
input logic mosi, // SPI MOSI
output logic miso, // SPI MISO
output logic [18:0] sram_addr, // ext sram address
inout logic [7:0] sram_data, // ext sram data (bidir)
output logic sram_oen, // ext sram output enable (active low)
output logic sram_wen, // ext sram write enable (active low)
output logic sram_cen // ext sram chip enable (active low)
);
logic [7:0] rdata;
logic [7:0] rdata_regmap;
logic [7:0] wdata;
logic [23:0] address;
logic rd_en_regmap;
logic wr_en_regmap;
logic rd_en_sram;
logic wr_en_sram;
logic rst_n;
logic reset_spi;
assign rst_n = ~reset;
assign reset_spi = reset || ss_n; // clear the SPI when the chip_select is inactive
assign rdata = (rd_en_sram) ? sram_data : rdata_regmap;
assign sram_data = (sram_oen) ? wdata : 'z;
spi_slave_lbus u_spi_slave_lbus
( .sclk, // input
.mosi, // input
.miso, // output
.reset_spi, // input
.rdata, // input [7:0]
.rd_en_regmap, // output
.wr_en_regmap, // output
.rd_en_sram, // output
.wr_en_sram, // output
.wdata, // output [7:0]
.address // output [23:0]
);
lbus_regmap u_lbus_regmap
( .clk, // input
.rst_n, // input
.rd_en_sclk (rd_en_regmap), // input
.wr_en_sclk (wr_en_regmap), // input
.address_sclk (address), // input [23:0]
.wdata_sclk (wdata), // input [7:0]
.rdata (rdata_regmap) // output [7:0]
);
lbus_ext_sram u_lbus_ext_sram
( .clk, // input
.rst_n, // input
.rd_en_sclk (rd_en_sram), // input
.wr_en_sclk (wr_en_sram), // input
.address_sclk (address), // input [23:0]
.sram_addr, // output [18:0]
.sram_oen, // output
.sram_wen, // output
.sram_cen // output
);
endmodule