0
\$\begingroup\$

I created my own clock since I need a 2Mhz clock and the clock generator IP wont let me go bellow 6Mhz. I created a clock divider module.

module clock_divider#(parameter HALF_CYCLE_COUNT = 128, COUNT_BITS = 8)
(
    input clk_in,
    output reg clk_out = 1'b0
);

    reg [COUNT_BITS - 1:0] counter = 1'b0;
    always @(posedge clk_in) begin
        if(counter == HALF_CYCLE_COUNT - 1) begin
            counter <= 0;
            clk_out = ~clk_out;
        end else counter <= counter + 1;
    end
endmodule

Here is my top level module.

module audio_visualizer
(
    input clk,
    input m_data,
    output m_clk,
    output reg m_lr = 1'b1
);

    wire pdm_clk;
    clock_divider#(.HALF_CYCLE_COUNT(100), .COUNT_BITS(7)) pdm_clk_div(clk, pdm_clk);
    assign m_clk = pdm_clk;

    wire [7:0] sample;
    wire sample_changed;
    sampler s(pdm_clk, m_data, 1'b0, sample, sample_changed);

    ila_0 i(clk, sample, sample_changed, pdm_clk);
endmodule

I want to declare a constraint so that vivado knows the frequency of pdm_clk. Here is what I have right now for clocking constraints.

set_property -dict { PACKAGE_PIN E3    IOSTANDARD LVCMOS33 } [get_ports { clk }]; #IO_L12P_T1_MRCC_35 Sch=clk100mhz
create_clock -add -name clk -period 10.00 -waveform {0 5} [get_ports {clk}];
create_generated_clock -name pdm_clk -source [get_ports clk] -divide_by 50 [get_ports pdm_clk]

I keep getting this error.

[Vivado 12-1387] No valid object(s) found for create_generated_clock constraint with option '-objects [get_ports pdm_clk]'. ["/home/chase/vivado-workspace/Sound/Sound.srcs/constrs_1/imports/Desktop/Nexys4DDR_Master.xdc":9]

I am not sure how to tell vivado what the output of the generated clock is. I have also tried [get_pins audio_visualizer/pdm_clk].

\$\endgroup\$
2
  • \$\begingroup\$ I'm not sure I would be too concerned about anything at 2 MHz. I would recommend using your divider as a chip enable and continue using the original clock. My 2 cents \$\endgroup\$
    – johnnymopo
    Commented Jan 22, 2016 at 15:25
  • \$\begingroup\$ Good to know. I just want to know how to set the constraint for future reference. \$\endgroup\$
    – chasep255
    Commented Jan 22, 2016 at 15:59

1 Answer 1

2
\$\begingroup\$

The problem is that pdm_clk isn't a port, it's a wire, and so won't be found by the get_ports search.

What you should instead do, is target the actual register driving the signal. You can do this with something like (haven't checked):

create_generated_clock ... {pdm_clk_div|clk_out}

Where in this case clk_out is the name of the register inside the ```pdm_clk_div` instance which is driving the clock net.

If the above doesn't work, you can try something like [get_pins {pdm_clk_div|clk_out}] or [get_registers {pdm_clk_div|clk_out}]


As a side note, if you are generating your own clocks, you should also include a BUFG primitive on the output so that the clock can be promoted to the global clock network. This will avoid excessive skew warnings later on during fitting.

However I agree with @johnnymopo's comment that the best approach is to use the original clock to drive your registers and then use the clock divider to generate a clock enable. Instead of generated clock constraints in this case you may instead require multicycle paths to declared if there are any timing issues.

\$\endgroup\$
2
  • \$\begingroup\$ Wouldn't I also need to add the instance name somewhere since I can have two instances creating different frequencies. \$\endgroup\$
    – chasep255
    Commented Jan 25, 2016 at 1:02
  • \$\begingroup\$ @chasep255 pdm_clk_div was the instance name. clk_out is the output register of that instance. Say you had another instance called another_clk_div, then the second constraint would target another_clk_div|clk_out \$\endgroup\$ Commented Jan 25, 2016 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.