Simulink HDL Coder D-FF With Trigger that isn't clock
Show older comments
Hello, im trying to build a D-FF using HDL Coder in Simulink without a clock trigger signal. The trigger signal I desire is generated outside the subsystem and fed as an input to the subsystem. Whenever I convert the model into HDL, inputs that are not included in the subsystem are added (such as clk, clk_enable). Is there a way to model a DFF with a trigger signal that is not a system clock and translate it into HDL using HDL Coder?
The generated HDL code should be something like this:
------------------------------------------------------------------------------------------------
always @(posedge trigger_signal or negedge rst)
begin
if (!rst)
v_sampled_latched <= pi_ref;
else
v_sampled_latched<=v_sampled_masked;
end
------------------------------------------------------------------------------------------------
I have tried using delay block and triggered subsystem, both add undesired inputs to the system, and use those inputs as trigger to the DFF instead of the signal i desire.
Any help would be greatly appreciated!
Accepted Answer
More Answers (3)
Kiran Kintali
on 3 May 2021
1 vote
The requirement is relaxed in the newer releases.
makehdl('Simulink_PI_Triggered/Discrete Compensator', 'TriggerAsClock', 'on', 'TriggerAsClockWithoutSyncRegisters', 'on')
Kiran Kintali
on 4 May 2021
you can generate negative edge reset using ResetAssertedLevel option
makehdl(gcb, 'triggerasclock', 'on' , 'ResetAssertedLevel', 'Active-low')
always @(posedge Trigger or negedge reset)
begin : vsampled_latch_hold_process
if (reset == 1'b0) begin
In1_hold <= 6'b000000;
end
else begin
In1_hold <= In1;
end
end
you can remove resets in the generated code using the MinimizeGlobalReset option
makehdl(gcb, 'triggerasclock', 'on', 'minimizeglobalreset', 'on')
always @(posedge Trigger)
begin : vsampled_latch_hold_process
In1_hold <= In1;
end
1 Comment
Itay Israeli
on 4 May 2021
Kiran Kintali
on 30 Apr 2021
0 votes
Can you share a sample model?
Categories
Find more on Clocking and Multirate Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
