System Generator error: "The inputs to this block cannot all be constant"

I am reading the article (attached file) and making VCO circuit (Charged balance) to model on Matlab/Simulink using System Generator. I get some error and I don't know how to fix it. At one-shot timer module when I run, it notifies:

Error 0001: The inputs to this block cannot all be constant.
Block: 'VCO_v2/one-shot timer '

This is my diagram enter image description here

This is the error I encounter enter image description here

This is my VCO file I simulink

Upvotes: 2

Views: 538

Answers (2)

I found the answer for this problem. Just change constant block of Matlab instead of using constant block of Xilinx. enter image description here

Upvotes: 1

JHBonarius
JHBonarius

Reputation: 11271

You've attached two entities. I'm assuming you're using oneshot v1.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity oneshot is
    port ( clk : in STD_LOGIC;
            ce : in STD_LOGIC;
            trigger : in STD_LOGIC;
            delay : in STD_LOGIC_VECTOR (7 downto 0);
            pulse : out STD_LOGIC :='0');
end oneshot;

architecture Behavioral of oneshot is
    signal count: INTEGER range 0 to 255; -- count variable
    signal flag : STD_LOGIC := '0'; -- count variable
begin
    process (flag,clk,delay)
    begin
        -- wait for trigger leading edge
        if trigger = '1' then
            count <= to_integer(unsigned(delay));
        elsif rising_edge(clk) then
            if count > 0 then
                pulse <= '1';
                count <= count - 1;
            else
                pulse <= '0';
            --flag <='0';
            end if;
        end if;
    end process;
end Behavioral;

So what's the flag signal doing there? Why is it in the sensitivity list? Why is there an unused ce input?

But let's look at the oneshot_config.m file. The error message originates from there:

function setup_as_single_rate(block,clkname,cename) 
    inputRates = block.inputRates; 
    uniqueInputRates = unique(inputRates); 
    if (length(uniqueInputRates)==1 & uniqueInputRates(1)==Inf) 
        block.addError('The inputs to this block cannot all be constant.'); 
        return; 
    end 
    if (uniqueInputRates(end) == Inf) 
        hasConstantInput = true; 
        uniqueInputRates = uniqueInputRates(1:end-1); 
    end 
    if (length(uniqueInputRates) ~= 1) 
        block.addError('The inputs to this block must run at a single rate.'); 
        return; 
    end 
    theInputRate = uniqueInputRates(1); 
    for i = 1:block.numSimulinkOutports 
        block.outport(i).setRate(theInputRate); 
    end 
    block.addClkCEPair(clkname,cename,theInputRate); 
    return; 

And that is called here

if (this_block.inputRatesKnown)
    setup_as_single_rate(this_block,'clk','ce')
end  % if(inputRatesKnown)

So the matlab code checks the inputRates of all inputs of this_block input. It has concluded that all the inputs are constant (you have no variable inputs to you system) and it has concluded that this will not work. This is because it tries to automatically determine the clock frequency from its inputs, which is impossible with constants.

So you'lll have to configure the clock rate manually. You could modify the oneshot_config.m. But probably you can assign a rate to the constant block. It should be something like block.outport.setRate(...); <-- some clock rate. Check the System Generator user guide.

I don't have System Generator installed on my Matlab pc, so I cannot check this.

Upvotes: 1

Related Questions