FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > VHDL

VHDL comp.lang.vhdl newsgroup / Usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-20-2005, 11:51 AM
Kumar
Guest
 
Posts: n/a
Default How to change the logic .......?

How should I make my program more effective....?

Can anyone tell the modification for the program which does the memory
controller operation...


Please tell me the modification for the program....


entity mc is
port(
wrcut bit_vector(2 downto 0);
clk,rw: in bit;
ea:in bit_vector(3 downto 0)
);
end mc;

architecture behave of mc is
begin
process(clk)
variable sar1:bit_vector(7 downto 0);variable rar1:bit_vector(7 downto
0);variable car1:bit_vector(7 downto 0);
variable sar2:bit_vector(7 downto 0);variable rar2:bit_vector(7 downto
0);variable car2:bit_vector(7 downto 0);
variable sar3:bit_vector(7 downto 0);variable rar3:bit_vector(7 downto
0);variable car3:bit_vector(7 downto 0);
variable temp:bit_vector(3 downto 0);
variable l1,l2,l3:bit_vector(1 downto 0);
begin
if(clk='1')then
sar1 := "10001000";
sar2 := "10101010";
sar3 := "10111010";
rar1 := "10011000";
rar2 := "10001100";
rar3 := "11101000";
car1 := "10111011";
car2 := "10001111";
car3 := "11111000";

temp := sar1(3 downto 0);
if (ea = temp) then
wrc(0) <= 1;
l1 := 1;
else
wrc(0) <= 0;
end if;

temp := sar2(3 downto 0);
if (ea = temp) then
wrc(0) <= 1;
l1 := 2;
else
wrc(0) <= 0;
end if;

temp := sar3(3 downto 0);
if (ea = temp) then
wrc(0) <= 1;
l1 := 3;
else
wrc(0) <= 0;
end if;

temp := rar1(3 downto 0);
if (ea = temp) then
wrc(1) <= 1;
l2 := 1;
else
wrc(1) <= 0;
end if;

temp := rar2(3 downto 0);
if (ea = temp) then
wrc(1) <= 1;
l2 := 1;
else
wrc(1) <= 0;
end if;

temp := rar3(3 downto 0);
if (ea = temp) then
wrc(1) <= 1;
l2 := 1;
else
wrc(1) <= 0;
end if;

temp := car1(3 downto 0);
if (ea = temp) then
wrc(2) <= 1;
l3 := 1;
else
wrc(2) <= 0;
end if;

temp := car2(3 downto 0);
if (ea = temp) then
wrc(2) <= 1;
l3 := 1;
else
wrc(2) <= 0;
end if;

temp := car3(3 downto 0);
if (ea = temp) then
wrc(2) <= 1;
l3 := 1;
else
wrc(2) <= 0;
end if;

if(rw = '0')then -- for readers
if (wrc = "000") then --rcw = 000, Put in rar
rar2(3 downto 0) := ea;
elsif (wrc = "100") then --rcw = 001
rar2(3 downto 0) := ea;
elsif (wrc = "001") then --rcw = 010, RAW, enter in rar and link with
matched sar
rar2(3 downto 0) := ea;
if(l1 = 1)then
rar2(5 downto 4) := "00";
elsif(l1 = 2)then
rar2(5 downto 4) := "01";
elsif(l1 = 3)then
rar2(5 downto 4) := "10";
end if;
elsif (wrc = "101") then --rcw = 011, enter in rar and link with sar
rar2(3 downto 0) := ea;
if(l1 = 1)then
rar2(5 downto 4) := "00";
elsif(l1 = 2)then
rar2(5 downto 4) := "01";
elsif(l1 = 3)then
rar2(5 downto 4) := "10";
end if;
elsif(wrc = "010")then --rcw = 100, enter in rar, link for service
with matched rar.
rar3(3 downto 0) := ea;
if(l1 = 1)then
rar3(5 downto 4) := "00";
elsif(l1 = 2)then
rar3(5 downto 4) := "01";
elsif(l1 = 3)then
rar3(5 downto 4) := "10";
end if;
elsif(wrc = "110")then --rcw = 101, enter in rar with link to match
rar.
rar3(3 downto 0) := ea;
if(l2 = 1)then
rar3(5 downto 4) := "00";
elsif(l2 = 2)then
rar3(5 downto 4) := "01";
elsif(l2 = 3)then
rar3(5 downto 4) := "10";
end if;
elsif(wrc = "011")then --rcw = 110, RAW, enter in rar link with
matched sar.
rar2(3 downto 0) := ea;
if(l1 = 1)then
rar2(5 downto 4) := "00";
elsif(l1 = 2)then
rar2(5 downto 4) := "01";
elsif(l1 = 3)then
rar2(5 downto 4) := "10";
end if;
end if;

elsif(rw='1')then -- for writers.
if(wrc = "000")then --rwc = 000, no hazard, enter in sar
sar2(3 downto 0) := ea;
elsif(wrc = "100")then --rcw = 001, enter in sar
sar2(3 downto 0) := ea;
elsif(wrc = "001")then --rcw = 010, enter in sar
sar2(3 downto 0) := ea;
elsif(wrc = "101") then --rcw = 011, ener in sar and link with sar
sar2(3 downto 0) := ea;
if(l1 = 1)then
sar2(5 downto 4) := "00";
elsif(l1 = 1)then
sar2(5 downto 4) := "01";
elsif(l1 = 1)then
sar2(5 downto 4) := "10";
end if;
elsif(wrc = "010")then --rcw = 100, WAR, enter in sar, link with
rar.
sar2(3 downto 0) := ea;
if(l2 = 1)then
sar2(5 downto 4) := "00";
elsif(l2 = 1)then
sar2(5 downto 4) := "01";
elsif(l2 = 1)then
sar2(5 downto 4) := "10";
end if;
elsif(wrc = "110")then --rcw = 101, WAR, enter in sar link with rar.
sar2(3 downto 0) := ea;
if(l2 = 1)then
sar2(5 downto 4) := "00";
elsif(l2 = 1)then
sar2(5 downto 4) := "01";
elsif(l2 = 1)then
sar2(5 downto 4) := "10";
end if;
end if;
end if; --rw
end if; --clk
end process;
end behave;




Please tell me how can I modify and write in less numnber of lines,,,


Waiting

Reply With Quote
  #2 (permalink)  
Old 10-20-2005, 05:21 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: How to change the logic .......?

Kumar wrote:

> Please tell me how can I modify and write in less numnber of lines,,,


Code and babies are born ugly.
However, it is a good idea to make sure
the baby can cry before you clean him up much.
In vhdl you do this by running a sim to make sure
the design does what you expect.
If it doesn't, clean-up is irrelevant.

Once your code sims ok, I would start by
putting repeated code sequences into loops.
Re-run your sim after each clean up.

-- Mike Treseler
Reply With Quote
  #3 (permalink)  
Old 10-20-2005, 09:06 PM
Kumar
Guest
 
Posts: n/a
Default Re: How to change the logic .......?

Ya baby need to be cleaned but which part of th e baby!! Can u tell
me exact changed code???

Reply With Quote
  #4 (permalink)  
Old 10-20-2005, 09:37 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: How to change the logic .......?

Kumar wrote:
> Can u tell me exact changed code???


Post a working testbench and I'll have a look.

-- Mike Treseler
Reply With Quote
  #5 (permalink)  
Old 10-21-2005, 02:57 AM
Mark McDougall
Guest
 
Posts: n/a
Default Re: How to change the logic .......?

Mike Treseler wrote:

> Code and babies are born ugly. However, it is a good idea to make
> sure the baby can cry before you clean him up much. In vhdl you do
> this by running a sim to make sure the design does what you expect.
> If it doesn't, clean-up is irrelevant.


IMHO, it depends...

*Really* ugly code that is a result of poor design due to, for example,
inexperience may be a 'lost cause' if one wastes too much time trying to
get it to work. At some point down this track one generally questions
oneself whether or not there is a better way to do things, and by asking
for advice/pointers you generally end up saving time and learning
something along the way.

I'm NOT saying that this post is an example of that!

Just saying that *some* paths are best abandoned.

Regards,
Mark
Reply With Quote
  #6 (permalink)  
Old 10-21-2005, 05:10 AM
Kumar
Guest
 
Posts: n/a
Default Re: How to change the logic .......?

Here is testbench Mike!!!

logfile mem.log

bitvec input ea_3 ea_2 ea_1 ea_0
bitvec f rw
sbvec input 1000
sbvec f 0

watch clk
dl
uvec clk 10101010101010101010
watch wrc_2
watch wrc_1
watch wrc_0
runvec

sbvec input 1010
sbvec f 0

watch clk
dl
uvec clk 10101010101010101010
watch wrc_2
watch wrc_1
watch wrc_0
runvec

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change OCM Clock Joey FPGA 3 05-02-2005 05:25 PM
state change Urban Stadler VHDL 4 09-01-2004 08:53 AM
Please HELP !! register not change Hayami VHDL 2 03-07-2004 06:24 PM
Pass transistor logic and multi-valued logic in a FPGA Nitin FPGA 1 10-24-2003 02:22 PM


All times are GMT +1. The time now is 01:17 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved