Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I dont wont to save the "space" in SRAM, Help me ?

Status
Not open for further replies.

Bebo

Newbie level 4
Joined
Nov 17, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
UAE
Activity points
1,404
Hi every body ...

i wrote a code that receive data RS232 and save it on the SRAM ... and its work :)

But i have problem...
i don't wont to save a " space " ,which equal 20 in hex, with the data ...i tried to modify my code but i failed

PLZ... help me :(

this my code :

#### MEM_SRAM #####################################

module MEM_SRAM (
Data_Bus, // Data Bus
Address, // RAM Address
nRD, // RAM Read Enable
nWR, // RAM Write Enable
nCE, // RAM Chip Enable
nUB, // RAM Upper Byte
nLB, // RAM Lower Byte
Data_In,
Address_In,
RxD_endofpacket,
LEDR,
clk); // Write Enable

output reg [17:0] Address; // RAM Signals // include
inout [7:0] Data_Bus;
output nRD, nWR;
output nUB, nLB;
output nCE;
reg [1:0] WE; // Write Enable
input [17:0] Address_In ;
input [7:0] Data_In;
input RxD_endofpacket;
output [17:0] LEDR; // include reg
input clk;
assign nUB = 1'b1; // Disable Upper Byte
assign nLB = 1'b0; // Enable Lower Byte
assign nCE = 1'b0; // Enable Chip
assign nRD = 1'b0; // Read Enable
assign nWR = !WE; // Write Enable


assign Data_Bus = WE? Data_In : 8'hzz;

always @(posedge RxD_endofpacket)
if(RxD_endofpacket==1)
begin
if ( Data_In == "00100000")
WE=1'b0;
else
WE=1'b1;

Address <= Address + 1;
end

assign LEDR = Address;

###################################


This is the module that combines the receiver module and the SRAM module

######## ############################

module serialfun(clk, RxD, RxD_data, nWR,nCE,
nRD,Address, Data_Bus,LED,Data_In,nUB,nLB,RxD_endofpacket,RxD_data_ready,RxD_idle);
input clk;
input RxD;
output RxD_idle;
output RxD_endofpacket;
output RxD_data_ready;
output nRD;
output nWR, nCE;
reg [1:0] WE;
output [17:0] Address;
inout [7:0] Data_Bus;
output [17:0] LED;
output nUB,nLB;

///////////////////////////////////////////////////
//wire RxD_data_ready;
output [7:0] RxD_data;
async_receiver deserializer(.clk(clk), .RxD(RxD), .RxD_data(RxD_data), .RxD_endofpacket(RxD_endofpacket),.RxD_idle(RxD_idle),.RxD_data_ready(RxD_data_ready) );
///////////////////////////////////////////////////

///////////////////////////////////////////////////////////
input [7:0] Data_In;
reg [17:0] Address_In ;

MEM_SRAM u0(.Data_Bus(Data_Bus), .Address(Address), .nRD(nRD), .nUB(nUB), .nLB(nLB),
.nWR(nWR), .nCE(nCE), .Address_In(Address_In), .Data_In(RxD_data),.LEDR(LED),.RxD_endofpacket(RxD_endofpacket));


endmodule
 

Re: I dont wont to save the "space" in SRAM, Help

In your code, Address is always incremented when RxD_endofpacket==1.

It should look something like this:

Code:
  if ( Data_In == 'h20 )
     WE <= 1'b0;
  else begin
     WE <= 1'b1;
     Address <= Address + 1;
  end

You might want to check your code.
1) The check for RxD_endofpacket==1 is redundant because of posedge RxD_endofpacket (should that be posedge clk instead?)
2) It looks like WE stays high until Data_In == 'h20
 

Re: I dont wont to save the "space" in SRAM, Help

thank you devnull

i changed my code ..

the WE (Write Enable ) will enter the MEM code as input and i will check the if the data is " space " or any other data from out side and then sign WE to write or not to the memory.

and in the MEM code i will just increment the Address.

Do you think that my logic is writ or not ???


module that combines the receiver module and the SRAM module:
###############################################
module serialfun(clk, RxD, RxD_data, nWR,nCE,
nRD,Address, Data_Bus,LED,Data_In,nUB,nLB,RxD_endofpacket,RxD_data_ready,RxD_idle,WE);
input clk;
input RxD;
output RxD_idle;
output RxD_endofpacket;
output RxD_data_ready;
output nRD;
output nWR, nCE;
output reg WE;
output [17:0] Address;
inout [7:0] Data_Bus;
output [17:0] LED;
output nUB,nLB;

///////////////////////////////////////////////////
//wire RxD_data_ready;
output [7:0] RxD_data;
async_receiver deserializer(.clk(clk), .RxD(RxD), .RxD_data(RxD_data), .RxD_endofpacket(RxD_endofpacket),.RxD_idle(RxD_idle),.RxD_data_ready(RxD_data_ready) );

///////////////////////////////////////////////////

always @(posedge RxD_endofpacket)
if(RxD_endofpacket==1)
begin
if ( RxD_data == 8'b00100000)
WE=1'b0;
else
WE=1'b1;
end
///////////////////////////////////////////////////////////

assign Data_Bus = WE? RxD_data : 8'hzz;

///////////////////////////////////////////////////////////

input [7:0] Data_In;
reg [17:0] Address_In ;

MEM_SRAM u0(.Data_Bus(Data_Bus), .Address(Address), .nRD(nRD), .nUB(nUB), .nLB(nLB),
.nWR(nWR), .nCE(nCE), .Address_In(Address_In), .Data_In(RxD_data),.LEDR(LED),.RxD_endofpacket(RxD_endofpacket),.WE(WE));


endmodule [/color]

###################################################

SRAM CODE :
####################################################
module MEM_SRAM (
Data_Bus, // Data Bus
Address, // RAM Address
nRD, // RAM Read Enable
nWR, // RAM Write Enable
nCE, // RAM Chip Enable
nUB, // RAM Upper Byte
nLB, // RAM Lower Byte
Data_In,
Address_In,
RxD_endofpacket,
LEDR,
WE,
clk); // Write Enable

output reg [17:0] Address; // RAM Signals // include
inout [7:0] Data_Bus;
output nRD, nWR;
output nUB, nLB;
output nCE;
input WE; // Write Enable
input [17:0] Address_In ;
input [7:0] Data_In;
input RxD_endofpacket;
output [17:0] LEDR; // include reg
input clk;
assign nUB = 1'b1; // Disable Upper Byte
assign nLB = 1'b0; // Enable Lower Byte
assign nCE = 1'b0; // Enable Chip
assign nRD = 1'b0; // Read Enable
assign nWR = !WE; // Write Enable



always @(posedge RxD_endofpacket)
if(RxD_endofpacket==1)
begin
if(WE==1)
Address <= Address + 1;
else
Address <= Address + 0;
end


assign LEDR = Address;

###########################################3
 

Re: I dont wont to save the "space" in SRAM, Help

The best way to determine if your code will work or not is to simulate and look at the waveforms.
 

Re: I dont wont to save the "space" in SRAM, Help

i dont know what is wrong with my code ?? :/

when i send the data like ( for example) >>>1 then 2 then "space" then 3 then 4

the data saved like this in SRAM >>>> 1 then 2 then "space" then 4

i dont know why it save the "space" and skip 3 >>????

this is my whole project :

###########################################

module serialfun(clk, RxD, RxD_data, nWR,nCE,
nRD,Address, Data_Bus,LED,Data_In,nUB,nLB,RxD_endofpacket,RxD_data_ready,RxD_idle,WE);
input clk;
input RxD;
output RxD_idle;
output RxD_endofpacket;
output RxD_data_ready;
output nRD;
output nWR, nCE;
output reg WE;
output [17:0] Address;
inout [7:0] Data_Bus;
output [17:0] LED;
output nUB,nLB;


///////////////////////////////////////////////////
//wire RxD_data_ready;
output [7:0] RxD_data;
async_receiver deserializer(.clk(clk), .RxD(RxD), .RxD_data(RxD_data), .RxD_endofpacket(RxD_endofpacket),.RxD_idle(RxD_idle),.RxD_data_ready(RxD_data_ready) );

///////////////////////////////////////////////////

always @(posedge RxD_endofpacket)
if(RxD_endofpacket==1)
begin
if ( RxD_data == 8'b00100000)
WE=1'b0;


else
WE=1'b1;

end
///////////////////////////////////////////////////////////

//assign Data_Bus = WE? RxD_data : 8'hzz;
input [7:0] Data_In;
reg [17:0] Address_In ;

///////////////////////////////////////////////////////////



MEM_SRAM u0(.Data_Bus(Data_Bus), .Address(Address), .nRD(nRD), .nUB(nUB), .nLB(nLB),
.nWR(nWR), .nCE(nCE), .Address_In(Address_In), .Data_In(RxD_data),.LEDR(LED),.RxD_endofpacket(RxD_endofpacket),.WE(WE));


endmodule


##############################################

module MEM_SRAM (
Data_Bus, // Data Bus
Address, // RAM Address
nRD, // RAM Read Enable
nWR, // RAM Write Enable
nCE, // RAM Chip Enable
nUB, // RAM Upper Byte
nLB, // RAM Lower Byte
Data_In,
Address_In,
RxD_endofpacket,
LEDR,
WE,
clk); // Write Enable

output reg [17:0] Address; // RAM Signals // include
inout [7:0] Data_Bus;
output nRD, nWR;
output nUB, nLB;
output nCE;
input WE; // Write Enable
input [17:0] Address_In ;
input [7:0] Data_In;
input RxD_endofpacket;
output [17:0] LEDR; // include reg
input clk;
assign nUB = 1'b1; // Disable Upper Byte
assign nLB = 1'b0; // Enable Lower Byte
assign nCE = 1'b0; // Enable Chip
assign nRD = 1'b0; // Read Enable
assign nWR = !WE; // Write Enable


assign Data_Bus = WE? Data_In : 8'hzz;

always @(posedge RxD_endofpacket)
if(RxD_endofpacket==1)
begin
if(WE==1)
Address <= Address + 1;

//else
//Address <= Address + 0;
end

assign LEDR = Address;


endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top