A
Analog_Guy
Guest
Hi ... I've been a bit stumped with all the issues I am having with
records, when trying to implement a client/server approach between two
entities.
Basically, I keep getting X's in the simulation for cmd_rec.a and
cmd_rec.b, even though they appear to be properly defined.
The records are initialized at the ENTITY PORT level of the two
components (test_ctrl_clv.vhd and cpu_bfm_clv.vhd). They are assigned
in cpu_bfm_pkg_clv.vhd ... and this is when I get X's.
I have noted two things:
1. If I uncomment the assignment to cmd_rec.c in cpu_bfm_clv.vhd
everything works fine! Why do I have to make a signal assignment to
cmd_rec.c in order for this to work? The record element cmd_rec.c is
already initialized to a value at the ENTITY PORT level ... isn't that
good enough?
2. If i leave the assignment to cmd_rec.c in cpu_bfm_clv.vhd commented
out, and instead change CMD_REC_TYPE_INIT to all 'Z' entries everything
works fine! I really want some of the signals to have initial values,
so I didn't want to have to do this.
What are the rules related to RECORDs to ensure I am not running into
all these conflicts? I have chosen all RECORD elements to be STD_LOGIC
so that they should all be resolved. I can't seem to find anything
relevant in the LRM regarding this. What is the standard a
A very simplified example (which compiles and simulates) is presented
below:
************************************************************************************************
1. TOP-LEVEL (tb_top_test_clv.vhd)
--============================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
--===============================================
ENTITY tb_top_test_clv IS
--
END ENTITY tb_top_test_clv;
--
--================================================
ARCHITECTURE tb OF tb_top_test_clv IS
--
-- DUT Interface Signals
SIGNAL M_CTRL_CLK : STD_LOGIC; -- Main PLD clock.
SIGNAL RESETn : STD_LOGIC; -- Main PLD reset.
--
-- Transaction Based Signals
SIGNAL ctrl_rec : cpu_bfm_pkg_clv.CTRL_REC_TYPE;
SIGNAL cmd_rec : cpu_bfm_pkg_clv.CMD_REC_TYPE;
--
--------------------------------------------------------------------------------
-- COMPONENT DECLARATIONS
-- ----------------------
--
COMPONENT test_ctrl_clv IS
PORT (
CLOCK : IN STD_LOGIC; -- Main PLD clock.
RESETn : IN STD_LOGIC; -- Main PLD reset.
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE
);
END COMPONENT test_ctrl_clv;
--
--+++++++++++++++++++++++++++++++++++++++++++++++++
COMPONENT cpu_bfm_clv IS
PORT (
CLOCK : IN STD_LOGIC; -- Main PLD clock.
RESETn : IN STD_LOGIC; -- Main PLD reset.
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE
);
END COMPONENT cpu_bfm_clv;
--
--------------------------------------------------------------------------------
BEGIN
--
-- COMPONENT INSTANTIATIONS
-- ------------------------
test_ctrl_u1 : test_ctrl_clv
PORT MAP (
CLOCK => M_CTRL_CLK,
RESETn => RESETn,
ctrl_rec => ctrl_rec,
cmd_rec => cmd_rec
);
--
--+++++++++++++++++++++++++++++++++++++++++++++++++
cpu_bfm_u1 : cpu_bfm_clv
PORT MAP (
CLOCK => M_CTRL_CLK,
RESETn => RESETn,
ctrl_rec => ctrl_rec,
cmd_rec => cmd_rec
);
--
END ARCHITECTURE tb;
--
--=========================================
**************************************************************************************************
2. TEST CONTROL (test_ctrl_clv.vhd)
--=====================================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
--===================================================
ENTITY test_ctrl_clv IS
PORT (
CLOCK : IN STD_LOGIC;
RESETn : IN STD_LOGIC;
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE :=
cpu_bfm_pkg_clv.CTRL_REC_TYPE_INIT;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE :=
cpu_bfm_pkg_clv.CMD_REC_TYPE_INIT
);
END ENTITY test_ctrl_clv;
--
--================================================
ARCHITECTURE behav OF test_ctrl_clv IS
BEGIN
--
main_testcase : PROCESS
BEGIN
WAIT UNTIL RISING_EDGE(RESETn);
-- Exercise CPU READs
cpu_bfm_pkg_clv.cpu_read(X"0000_0000", X"A5A5_A5A5_A5A5_A5A5",
ctrl_rec, cmd_rec);
cpu_bfm_pkg_clv.cpu_read(X"0000_0001", X"5A5A_5A5A_5A5A_5A5A",
ctrl_rec, cmd_rec);
-- Extend Simulation Time
WAIT FOR 1000 ns;
-- Terminate Simulation (Current settings in ModelSim break simulation
on severity
-- level of FAILURE)
ASSERT (FALSE)
REPORT "*** Ignore Failure *** : Simulator Terminated Normally!"
SEVERITY FAILURE;
-- Suspend Process
WAIT;
END PROCESS main_testcase;
END ARCHITECTURE behav;
--
--=========================================
*********************************************************************************
3. BFM PACKAGE (cpu_bfm_pkg_clv.vhd)
--============================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
--=============================================
PACKAGE cpu_bfm_pkg_clv IS
-- Transaction Record Declarations
TYPE CTRL_REC_TYPE IS RECORD
req : STD_LOGIC;
ack : STD_LOGIC;
END RECORD CTRL_REC_TYPE;
TYPE CMD_REC_TYPE IS RECORD
a : STD_LOGIC;
b : STD_LOGIC;
c : STD_LOGIC;
END RECORD CMD_REC_TYPE;
--
--++++++++++++++++++++++++++++++++++++++++++
-- Transaction Record Initializations
CONSTANT CTRL_REC_TYPE_INIT : CTRL_REC_TYPE :=
( req => '0',
ack => 'Z');
CONSTANT CMD_REC_TYPE_INIT : CMD_REC_TYPE :=
( a => 'Z',
b => 'Z',
c => 'Z'
);
--
--------------------------------------------------------------------------------
-- CPU BFM PROCEDURE DECLARATIONS
-- ------------------------------
--
-- Transaction Level Read
-- ----------------------
PROCEDURE cpu_read ( CONSTANT addr : IN STD_LOGIC_VECTOR;
CONSTANT data : IN STD_LOGIC_VECTOR;
SIGNAL ctrl_rec : INOUT CTRL_REC_TYPE;
SIGNAL cmd_rec : INOUT CMD_REC_TYPE
);
--
END PACKAGE cpu_bfm_pkg_clv;
--
--===================================================
PACKAGE BODY cpu_bfm_pkg_clv IS
--
-- CPU BFM PROCEDURE DEFINITIONS
-- -----------------------------
--
-- Transaction Level Read
-- ----------------------
PROCEDURE cpu_read ( CONSTANT addr : IN STD_LOGIC_VECTOR;
CONSTANT data : IN STD_LOGIC_VECTOR;
SIGNAL ctrl_rec : INOUT CTRL_REC_TYPE;
SIGNAL cmd_rec : INOUT CMD_REC_TYPE) IS
BEGIN
-- Put Transaction into Record
cmd_rec.a <= '0';
cmd_rec.b <= '1';
-- Handshake with BFM
ctrl_rec.req <= NOT(ctrl_rec.req);
WAIT UNTIL ctrl_rec.ack'ACTIVE;
END PROCEDURE cpu_read;
--
END PACKAGE BODY cpu_bfm_pkg_clv;
--
--============================================
****************************************************************************************
4. BFM (cpu_bfm_clv.vhd)
--================================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
================================================
ENTITY cpu_bfm_clv IS
PORT (
CLOCK : IN STD_LOGIC;
RESETn : IN STD_LOGIC;
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE :=
cpu_bfm_pkg_clv.CTRL_REC_TYPE_INIT;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE :=
cpu_bfm_pkg_clv.CMD_REC_TYPE_INIT
);
END ENTITY cpu_bfm_clv;
--
--================================================
ARCHITECTURE behav OF cpu_bfm_clv IS
--
BEGIN
--
-- INTERFACE SPECIFICATION
-- -----------------------
--
-- CPU READ Control
-- ----------------
bfm_ctrl_1 : PROCESS
BEGIN
IF (RESETn = '0') THEN
ctrl_rec.ack <= '0';
ELSIF (ctrl_rec.req'ACTIVE) THEN
-- Execute Functionality.
WAIT UNTIL CLOCK = '1' and CLOCK'EVENT;
-- cmd_rec.c <= '1' AFTER 5 ns;
WAIT FOR 100 ns;
WAIT UNTIL CLOCK = '1' and CLOCK'EVENT;
ctrl_rec.ack <= NOT(ctrl_rec.ack); -- Toggle acknowledge to
Client, indicating end of access.
END IF;
WAIT ON RESETn, ctrl_rec;
END PROCESS bfm_ctrl_1;
--
END ARCHITECTURE behav;
--
--=========================================
Sorry for the length of the post, I am not sure how to attach files
instead of just copying the text.
Your comments would be appreciated.
records, when trying to implement a client/server approach between two
entities.
Basically, I keep getting X's in the simulation for cmd_rec.a and
cmd_rec.b, even though they appear to be properly defined.
The records are initialized at the ENTITY PORT level of the two
components (test_ctrl_clv.vhd and cpu_bfm_clv.vhd). They are assigned
in cpu_bfm_pkg_clv.vhd ... and this is when I get X's.
I have noted two things:
1. If I uncomment the assignment to cmd_rec.c in cpu_bfm_clv.vhd
everything works fine! Why do I have to make a signal assignment to
cmd_rec.c in order for this to work? The record element cmd_rec.c is
already initialized to a value at the ENTITY PORT level ... isn't that
good enough?
2. If i leave the assignment to cmd_rec.c in cpu_bfm_clv.vhd commented
out, and instead change CMD_REC_TYPE_INIT to all 'Z' entries everything
works fine! I really want some of the signals to have initial values,
so I didn't want to have to do this.
What are the rules related to RECORDs to ensure I am not running into
all these conflicts? I have chosen all RECORD elements to be STD_LOGIC
so that they should all be resolved. I can't seem to find anything
relevant in the LRM regarding this. What is the standard a
A very simplified example (which compiles and simulates) is presented
below:
************************************************************************************************
1. TOP-LEVEL (tb_top_test_clv.vhd)
--============================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
--===============================================
ENTITY tb_top_test_clv IS
--
END ENTITY tb_top_test_clv;
--
--================================================
ARCHITECTURE tb OF tb_top_test_clv IS
--
-- DUT Interface Signals
SIGNAL M_CTRL_CLK : STD_LOGIC; -- Main PLD clock.
SIGNAL RESETn : STD_LOGIC; -- Main PLD reset.
--
-- Transaction Based Signals
SIGNAL ctrl_rec : cpu_bfm_pkg_clv.CTRL_REC_TYPE;
SIGNAL cmd_rec : cpu_bfm_pkg_clv.CMD_REC_TYPE;
--
--------------------------------------------------------------------------------
-- COMPONENT DECLARATIONS
-- ----------------------
--
COMPONENT test_ctrl_clv IS
PORT (
CLOCK : IN STD_LOGIC; -- Main PLD clock.
RESETn : IN STD_LOGIC; -- Main PLD reset.
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE
);
END COMPONENT test_ctrl_clv;
--
--+++++++++++++++++++++++++++++++++++++++++++++++++
COMPONENT cpu_bfm_clv IS
PORT (
CLOCK : IN STD_LOGIC; -- Main PLD clock.
RESETn : IN STD_LOGIC; -- Main PLD reset.
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE
);
END COMPONENT cpu_bfm_clv;
--
--------------------------------------------------------------------------------
BEGIN
--
-- COMPONENT INSTANTIATIONS
-- ------------------------
test_ctrl_u1 : test_ctrl_clv
PORT MAP (
CLOCK => M_CTRL_CLK,
RESETn => RESETn,
ctrl_rec => ctrl_rec,
cmd_rec => cmd_rec
);
--
--+++++++++++++++++++++++++++++++++++++++++++++++++
cpu_bfm_u1 : cpu_bfm_clv
PORT MAP (
CLOCK => M_CTRL_CLK,
RESETn => RESETn,
ctrl_rec => ctrl_rec,
cmd_rec => cmd_rec
);
--
END ARCHITECTURE tb;
--
--=========================================
**************************************************************************************************
2. TEST CONTROL (test_ctrl_clv.vhd)
--=====================================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
--===================================================
ENTITY test_ctrl_clv IS
PORT (
CLOCK : IN STD_LOGIC;
RESETn : IN STD_LOGIC;
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE :=
cpu_bfm_pkg_clv.CTRL_REC_TYPE_INIT;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE :=
cpu_bfm_pkg_clv.CMD_REC_TYPE_INIT
);
END ENTITY test_ctrl_clv;
--
--================================================
ARCHITECTURE behav OF test_ctrl_clv IS
BEGIN
--
main_testcase : PROCESS
BEGIN
WAIT UNTIL RISING_EDGE(RESETn);
-- Exercise CPU READs
cpu_bfm_pkg_clv.cpu_read(X"0000_0000", X"A5A5_A5A5_A5A5_A5A5",
ctrl_rec, cmd_rec);
cpu_bfm_pkg_clv.cpu_read(X"0000_0001", X"5A5A_5A5A_5A5A_5A5A",
ctrl_rec, cmd_rec);
-- Extend Simulation Time
WAIT FOR 1000 ns;
-- Terminate Simulation (Current settings in ModelSim break simulation
on severity
-- level of FAILURE)
ASSERT (FALSE)
REPORT "*** Ignore Failure *** : Simulator Terminated Normally!"
SEVERITY FAILURE;
-- Suspend Process
WAIT;
END PROCESS main_testcase;
END ARCHITECTURE behav;
--
--=========================================
*********************************************************************************
3. BFM PACKAGE (cpu_bfm_pkg_clv.vhd)
--============================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
--=============================================
PACKAGE cpu_bfm_pkg_clv IS
-- Transaction Record Declarations
TYPE CTRL_REC_TYPE IS RECORD
req : STD_LOGIC;
ack : STD_LOGIC;
END RECORD CTRL_REC_TYPE;
TYPE CMD_REC_TYPE IS RECORD
a : STD_LOGIC;
b : STD_LOGIC;
c : STD_LOGIC;
END RECORD CMD_REC_TYPE;
--
--++++++++++++++++++++++++++++++++++++++++++
-- Transaction Record Initializations
CONSTANT CTRL_REC_TYPE_INIT : CTRL_REC_TYPE :=
( req => '0',
ack => 'Z');
CONSTANT CMD_REC_TYPE_INIT : CMD_REC_TYPE :=
( a => 'Z',
b => 'Z',
c => 'Z'
);
--
--------------------------------------------------------------------------------
-- CPU BFM PROCEDURE DECLARATIONS
-- ------------------------------
--
-- Transaction Level Read
-- ----------------------
PROCEDURE cpu_read ( CONSTANT addr : IN STD_LOGIC_VECTOR;
CONSTANT data : IN STD_LOGIC_VECTOR;
SIGNAL ctrl_rec : INOUT CTRL_REC_TYPE;
SIGNAL cmd_rec : INOUT CMD_REC_TYPE
);
--
END PACKAGE cpu_bfm_pkg_clv;
--
--===================================================
PACKAGE BODY cpu_bfm_pkg_clv IS
--
-- CPU BFM PROCEDURE DEFINITIONS
-- -----------------------------
--
-- Transaction Level Read
-- ----------------------
PROCEDURE cpu_read ( CONSTANT addr : IN STD_LOGIC_VECTOR;
CONSTANT data : IN STD_LOGIC_VECTOR;
SIGNAL ctrl_rec : INOUT CTRL_REC_TYPE;
SIGNAL cmd_rec : INOUT CMD_REC_TYPE) IS
BEGIN
-- Put Transaction into Record
cmd_rec.a <= '0';
cmd_rec.b <= '1';
-- Handshake with BFM
ctrl_rec.req <= NOT(ctrl_rec.req);
WAIT UNTIL ctrl_rec.ack'ACTIVE;
END PROCEDURE cpu_read;
--
END PACKAGE BODY cpu_bfm_pkg_clv;
--
--============================================
****************************************************************************************
4. BFM (cpu_bfm_clv.vhd)
--================================================
-- General Library Declarations
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--
-- BFM Package Declarations
LIBRARY rec_test;
USE rec_test.cpu_bfm_pkg_clv;
--
================================================
ENTITY cpu_bfm_clv IS
PORT (
CLOCK : IN STD_LOGIC;
RESETn : IN STD_LOGIC;
ctrl_rec : INOUT cpu_bfm_pkg_clv.CTRL_REC_TYPE :=
cpu_bfm_pkg_clv.CTRL_REC_TYPE_INIT;
cmd_rec : INOUT cpu_bfm_pkg_clv.CMD_REC_TYPE :=
cpu_bfm_pkg_clv.CMD_REC_TYPE_INIT
);
END ENTITY cpu_bfm_clv;
--
--================================================
ARCHITECTURE behav OF cpu_bfm_clv IS
--
BEGIN
--
-- INTERFACE SPECIFICATION
-- -----------------------
--
-- CPU READ Control
-- ----------------
bfm_ctrl_1 : PROCESS
BEGIN
IF (RESETn = '0') THEN
ctrl_rec.ack <= '0';
ELSIF (ctrl_rec.req'ACTIVE) THEN
-- Execute Functionality.
WAIT UNTIL CLOCK = '1' and CLOCK'EVENT;
-- cmd_rec.c <= '1' AFTER 5 ns;
WAIT FOR 100 ns;
WAIT UNTIL CLOCK = '1' and CLOCK'EVENT;
ctrl_rec.ack <= NOT(ctrl_rec.ack); -- Toggle acknowledge to
Client, indicating end of access.
END IF;
WAIT ON RESETn, ctrl_rec;
END PROCESS bfm_ctrl_1;
--
END ARCHITECTURE behav;
--
--=========================================
Sorry for the length of the post, I am not sure how to attach files
instead of just copying the text.
Your comments would be appreciated.