Altera_Forum
Honored Contributor
9 years agoWay to switch codes by the compilers
Hello, guys.
I am in the VHDL, and I am using the Quartus with the ModelSim. I have written a clocker for the simulations;library ieee;
use ieee.std_logic_1164.all;
entity clocker is
port (
clock: out std_logic
);
end;
architecture clocker of clocker is
constant clock_period: time := 1 ps;
begin
process
begin
clock <= '0';
wait for clock_period;
clock <= '1';
wait for clock_period;
end process;
end;
and I have used the "generate"s and switch by one constant value; -- DO NOT FORGET to toggle when switched to the other compiler.
constant simulating: boolean := true;
...
g0: if not simulating generate
clock <= CLOCK_125_p;
end generate;
g1: if simulating generate
c0: clocker
port map(clock);
end generate;
But I began to think gradually that I want to switch codes by automatically. For example, in the C/C++, below snippet (maybe) has the ability. #ifdef __GNUC__# ifndef __clang__
// codes for the gcc...# else
// codes for the clang...# endif# endif Finally, I have written the snippet to switch that. -- synthesis read_comments_as_HDL on
-- constant simulating: boolean := false;
-- synthesis read_comments_as_HDL off
-- synthesis translate_off
constant simulating: boolean := true;
-- synthesis translate_on
It has works on the quartus_map(Quartus), and the vcom(ModelSim), but I think it is not clever way. Question: How should I write? Where is a good way? Environment Info: Windows 7 Ultimate Service Pack 1 Quartus Prime Version 16.0.2 Build 222 07/20/2016 SJ Lite Edition ModelSim ALTERA STARTER EDITION 10.4d Revision: 2015.12 Cyclone V GX Starter Kit (5CGXFC5C6F27C7)