- fixed command size

git-svn-id: http://moon:8086/svn/vhdl/trunk@1282 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2015-06-04 13:44:21 +00:00
parent ca0b04c733
commit bae4ed7e62
2 changed files with 6 additions and 12 deletions
+3 -3
View File
@@ -57,8 +57,8 @@ ARCHITECTURE behavior OF spi_master IS
signal spi_rst_count : unsigned(5 downto 0);
signal spi_rst : std_logic;
signal cat_fifo_din : unsigned(to_unsigned(cmd)'length-1 downto 0);
signal cat_fifo_dout : unsigned(to_unsigned(cmd)'length-1 downto 0);
signal cat_fifo_din : unsigned(SIZEOF_CMD-1 downto 0);
signal cat_fifo_dout : unsigned(SIZEOF_CMD-1 downto 0);
signal cat_fifo_full : std_logic;
signal cat_fifo_empty : std_logic;
@@ -113,7 +113,7 @@ begin
GENERIC MAP
(
addr_width => NextExpBaseTwo(CAT_FIFO_DEPTH),
data_width => cmd_size
data_width => SIZEOF_CMD
)
PORT MAP
(
+3 -9
View File
@@ -8,6 +8,7 @@ package spi_types is
-- Constants
constant XFER_MAX_SIZE_BITS : natural := 32;
constant SIZEOF_CMD : natural := 2*XFER_MAX_SIZE_BITS;
-- Types
type cmd_t is record
@@ -33,7 +34,6 @@ package spi_types is
end record;
-- Functions
function cmd_size return positive;
function to_cmd (xfer_size, data_size : natural) return cmd_t;
function to_unsigned (cmd : cmd_t) return unsigned;
function to_cmd (cmd : unsigned) return cmd_t;
@@ -42,12 +42,6 @@ end spi_types;
package body spi_types is
function cmd_size return positive is
variable res : cmd_t;
begin
return res.xfer_size'length + res.data_size'length + 1 + 1;
end cmd_size;
function to_cmd(xfer_size, data_size : natural) return cmd_t is
variable res : cmd_t;
begin
@@ -57,7 +51,7 @@ package body spi_types is
end to_cmd;
function to_unsigned(cmd : cmd_t) return unsigned is
variable res : unsigned(cmd.xfer_size'length + cmd.data_size'length + 1 + 1 -1 downto 0) := (others => '0');
variable res : unsigned(SIZEOF_CMD-1 downto 0) := (others => '0');
begin
res(res'left downto res'left - cmd.xfer_size'length+1) := cmd.xfer_size;
res(res'left - cmd.xfer_size'length downto res'left - cmd.xfer_size'length - cmd.data_size'length +1) := cmd.data_size;
@@ -68,7 +62,7 @@ package body spi_types is
variable res : cmd_t;
begin
res.xfer_size := cmd(cmd'left downto cmd'left - res.xfer_size'length+1);
res.data_size := cmd(cmd'left - res.xfer_size'length downto cmd'left - res.xfer_size'length - res.data_size'length +1);
res.data_size := cmd(cmd'left - res.xfer_size'length downto 0);
return res;
end to_cmd;