Hi,
Thank You for quick response.
addr > 0 worked.
But Now I landed with different issue.
My requirement is I need a Read Before write memory.
Here is my m code
function demux_out=syn_demux_ref(t,addr,din,we)
% Persistent variables for memory functions
X =(128:1);
persistent d0;
% Initialize persistent variables
if (t==0)
X = zeros(128:1);
d0 =0;
end
if (addr > 0)
if (we == 1)
X(addr) = din;
end
d0 = X(addr);
end
demux_out =[d0];
return
what happens here is I write first into array and then
d0 will read it.
But my requrement is read before write, so I expect
zeros to be outputted from my array.
when I modify my m code as below
function demux_out=syn_demux_ref(t,addr,din,we)
% Persistent variables for memory functions
X =(128:1);
persistent d0;
% Initialize persistent variables
if (t==0)
X = zeros(128:1);
d0 =0;
end
if (addr > 0)
d0 = X(addr);
if (we == 1)
X(addr) = din;
end
end
demux_out =[d0];
return
It does not work.
Matlab gives following error
Error in MATLAB Function block 'demux/Demux_ref/MATLAB
Fcn' while evaluating expression: Index exceeds matrix
dimensions
I'm not able to trace where exactly I'm doing mistake.
Is there a way I can do Read before write.
Thanks
Sanjay
--- Ahmed El-Saied <> wrote: >
This Error results that you may had made an index =
> 0
> there is no index 0 in matlab ,,,, begin index from
> 1
> X(1) ---> First Element
> X(0) ---> Error , There is no index zero
> ----- Original Message -----
> From: "Sanjay" <>
> To: <>
> Sent: Friday, April 30, 2004 11:46 AM
> Subject: [matlab] Single Port RAM in matlab
> > Hi,
> >
> > I want to design a single ported RAM [Random
> Access
> > Memory] in matlab.
> >
> > The Memory will have address, Data and Write
> Enable as
> > a Input Port.
> >
> > Behaviour is
> >
> > if addr>=0
> > if WE == 1
> > X(addr) = din;
> > end
> > Dout <= X(addr);
> > end;
> >
> > So I need to define X as a array
> > I've defined as
> > X = zeros(1,128); % assume RAM size is 128
> >
> > When I compile this code,I get error message as
> >
> > while evaluating expression: Subscript indices
> must
> > either be real
> > positive integers or logicals
> >
> > Can anyone help me on M script of RAM?
> >
> >
> > Thanks in Advance
> > Sanjay
> >
> >
> >
> >
> >
> >
> >
> >
>
____________________________________________________________
> > Yahoo! Messenger - Communicate
instantly..."Ping"
> > your friends today! Download Messenger Now
> > http://uk.messenger.yahoo.com/download/index.html
> >
> >
> >
> > _____________________________________
> > Note: If you do a simple "reply" with your email
> client, only the author
> of this message will receive your answer. You need
> to do a "reply all" if
> you want your answer to be distributed to the entire
> group.
> >
> > _____________________________________
> > About this discussion group:
> >
> > To Join:
> >
> > To Post:
> >
> > To Leave:
> >
> > Archives: http://www.yahoogroups.com/group/matlab
> >
> > More DSP-Related Groups:
> http://www.dsprelated.com/groups.php3
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
|