1
+ -- This Source Code Form is subject to the terms of the Mozilla Public
2
+ -- License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ -- file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ --
5
+ -- Copyright 2024 Oxide Computer Company
6
+
7
+ -- Common register block for basic board information
8
+
9
+ library ieee;
10
+ use ieee.std_logic_1164.all ;
11
+ use ieee.numeric_std.all ;
12
+ use ieee.numeric_std_unsigned.all ;
13
+
14
+ use work.info_regs_pkg.all ;
15
+ use work.git_sha_pkg.all ;
16
+
17
+ entity info_2k8 is
18
+ generic (
19
+ hubris_compat_num_bits: positive range 1 to 31
20
+ );
21
+ port (
22
+ clk : in std_logic ;
23
+ reset : in std_logic ;
24
+ -- System Interface
25
+ hubris_compat_pins: in std_logic_vector (hubris_compat_num_bits- 1 downto 0 );
26
+ -- axi interface. This is not using VHDL2019 views so that it's compatible with
27
+ -- GHDL/yosys based toolchains
28
+ -- write address channel
29
+ awvalid : in std_logic ;
30
+ awready : out std_logic ;
31
+ awaddr : in std_logic_vector (7 downto 0 ) ;
32
+ -- write data channel
33
+ wvalid : in std_logic ;
34
+ wready : out std_logic ;
35
+ wdata : in std_logic_vector (31 downto 0 );
36
+ wstrb : in std_logic_vector (3 downto 0 ); -- un-used
37
+ -- write response channel
38
+ bvalid : out std_logic ;
39
+ bready : in std_logic ;
40
+ bresp : out std_logic_vector (1 downto 0 );
41
+ -- read address channel
42
+ arvalid : in std_logic ;
43
+ arready : out std_logic ;
44
+ araddr : in std_logic_vector (7 downto 0 );
45
+ -- read data channel
46
+ rvalid : out std_logic ;
47
+ rready : in std_logic ;
48
+ rdata : out std_logic_vector (31 downto 0 );
49
+ rresp : out std_logic_vector (1 downto 0 )
50
+
51
+
52
+ );
53
+ end entity ;
54
+
55
+ architecture rtl of info_2k8 is
56
+ constant OKAY : std_logic_vector (1 downto 0 ) := "00" ;
57
+ signal axi_int_read_ready : std_logic ;
58
+
59
+ constant identity : identity_type := rec_reset;
60
+ constant version : version_type := rec_reset;
61
+ constant git_info : git_info_type := (sha => short_sha);
62
+ signal checksum : fpga_checksum_type := rec_reset;
63
+ signal scratchpad : scratchpad_type := rec_reset;
64
+ signal hubris_compat: hubris_compat_type := rec_reset;
65
+
66
+ begin
67
+ bresp <= OKAY;
68
+ rresp <= OKAY;
69
+
70
+ wready <= awready;
71
+ arready <= not rvalid;
72
+
73
+ axi_int_read_ready <= arvalid and arready;
74
+
75
+ -- axi transaction mgmt
76
+ axi_txn : process (clk, reset)
77
+ begin
78
+ if reset then
79
+ awready <= '0' ;
80
+ bvalid <= '0' ;
81
+ rvalid <= '0' ;
82
+ elsif rising_edge (clk) then
83
+ -- bvalid set on every write,
84
+ -- cleared after bvalid && bready
85
+ if awready then
86
+ bvalid <= '1' ;
87
+ elsif bready then
88
+ bvalid <= '0' ;
89
+ end if ;
90
+
91
+ if axi_int_read_ready then
92
+ rvalid <= '1' ;
93
+ elsif rready then
94
+ rvalid <= '0' ;
95
+ end if ;
96
+
97
+ -- can accept a new write if we're not
98
+ -- responding to write already or
99
+ -- the write is not in progress
100
+ awready <= not awready and
101
+ (awvalid and wvalid) and
102
+ (not bvalid or bready);
103
+ end if ;
104
+ end process ;
105
+
106
+ write_logic : process (clk, reset)
107
+ begin
108
+ if reset then
109
+ hubris_compat <= rec_reset;
110
+ scratchpad <= rec_reset;
111
+ elsif rising_edge (clk) then
112
+ -- go ahead and flo this every cycle, it's external but not
113
+ -- changing
114
+ hubris_compat <= unpack(resize (hubris_compat_pins, 32 ));
115
+ if wready then
116
+ case to_integer (awaddr) is
117
+ when FPGA_CHECKSUM_OFFSET => checksum <= unpack(wdata);
118
+ when SCRATCHPAD_OFFSET => scratchpad <= unpack(wdata);
119
+ when others => null ;
120
+ end case ;
121
+ end if ;
122
+ end if ;
123
+ end process ;
124
+
125
+ read_logic : process (clk, reset)
126
+ begin
127
+ if reset then
128
+ rdata <= (others => '0' );
129
+ elsif rising_edge (clk) then
130
+ if (not arvalid) or arready then
131
+ case to_integer (araddr) is
132
+ when IDENTITY_OFFSET => rdata <= pack(identity);
133
+ when HUBRIS_COMPAT_OFFSET => rdata <= pack(hubris_compat);
134
+ when VERSION_OFFSET => rdata <= pack(version);
135
+ when GIT_INFO_OFFSET => rdata <= pack(git_info);
136
+ when FPGA_CHECKSUM_OFFSET => rdata <= pack(checksum);
137
+ when SCRATCHPAD_OFFSET => rdata <= pack(scratchpad);
138
+ when others =>
139
+ rdata <= (others => '0' );
140
+ end case ;
141
+ end if ;
142
+ end if ;
143
+ end process ;
144
+
145
+ end rtl ;
0 commit comments