Skip to content

Commit fc7ce03

Browse files
Espi core and spi-nor updates to support reading flash (#198)
This brings in the espi block and modifies the spi-nor block to support flash reads from espi. This isn't totally done, but the sims run and I'm going to merge it so that I can rebase the grapefruit branch off of it.
1 parent db9535f commit fc7ce03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4944
-174
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ vivado*.log
3535

3636
# DrawIO cruft
3737
**/*.svg.bkp
38-
*.dtmp

hdl/ip/vhd/crc/BUCK

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("//tools:hdl.bzl", "vhdl_unit")
2+
3+
vhdl_unit(
4+
name = "crc8atm_8wide",
5+
srcs = ["crc8atm_8wide.vhd"],
6+
visibility = ['PUBLIC']
7+
)

hdl/ip/vhd/crc/crc8atm_8wide.vhd

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
library ieee;
8+
use ieee.std_logic_1164.all;
9+
use ieee.numeric_std.all;
10+
use ieee.numeric_std_unsigned.all;
11+
12+
-- An 8-wide parallel CRC LFSR implementation for the
13+
-- CRC8ATM CRC algorithm.
14+
-- The polynomial represented here is x^8+x^2+x+1 with
15+
-- a 0's seed value.
16+
17+
entity crc8atm_8wide is
18+
port (
19+
clk : in std_logic;
20+
reset : in std_logic;
21+
data_in : in std_logic_vector(7 downto 0);
22+
enable : in std_logic;
23+
clear : in std_logic;
24+
crc_out : out std_logic_vector(7 downto 0)
25+
);
26+
end entity;
27+
28+
architecture rtl of crc8atm_8wide is
29+
30+
begin
31+
32+
crc_reg: process(clk, reset)
33+
begin
34+
if reset then
35+
crc_out <= (others => '0');
36+
elsif rising_edge(clk) then
37+
-- This logic may run on a faster clock cycle than our shifter
38+
-- so we allow the external logic to clock faster and use the
39+
-- enable and clear to control when we do the shifts.
40+
if clear then
41+
crc_out <= (others => '0');
42+
elsif enable then
43+
-- This equation is created by unrolling 8 shifts of the
44+
-- LFSR.
45+
crc_out(0) <= crc_out(0) xor crc_out(6) xor crc_out(7) xor data_in(0) xor data_in(6) xor data_in(7);
46+
crc_out(1) <= crc_out(0) xor crc_out(1) xor crc_out(6) xor data_in(0) xor data_in(1) xor data_in(6);
47+
crc_out(2) <= crc_out(0) xor crc_out(1) xor crc_out(2) xor crc_out(6) xor data_in(0) xor data_in(1) xor data_in(2) xor data_in(6);
48+
crc_out(3) <= crc_out(1) xor crc_out(2) xor crc_out(3) xor crc_out(7) xor data_in(1) xor data_in(2) xor data_in(3) xor data_in(7);
49+
crc_out(4) <= crc_out(2) xor crc_out(3) xor crc_out(4) xor data_in(2) xor data_in(3) xor data_in(4);
50+
crc_out(5) <= crc_out(3) xor crc_out(4) xor crc_out(5) xor data_in(3) xor data_in(4) xor data_in(5);
51+
crc_out(6) <= crc_out(4) xor crc_out(5) xor crc_out(6) xor data_in(4) xor data_in(5) xor data_in(6);
52+
crc_out(7) <= crc_out(5) xor crc_out(6) xor crc_out(7) xor data_in(5) xor data_in(6) xor data_in(7);
53+
end if;
54+
end if;
55+
end process;
56+
57+
end rtl;

hdl/ip/vhd/espi/BUCK

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
load("//tools:hdl.bzl", "vhdl_unit", "vunit_sim")
2+
load("//tools:rdl.bzl", "rdl_file")
3+
4+
rdl_file(
5+
name = "espi_spec_regs_pkg",
6+
src = "espi_spec_regs.rdl",
7+
outputs = ["espi_spec_regs_pkg.vhd", "espi_spec_regs.html"],
8+
visibility = ['PUBLIC']
9+
)
10+
11+
rdl_file(
12+
name = "espi_regs_pkg",
13+
src = "sys_regs/espi_regs.rdl",
14+
outputs = ["espi_regs_pkg.vhd", "espi_regs.html"],
15+
visibility = ['PUBLIC']
16+
)
17+
18+
vhdl_unit(
19+
name = "espi_top",
20+
srcs = glob([
21+
"link_layer/*.vhd",
22+
"txn_layer/*.vhd",
23+
"flash_channel/*.vhd",
24+
"sys_regs/*.vhd",
25+
"*.vhd"]),
26+
deps = [
27+
":espi_spec_regs_pkg",
28+
":espi_regs_pkg",
29+
"//hdl/ip/vhd/crc:crc8atm_8wide",
30+
"//hdl/ip/vhd/fifos:dcfifo_xpm",
31+
"//hdl/ip/vhd/fifos:dcfifo_mixed_xpm",
32+
"//hdl/ip/vhd/axi_blocks:axilite_common_pkgs",
33+
"//hdl/ip/vhd/memories:dual_clock_simple_dpr",
34+
],
35+
standard = "2019",
36+
visibility = ['PUBLIC']
37+
)
38+
vunit_sim(
39+
name = "espi_tb",
40+
srcs = glob(["sims/**/*.vhd"]),
41+
deps = [
42+
":espi_top",
43+
"//hdl/ip/vhd/vunit_components:qspi_controller_vc"
44+
],
45+
visibility = ['PUBLIC'],
46+
)

hdl/ip/vhd/espi/docs/espi.adoc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:showtitle:
2+
:toc: left
3+
:numbered:
4+
:icons: font
5+
:revision: 1.0
6+
:revdate: 2024-04-24
7+
8+
= eSPI Target Core

hdl/ip/vhd/espi/docs/espi_block.drawio.svg

+4
Loading

0 commit comments

Comments
 (0)