Let us know how well it works out for you...
Well you still need internal signals, don't you?
What I mean is that the following:
entity design_1 is
port (
btn : in STD_LOGIC;
clk : in STD_LOGIC;
led : out STD_LOGIC;
sw : in STD_LOGIC_VECTOR ( 3 downto 0 )
);
end design_1;
architecture STRUCTURE of design_1 is
component design_1_clk_wiz_0_0 is
port (
clk_in1 : in STD_LOGIC;
clk_out1 : out STD_LOGIC
);
end component design_1_clk_wiz_0_0;
component design_1_pwm_0_0 is
port (
clk_i : in STD_LOGIC;
reset_i : in STD_LOGIC;
led_o : out STD_LOGIC;
val_i : in STD_LOGIC_VECTOR ( 3 downto 0 )
);
end component design_1_pwm_0_0;
signal btn_1 : STD_LOGIC;
signal clk_1 : STD_LOGIC;
signal clk_wiz_0_clk_out1 : STD_LOGIC;
signal pwm_0_led_o : STD_LOGIC;
signal sw_1 : STD_LOGIC_VECTOR ( 3 downto 0 );
begin
btn_1 <= btn;
clk_1 <= clk;
led <= pwm_0_led_o;
sw_1(3 downto 0) <= sw(3 downto 0);
clk_wiz_0: component design_1_clk_wiz_0_0
port map (
clk_in1 => clk_1,
clk_out1 => clk_wiz_0_clk_out1
);
pwm_0: component design_1_pwm_0_0
port map (
clk_i => clk_wiz_0_clk_out1,
led_o => pwm_0_led_o,
reset_i => btn_1,
val_i(3 downto 0) => sw_1(3 downto 0)
);
end STRUCTURE;
Should be possible to express with:
entity design_1 is
port (
btn : in STD_LOGIC;
clk : in STD_LOGIC;
led : out STD_LOGIC;
sw : in STD_LOGIC_VECTOR ( 3 downto 0 )
);
end design_1;
architecture STRUCTURE of design_1 is
signal clk_wiz_0_clk_out1 : STD_LOGIC;
begin
clk_wiz_0: component design_1_clk_wiz_0_0
port map (
clk_in1 => clk,
clk_out1 => clk_wiz_0_clk_out1
);
pwm_0: component design_1_pwm_0_0
port map (
clk_i => clk_wiz_0_clk_out1,
led_o => led,
reset_i => btn,
val_i(3 downto 0) => sw(3 downto 0)
);
end STRUCTURE;
I.e.
- Skip the component port declaration, that should be inferred straight from the component's source. Copypasta between the component and the entity that instantiates it is ridiculous...
- Skip the local signals that have no other purpose than connecting a port of the entity straight to a port of a component, connect those directly
- Local signals that are used to connect ports between components are fine, they're required due the possibility of having multiple instances of the same component, no issue there.
You already save half the code lines, and it seems you don't lose anything. You need a little more back and forth between files to check component declarations when doing the mapping, but I'd take that any day over having to copy them across and maintain that copy, every language requires that kind of thing anyway.
Disclaimer: I'm pretty much a beginner in VHDL and I'm probably missing something including the possibility that my proposed version could be OK
, and I've never tried verilog so maybe that does just this - if so I'd happily have a look at it, I'm here to learn!
Note: obviously modern tools e.g. Vivado are able to hide that away from you by autogenerating the top module from the much easier to specify graphical block diagram, but still.