System Generator Question: Flopping the inputs and outputs

Hi,

I'm trying to implement some control circuits in Mcode. I want to have the inputs and the outputs of the circuits to be flopped. I'm having trouble finding guidance in the documentation as to how I might do this. Could anybody help.

As you may have surmised, I am new to System Generator.

Phil

Reply to
Phil
Loading thread data ...

Here is my attempt at a 2 input mux with a reset. It seems to work, but I'm not sure if there is a more appropriate way of registering the inputs and outputs.

function [mux_out] = mux(a_in, b_in, sel_in, rst)

persistent a_flop, a_flop = xl_state(0, {xlUnsigned, 8, 0}); persistent b_flop, b_flop = xl_state(0, {xlUnsigned, 8, 0}); persistent mux_o, mux_o = xl_state(0, {xlUnsigned, 8, 0}); %--------------------------------------------------------------- % Mux %---------------------------------------------------------------

if rst mux_o = 0; mux_out = 0; else mux_out = mux_o; if sel_in mux_o = b_flop; else mux_o = a_flop; end end;

if rst a_flop = 0; b_flop = 0; else a_flop = a_in; b_flop = b_in; end;

Reply to
Phil

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.