Guest
On a couple of occasions, I have wanted to share some C/C++ header (.h)
defines between my firmware apps and VHDL code. This usually is for
memory mapping and enumerated type issues. Here's an example:
C/C++ .h file contains:
//----------------------------------------------//
#define BIN_TYPE_REG 0x05
#define BIN_TYPE_A 0
#define BIN_TYPE_B 1
#define BIN_TYPE_C 2
//----------------------------------------------//
Then in the FPGA VHDL file:
-----------------------------------------------
--- After Arch.
CONSTANT BIN_TYPE_REG : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"05";
CONSTANT BIN_TYPE_A : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"00";
CONSTANT BIN_TYPE_B : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"01";
CONSTANT BIN_TYPE_C : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"02";
---begin
---in some process
CASE(Address)
WHEN BIN_TYPE_REG =>
Data_Bus <= BIN_TYPE_B;
-----------------------------------------------
As you can see the same constants are duplicated in both files, which
is a pain to keep track of. I'm sure someone has run in this before.
Has anyone come up with a workable solution?
I have thought about writing script to parse the C header and replace a
tag embedded in the VHDL, but thought that maybe there was a cleaner
way to accomplish this.
Thanks,
Aaron
defines between my firmware apps and VHDL code. This usually is for
memory mapping and enumerated type issues. Here's an example:
C/C++ .h file contains:
//----------------------------------------------//
#define BIN_TYPE_REG 0x05
#define BIN_TYPE_A 0
#define BIN_TYPE_B 1
#define BIN_TYPE_C 2
//----------------------------------------------//
Then in the FPGA VHDL file:
-----------------------------------------------
--- After Arch.
CONSTANT BIN_TYPE_REG : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"05";
CONSTANT BIN_TYPE_A : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"00";
CONSTANT BIN_TYPE_B : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"01";
CONSTANT BIN_TYPE_C : STD_LOGIC_VECTOR(7 DOWNTO 0) := x"02";
---begin
---in some process
CASE(Address)
WHEN BIN_TYPE_REG =>
Data_Bus <= BIN_TYPE_B;
-----------------------------------------------
As you can see the same constants are duplicated in both files, which
is a pain to keep track of. I'm sure someone has run in this before.
Has anyone come up with a workable solution?
I have thought about writing script to parse the C header and replace a
tag embedded in the VHDL, but thought that maybe there was a cleaner
way to accomplish this.
Thanks,
Aaron