子模块实例化表示的就是根据子模块(组件)的声明定义一个子模块实例,同时定义此实例的信号连接方式以及类属参数等。UART 顶层模块的子模块实例化代码如下:
- -- 波特率发生器实例
- U_BG : baudrate_generator
- port map(
- bg_out => bg_out,
- ce => ce_parts,
- clk => clk,
- indicator => indicator,
- reset_n => reset_parts
- );
- -- 总线选择器实例
- U_BusSwitch : switch_bus
- port map(
- din1 => send_parity_source( DATA_BIT-1 downto 0 ),
- din2 => recv_parity_source( DATA_BIT-1 downto 0 ),
- dout => pv_source( DATA_BIT-1 downto 0 ),
- sel => sel_pv
- );
- -- UART 内核实例
- U_Core : uart_core
- port map(
- ce_parts => ce_parts,
- clk => clk,
- error => error,
- new_data => new_data,
- overflow => overflow,
- parity => parity,
- recv => recv,
- recv_bus => recv_parity_source( DATA_BIT-1 downto 0 ),
- regs => regs( TOTAL_BIT-1 downto 0 ),
- reset_dt => reset_dt,
- reset_n => reset_n,
- reset_parts => reset_parts,
- sel_clk => sel_clk,
- sel_out => sel_out,
- sel_pv => sel_pv,
- sel_si => sel_si,
- send => send,
- send_bus => send_parity_source( DATA_BIT-1 downto 0 ),
- send_over => send_over,
- send_si => send_si
- );
- -- 计数器实例
- U_Counter : counter
- port map(
- ce => ce_parts,
- clk => counter_clk,
- overflow => overflow,
- reset_n => reset_parts
- );
- -- 计数器时钟源选择器
- U_CounterClkSwitch : switch
- port map(
- din1 => indicator,
- din2 => clk_inv,
- dout => counter_clk,
- sel => sel_clk
- );
- -- 信号监测器
- U_Detector : detector
- port map(
- RxD => RxD,
- clk => clk,
- new_data => new_data,
- reset_n => reset_dt
- );
- -- 奇偶校验器
- U_ParityVerifier : parity_verifier
- port map(
- parity => parity,
- source => pv_source( DATA_BIT-1 downto 0 )
- );
- -- 移位寄存器输入源选择器实例
- U_SISwitch : switch
- port map(
- din1 => send_si,
- din2 => RxD,
- dout => sr_in,
- sel => sel_si
- );
- -- 移位寄存器实例
- U_SR : shift_register
- port map(
- clk => bg_clk,
- din => sr_in,
- dout => sr_out,
- regs => regs( TOTAL_BIT-1 downto 0 ),
- reset_n => reset_parts
- );
- -- 移位寄存器时钟源选择器实例
- U_SRClkSwitch : switch
- port map(
- din1 => bg_out,
- din2 => clk_inv,
- dout => bg_clk,
- sel => sel_clk
- );
- -- 输出选择器实例
- U_TXDSwitch : switch
- port map(
- din1 => VCC,
- din2 => sr_out,
- dout => TxD,
- sel => sel_out
- );
复制代码
以上便是 UART 顶层模块的实现方法, UART 顶层模块就是将 UART 内核和其他模块连接起来组成一个完成的模块。
0
|
|
|
|